using System.Collections.Generic;
public static class Program
public static void Main()
Console.WriteLine("Enter value for A");
string aa = Console.ReadLine(); byte A = 0;
bool aq = byte.TryParse(aa,out A);
if(aq == false || A < 1 || A > 8)
Console.WriteLine("A can be only 1-8");
Console.WriteLine("Enter value for t");
string tt = Console.ReadLine(); byte t = 0;
bool at = byte.TryParse(tt, out t);
if (aq == false || t < 2 || t > 9)
Console.WriteLine("t can be only 2-9");
Console.WriteLine("Enter value for max B");
string bb = Console.ReadLine(); ushort maxB = 0;
bool bq = ushort.TryParse(bb,out maxB);
if(bq == false || maxB > 9999)
Console.WriteLine("B can be only 0-9999");
Console.WriteLine("Compiling...");
Console.Write(" B || a1 ");
if(A > 1) Console.Write("| a2");
if(A > 2) Console.Write("|a3");
if(A > 3) Console.Write("|a4");
if(A > 4) Console.Write("|a5");
if(A > 5) Console.Write("|a6");
if(A > 6) Console.Write("|a7");
if(A > 7) Console.Write("|a8");
ushort[] N = new ushort[9];
ushort[] Ncopy = new ushort[9];
StringBuilder p = new StringBuilder("");
StringBuilder answer = new StringBuilder("");
--t; byte w = t; byte v = 0; ++t;
for(byte i = A; i > 0; i--)
for(byte i = A; i > 0; i--)
for(byte ad = 1; ad < A+1; ad++)
++Ncopy[i]; --t; w = t; ++t; v = 0;
for(byte x = A; x > i; x--)
count = 0; bool boolean = true;
for(byte j = 1; j < A+1; j++)
if(Ncopy[j]==Ncopy[i]) ++count;
if(Ncopy[j] > Ncopy[j-1]) boolean = false;
if(count < t && boolean == true)
for(byte m = 1; m < A+1; m++)
answer.Remove(0,answer.Length);
p.Append(Convert.ToString(B));
for(int o = p.Length; o < 4; o++)
p.Append(Convert.ToString(N[1]));
for(int o = p.Length; o < 4; o++)
p.Append(Convert.ToString(N[2]));
if(p.Length > 3) {Console.WriteLine("oh nooo"); goto END;}
for(int o = p.Length; o < 3; o++)
for(byte d = 3; d < A+1; d++)
p.Append(Convert.ToString(N[d]));
if(p.Length > 2) {Console.WriteLine("oh nooo"); goto END;}
if(p.Length == 1) answer.Append(" ");
Console.WriteLine(answer);
Console.WriteLine("The End.");