#include <bits/stdc++.h>
using namespace std;
int main(){
	do{
		int a=rand()%20000+1,b=rand()%20000+1;
		FILE*f=fopen("conf.in","w");
		fprintf(f,"%d %d\n",a,b);
		fclose(f);
		fprintf(stderr,"gen\n");
		system("./gen_chain1<conf.in>barrack.in");
		fprintf(stderr,"ans\n");
		system("./chain<conf.in>barrack.ans");
		fprintf(stderr,"out\n");
		system("./barrack");
	}while(!system("diff -b -B barrack.out barrack.ans"));
	return 0;
}