using System.Collections.Generic;
static bool Compare(string n1, string n2, int bulls, int cows)
List<int> bPos = new List<int> { };
for (int i = 0; i < 4; i++)
for (int i = 0; i < 4; i++)
List<int> cPos = new List<int> { };
for (int i = 0; i < 4 - b; i++)
char candidate = newN2[i];
if (newN1.Contains(candidate.ToString()))
int index = newN1.IndexOf(candidate);
if (!cPos.Contains(index))
if (b == bulls && c == cows)
public static void Main()
string n1 = Console.ReadLine();
int bulls = int.Parse(Console.ReadLine());
int cows = int.Parse(Console.ReadLine());
for (int i = 1000; i < 10000; i++)
if (!n2.Contains("0") && Program.Compare(n2, n1, bulls, cows))
if (bulls + cows > 4 || bulls > 4 || cows > 4 || count==0)