using System; using System.Linq; namespace No355{ public class Program{ public static void Main(string[] args){ Func output = s =>{ if(s.Distinct().Count() != s.Length) return new [] {-1, -1}; Console.WriteLine(string.Join(" ", s.ToCharArray())); return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse); }; int[] res; for(var i = 1234;; i++){ var x = output(i.ToString()); if(x[0] == 4) return; if(x[1] == 0){ res = i.ToString().Select(c => c - '0').ToArray(); break; } } for(var i = 0; i < 4; i++){ for(var j = 0; j < 10; j++){ res[i] = j; var x = output(string.Join("", res)); if(x[0] == i + 1) break; } } } } }