#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<vector>
#include<algorithm>
#define infile "inrudit.in"
#define tmax 100

using namespace std;

struct test
{
    int k;
    int l; //number of digits for X
    int i; //number of identical digits at the end of X
} t[tmax];
int nr; //tests number

inline int randomValue(int a, int b)
{
  return (rand()%(b-a+1)) + a;
}

string makeString(int x)
{
  if(!x) return "0";
  string str;
  while(x)
    str = char((x%10) + '0') + str, x /= 10;
  return str;
}

void init()
{
  nr=20;
  t[1].k=1;                 t[1].l=5;       t[1].i=1;
  t[2].k=13;                t[2].l=7;       t[2].i=2;
  t[3].k=31;                t[3].l=8;       t[3].i=3;
  t[4].k=1;                 t[4].l=31;      t[4].i=13;
  t[5].k=100*1000;          t[5].l=69;      t[5].i=31;
  t[6].k=1000*1000;         t[6].l=131;     t[6].i=1;
  t[7].k=100*1000*1000;     t[7].l=313;     t[7].i=13;
  t[8].k=200*1000*1000;     t[8].l=444;     t[8].i=31;
  t[9].k=300*1000*1000;     t[9].l=456;     t[9].i=131;
  t[10].k=400*1000*1000;    t[10].l=500;    t[10].i=1;
  t[11].k=500*1000*1000;    t[11].l=512;    t[11].i=13;
  t[12].k=600*1000*1000;    t[12].l=600;    t[12].i=31;
  t[13].k=1;                t[13].l=616;    t[13].i=131;
  t[14].k=700*1000*1000;    t[14].l=666;    t[14].i=1;
  t[15].k=750*1000*1000;    t[15].l=750;    t[15].i=13;
  t[16].k=800*1000*1000;    t[16].l=789;    t[16].i=31;
  t[17].k=1;                t[17].l=890;    t[17].i=131;
  t[18].k=900*1000*1000;    t[18].l=997;    t[18].i=1;
  t[19].k=1000*1000*1000;   t[19].l=999;    t[19].i=13;
  t[20].k=1;                t[20].l=1000;   t[20].i=31;
}

void generate(struct test t, int nr)
{ //generate test number nr
  string file = makeString(nr) + "-" + infile;
  freopen(file.c_str(), "w", stdout);
  char number[t.l+1];
  number[t.l] = 0;

  for (int i = 0; i < t.l; ++i) {
      number[i] = randomValue(0, 9);

      if (i == 0 && number[i] == 0) {
          number[i]++;
      }

      number[i] += '0';
  }

  int identicalDigit = randomValue(1, 9);

  for (int i = 0; i < t.i; ++i) {
      number[t.l - i - 1] = identicalDigit + '0';
  }

  printf("%d\n%s\n", t.k, number);

  fclose(stdout);
}

int main()
{
  srand((unsigned)time(0));
  init();

  for(int i = 1; i <= nr; ++i)
    generate(t[i],i);

  return 0;
}
