#include<cstdio>
#include<cstring>
#include<cassert>
#define MAX 1000000
bool t[MAX+1];
int main(int argc,char *argv[]){
  FILE *in=fopen(argv[1],"r"),*out=fopen(argv[2],"r"),*correct_out=fopen(argv[3],"r");
  int Z,n,m;
  fscanf(in,"%d",&Z);
  for(int z=1;z<=Z;z++){
    fscanf(in,"%d %d",&n,&m);
    assert(0<=n);
    assert(n<=MAX);
    assert(0<=m);
    assert(m<=MAX);
    for(int i=1;i<=n;i++)t[i]=0;
    char buf[100];
    fscanf(correct_out," %10s",buf);
    if(!strcmp(buf,"NO")){
      fscanf(out," %10s",buf);
      if(strcmp(buf,"NO")){printf("WRONG\nexpected NO\n");return 1;}
      for(int i=0;i<m;i++)fscanf(in,"%*d");
      continue;
    }
    fscanf(out," %10s",buf);
    if(strcmp(buf,"YES")){printf("WRONG\nexpected YES\n");return 1;}
    while(m--){
      int command,where;
      fscanf(in,"%d",&command);
      if(command){
        if(!t[command]){printf("WRONG\nempty lake\n");return 1;}
        t[command]=0;
      }else{
        fscanf(correct_out,"%*d");
        if(fscanf(out,"%d",&where)!=1){printf("WRONG\ninteger expected\n");return 1;}
        if(where<0||n<where||t[where]){printf("WRONG\ninvalid bin number\n");return 1;}
		if(where) t[where]=1;
      }
    }
  }
  puts("OK");
  return 0;
}
