#include <bits/stdc++.h>
using namespace std;
const int N = 110000;
int a[N], wei[N], r1, r2;
bool can[N], ans[N];
int n, m;
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &n, &m);
    n--;
    for (int i = (1); i <= (int)m; i++) {
      scanf("%d", &a[i]);
      wei[i] = a[i];
      ans[i] = 0;
      can[i] = 1;
    }
    r1 = r2 = 0;
    int shiwang = 0;
    for (int i = (1); i <= (int)n; i++) {
      int x, y;
      scanf("%d%d", &x, &y);
      if (y == 1) {
        if (!shiwang) shiwang = i;
      }
      if (!shiwang && x == 0) r1++;
      if (x == 0) r2++;
      if (shiwang) can[x] = 0;
      a[x]--;
      if (!shiwang) wei[x]--;
    }
    if (!shiwang) {
      for (int i = (1); i <= (int)m; i++)
        if (a[i] <= r2)
          printf("Y");
        else
          printf("N");
      printf("\n");
    } else {
      int lu = 0;
      for (int i = (1); i <= (int)m; i++)
        if (can[i] && wei[i] <= r1) {
          ans[i] = 1;
          if (r2 - wei[i] > lu) lu = r2 - wei[i];
        }
      for (int i = (1); i <= (int)m; i++) {
        if (a[i] <= lu) ans[i] = 1;
        if (ans[i])
          printf("Y");
        else
          printf("N");
      }
      printf("\n");
    }
  }
  return 0;
}
