#include <stdio.h>

int message[]=
{80, 125, 111, 18, 59, 88, 88, 28, 65, 98, 119, 103, 101, 79, 107, 2, 16,
92, 102, 123, 103, 84, 112, 78, 68, 98, 65, 37, 105, 85, 107, 13, 45, 9,
104, 81, 21, 31, 55, 110, 78, 66, 66, 3, 77, 63, 16, 105, 15, 123, 16, 84,
31, 96, 4, 82, 82, 122, 68, 115, 35, 73, 3, 108, 115, 83, 15, 19, 31, 99, 5,
123, 24, 65, 36, 15, 75, 84, 4, 2, -1};

char res[100];

int lim=100000001;

int valid(int x)
{
  if (x>='A' && x<='Z') return 1;
  if (x==' ' || x=='.' || x==',' || x=='\'' || x=='?' || x=='!') return 1;
  return 0;
}

void mainloop(long long x)
{
  int i;
  long long a, b, c;
  
  c=2;
  for (i=0; message[i]!=-1; i++)
  {
    a=4*i*i*i+6*i*i+4*i+1;
    while(a--) c=(c*x+1)%lim;
    b=(c/100)%100;
    res[i]=message[i]^b;
    if (!valid(res[i])) return;
    if (i==10)
    {
      res[i+1]=0;
      printf("Possible solution?: %lld %s\n", x, res);
    }
  }
  res[i]=0;
  printf("Solution: %lld %s\n", x, res);
}

int main()
{
  int x;
  for (x=100000000; x<=200000000; x++) mainloop(x);
  return 0;
}
