#include <bits/stdc++.h>
using namespace std;
FILE *f;
#define printf(args...) fprintf(f,##args)
inline void make()
{
    int T=20,n;
    printf("0 %d %d\n",T,(int)rand());
    while(T--)
    {
        n=(n%5)?(rand()%50+1)*2:(1<<(rand()%5+1)),
        printf("%d 1000 %d %d\n",n,rand()%n+1,(rand()&1)?500:10);
        while(n--) printf("%d ",rand()%998244353);
        printf("\n");
    }
}
#undef printf
int main()
{
    int i;
    for(i=1;i<=100;i++)
    {
        f=fopen("noodle.in","w"),make(),fclose(f);
        if(system("./bf")) { printf("bf RE\n"); return 0; }
        system("cp noodle.out noodle.ans");
        if(system("./test")) { printf("RE\n"); return 0; }
        if(system("diff noodle.out noodle.ans -w -q")) { printf("WA\n"); return 0; }
        if(!(i%10)) printf("passed %d tests\n",i);
    }
    return 0;
}