#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n, k;
int cap[maxn], dis[maxn], food[maxn];
int emp[maxn];
int ord[maxn];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &k);
    n--;
    for (int i = (1), _b = (k); i <= _b; ++i) scanf("%d", &cap[i]);
    for (int i = (1), _b = (n); i <= _b; ++i)
      scanf("%d%d", &food[i], &dis[i]), ord[food[i]]++;
    int alter = 0, ans = 0;
    for (int i = (1), _b = (n + 1); i <= _b; ++i) {
      if (i == n + 1) {
        for (int j = (1), _b = (k); j <= _b; ++j) emp[j] = alter >= cap[j];
        break;
      }
      if (dis[i] == 0) {
        if (food[i])
          ord[food[i]]--, cap[food[i]]--;
        else
          alter++;
      } else {
        int pos, xmin = 1000000;
        for (int j = (1), _b = (k); j <= _b; ++j)
          if (ord[j] == 0) {
            if (xmin > cap[j]) xmin = cap[j], pos = j;
            emp[j] = alter >= cap[j];
          } else
            emp[j] = 0;
        alter -= cap[pos];
        for (int j = (i), _b = (n); j <= _b; ++j) {
          if (food[j])
            cap[food[j]]--, ord[food[j]]--;
          else
            alter++;
        }
        for (int j = (1), _b = (k); j <= _b; ++j) emp[j] |= alter >= cap[j];
        break;
      }
    }
    for (int i = (1), _b = (k); i <= _b; ++i) {
      if (emp[i])
        putchar('Y');
      else
        putchar('N');
    }
    putchar('\n');
  }
  return 0;
}
