public class Main { public static void main(String[] args) throws Exception { for (int i = 0; i < 8; i++) { int a = i >> 0 & 1; int b = i >> 1 & 1; int c = i >> 2 & 1; int x = nand(nand(a, b), c); int y = nand(a, nand(b, c)); if (x != y) { System.out.println(a + " " + b + " " + c); return; } } } static int nand(int a, int b) { if (a == 1 && b == 1) { return 0; } else { return 1; } } }