using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
StreamReader sr = new StreamReader(Console.OpenStandardInput());
StreamWriter sw = new StreamWriter(Console.OpenStandardOutput());
List<string[]> S = new List<string[]>();
List<string[]> SPom = new List<string[]>();
for (int k = 1; k < 7; k++)
{
for (int l = 1; l < 7; l++)
{
for (int m = 1; m < 7; m++)
{
for (int n = 1; n < 7; n++)
{
S.Add (new string[]{ k.ToString(),l.ToString(), m.ToString(), n.ToString() }) ;
//SPom.Add(k + "" + l + "" + m + "" + n);
}
}
}
}
string[] guess = new string[] { "1","1","2","2"};
for (int i = 0; i < guess.Length; i++)
{
Console.Write(guess[i]+" ");
}
Console.WriteLine();
//sw.WriteLine();
//Console.Clear();
//sw.Flush();
string[] hint = sr.ReadLine().Split(' ');
var asd = String.Join("",hint);
int counter = 1;
while (asd != "1111")
{
if (counter == 11)
break;
Array.Sort(hint);
foreach (var combo in S)
{
if (!isEqual(Outcome(combo, guess), hint)) { }
else
SPom.Add(combo);
}
S.Clear();
foreach (var item in SPom)
{
S.Add(item);
}
guess = S[0];
SPom.Clear();
for (int i = 0; i < guess.Length; i++)
{
Console.Write(guess[i] + " ");
}
Console.WriteLine();
//Console.Clear();
//sw.WriteLine();
//sw.Flush();
hint = sr.ReadLine().Split(' ');
asd = String.Join("", hint);
counter++;
}
}
static string[] Outcome(string[] combo,string[] guess)
{
//string[] outcome = new string[4];
List<string> o = new List<string>();
for (int i = 0; i < guess.Length; i++)
{
if (!hasElement(combo, guess[i]))
{
//outcome[i] = "-1";
o.Add("-1");
}
else if (guess[i].Equals(combo[i]))
{
//outcome[i] = "1";
o.Add("1");
}
else
{
//outcome[i] = "0";
o.Add("0");
}
}
//Array.Sort(outcome);
o.Sort();
return o.ToArray();
}
static bool isEqual(string[] tab1,string[] tab2)
{
for (int i = 0; i < tab2.Length; i++)
{
if (!(tab1[i].Equals(tab2[i])))
{
return false;
}
}
return true;
}
static bool hasElement(string[] arr,string str)
{
for (int i = 0; i < arr.Length; i++)
{
if (arr[i].Equals(str))
return true;
}
return false;
}
}
}