/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
System.out.println(booleanExpression(true, true, true, true));
System.out.println(booleanExpression(true, true, true, false));
System.out.println(booleanExpression(false, false, false, true));
System.out.println(booleanExpression(false, false, false, false));
System.out.println(booleanExpression(true, false, true, false));
}
public static boolean booleanExpression(boolean a, boolean b, boolean c, boolean d)
{
if (a && b) return !(c || d);
if (c && d) return !(a || b);
return (a || b) && (c || d);
}
}