// kuko
// stdin <- contestant's solution
// argv[1] <- input file
// example: tester K1.in < K1.out

#include <cstdio>
#include <cassert>
#include <algorithm>
#include <bitset>
#define REP(i, n) for (int i = 0; i < (int) (n); ++i)
using namespace std;

#define FORMAT(x) if (!(x)) { printf("Invalid format.\n"); exit(1); }

#define MAX 2000

int n, m;
bitset<MAX> col;
bitset<MAX> a[MAX];

void click (int x) {
  if (!col[x]) {
    printf("Clicked on a white vertex.\n");
    exit(2);
  }

  col[x] = 0;
  col ^= a[x]; // flip colors of the neighbours
  for (int y=0; y<n; ++y)
    if (a[x][y]) a[y] ^= a[x];
  for (int y=0; y<n; ++y)
    if (a[x][y]) a[x][y] = a[y][x] = a[y][y] = 0;
}


void solve() {
  int l, x;
  FORMAT(scanf("%d", &l) == 1);
  FORMAT(0 <= l && l <= n);
  REP(i, l) {
    FORMAT(scanf("%d", &x) == 1);
    FORMAT(0 <= x && x < n)
    click (x);
  }
}

int main(int argc, char **argv) {
  int T;
  char s[MAX];

  assert(argc == 2);
  FILE *input = fopen(argv[1], "r");

  fscanf(input, "%d", &T);
  for (int t = 0; t < T; ++t) {
    col.reset();
    REP(x, MAX) a[x].reset();
    // read input
    fscanf (input, "%d %d\n", &n, &m);
    fscanf (input, "%s", s);
    for (int i=0; i<n; ++i) {
      col[i] = (s[i] == 'B');
    }
    for (int i=0; i<m; ++i) {
      int x, y;
      fscanf (input, "%d %d", &x, &y);
      a[x][y] = a[y][x] = 1;
    }

    solve();

    if (col.count() > 0) {
      printf ("black vertices remain\n");
      exit(3);
    }
    for (int i=0; i<n; ++i)
      if (a[i].count() > 0) {
        printf ("there are some remaining edges\n");
        exit(4);
      } 
  }

  printf ("OK\n");
  return 0;
}

