import java.io.*; import java.util.*; public class Main_yukicoder355 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); Printer pr = new Printer(System.out); Queue> q = new ArrayDeque<>(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (i == j) { continue; } for (int k = 0; k < 10; k++) { if (k == i || k == j) { continue; } for (int l = 0; l < 10; l++) { if (l == i || l == j || l == k) { continue; } ArrayList tmp = new ArrayList<>(); tmp.add(i); tmp.add(j); tmp.add(k); tmp.add(l); q.add(tmp); } } } } while (!q.isEmpty()) { // pr.println(q.size()); List e = q.remove(); send(e, pr); int x = sc.nextInt(); int y = sc.nextInt(); if (x == 4 && y == 0) { break; } Queue> qtmp = new ArrayDeque<>(); for (List ee : q) { if (eq(e, ee, x, y)) { qtmp.add(ee); } } q = qtmp; } pr.close(); sc.close(); } private static boolean eq(List e, List ee, int x, int y) { int xtmp = 0; int ytmp = 0; for (int i = 0; i < e.size(); i++) { for (int j = 0; j < e.size(); j++) { if (e.get(i) == ee.get(j)) { if (i == j) { xtmp++; } else { ytmp++; } } } } if (x == xtmp && y == ytmp) { return true; } else { return false; } } private static void send(List num, Printer pr) { pr.printf("%d %d %d %d\n", num.get(0), num.get(1), num.get(2), num.get(3)); pr.flush(); return; } @SuppressWarnings("unused") private static class Scanner { BufferedReader br; Iterator it; Scanner (InputStream in) { br = new BufferedReader(new InputStreamReader(in)); } String next() throws RuntimeException { try { if (it == null || !it.hasNext()) { it = Arrays.asList(br.readLine().split(" ")).iterator(); } return it.next(); } catch (IOException e) { throw new IllegalStateException(); } } int nextInt() throws RuntimeException { return Integer.parseInt(next()); } long nextLong() throws RuntimeException { return Long.parseLong(next()); } float nextFloat() throws RuntimeException { return Float.parseFloat(next()); } double nextDouble() throws RuntimeException { return Double.parseDouble(next()); } void close() { try { br.close(); } catch (IOException e) { // throw new IllegalStateException(); } } } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }