#include<bits/stdc++.h>
using namespace std;
const int N=1e5,V=1e9;
mt19937 rnd(time(0));
#define gc getchar()
#define rd read()
inline int read(){
int x=0,f=0; char c=gc;
for(;c<'0'||c>'9';c=gc) f|=(c=='-');
for(;c>='0'&&c<='9';c=gc) x=(x<<1)+(x<<3)+(c^48);
return f?-x:x;
}
void gen(){
FILE *p=fopen("data.in","w");
int n=rnd()%N+1,m=rnd()%N+1; fprintf(p, "%d %d\n", n, m);
for(int i=1;i<=n;++i) fprintf(p, "%d ", rnd()%V+1); fprintf(p, "\n");
for(int i=2;i<=n;++i) fprintf(p, "%d %d\n", rnd()%(i-1)+1, i);
for(int i=1;i<=m;++i){
if(rnd()&1) fprintf(p, "Q %d %d\n", rnd()%n+1, rnd()%n+1);
else fprintf(p, "C %d %d %d\n", rnd()%n+1, rnd()%n+1, rnd()%V+1);
}
fclose(p);
}
int main(){
int cnt=0;
while(++cnt){
gen();
system("Elaina < data.in > Elaina.out");
system("Vamilio < data.in > Vamilio.out");
if(system("fc Elaina.out Vamilio.out")) break;
}
return 0;
}