import javax.swing.*;

public class routes
{

    public static void main(String[] args)
    {
	String answer;

	answer = JOptionPane.showInputDialog(null,"is route A jammed?");
	if (answer.equals("yes")) 
	    {  // A jammed - take B
		answer = JOptionPane.showInputDialog(null,"3 jammed?");
		if (answer.equals("yes")) 
		    JOptionPane.showMessageDialog(null,"Take B then 4");
		else 
		    JOptionPane.showMessageDialog(null,"Take B then 3");

	    }  // A jammed - take B
	else
	    {  // A not jammed
		answer = JOptionPane.showInputDialog(null,"1 jammed?");
		if (answer.equals("yes"))
  		 {  // A free but 1 jammed - may need to check B again
		    answer = JOptionPane.showInputDialog(null,"2 jammed?");
		    if (answer.equals("yes"))
		     { //1 and 2 both jammed - take may want to take B
			 answer = JOptionPane.showInputDialog(null,"is route B jammed?");
			 if (answer.equals("yes"))
			     JOptionPane.showMessageDialog(null,"take A then 2");
			 else
			 {  //1,2 stuck, B not jammed - take B first

		           answer = JOptionPane.showInputDialog(null,"3 jammed?");
		           if (answer.equals("yes")) 
		             JOptionPane.showMessageDialog(null,"Take B then 4");
		           else 
		             JOptionPane.showMessageDialog(null,"Take B then 3");
			 }  // B not jammed - take B first
		     } //1 and 2 both jammed - take may want to take B
		     else
		     {  // A free 1 jammed, 2 not jammed
			 JOptionPane.showMessageDialog(null,"take a 2");
		     }
		 }  // A free but 1 jammed
		else
 		 {  // A and 1 not jammed
		     JOptionPane.showMessageDialog(null,"Take A then 1");
		 }
	    }  // A not jammed

	System.exit(0);
    }  // main
} 
