package no355; import java.util.Scanner; public class Main { static int[] query = new int[4]; static int hit = 0; static int blow = 0; static Scanner sc = new Scanner(System.in); public static void main(String[] args) { while(true) { for(int i=0;i<4;i++) { query[i] = (int) (Math.random() * 10); } if (!isValid()) continue; query(); if (hit == 0) break; } for(int i=0;i<4;i++) { query(); if (blow == 0) { for(int j=0;j<=9;j++) { query[i] = j; if (!isValid()) continue; query(); if (hit == i + 1) { break; } } }else{ for(int j=i+1;j<4;j++) { int t1 = query[i]; int t2 = query[j]; query[i] = t2; query[j] = t1; query(); if (hit == i + 1) { break; } query[i] = t1; query[j] = t2; } } } } public static boolean isValid() { boolean[] used = new boolean[10]; for(int i=0;i<4;i++) { int x = query[i]; if (used[x]) { return false; } used[x] = true; } return true; } public static void query() { StringBuilder sb = new StringBuilder(); for(int i=0;i<4;i++) { if (i > 0) sb.append(' '); sb.append(query[i]); } System.out.println(sb.toString()); hit = sc.nextInt(); blow = sc.nextInt(); } }