#include <bits/stdc++.h>
using namespace std;
int main(int argc, char* argv[]) {
  int tc;
  scanf("%d", &tc);
  for (int testCase = 0; testCase < int(tc); testCase++) {
    int m, k;
    scanf("%d %d", &m, &k);
    vector<int> a(k);
    for (int i = 0; i < int(k); i++) scanf("%d", &a[i]);
    vector<int> b(a);
    vector<int> t(m - 1), r(m - 1);
    int upset = -1;
    int unknown = 0;
    int unknownBeforeUpset = 0;
    for (int i = 0; i < int(m - 1); i++) {
      scanf("%d %d", &t[i], &r[i]);
      t[i]--;
      if (r[i] == 1 && upset == -1) upset = i;
      if (t[i] == -1) {
        unknown++;
        if (upset == -1) unknownBeforeUpset++;
      } else
        b[t[i]]--;
    }
    string result(k, 'N');
    if (upset == -1) {
      for (int i = 0; i < int(k); i++)
        if (b[i] <= unknown) result[i] = 'Y';
    } else {
      vector<bool> usedAfter(k, false);
      for (int i = upset; i < m - 1; i++)
        if (t[i] != -1) usedAfter[t[i]] = true;
      int minFirstFinished = -1;
      for (int i = 0; i < int(k); i++)
        if (!usedAfter[i] && unknownBeforeUpset >= b[i]) {
          result[i] = 'Y';
          if (minFirstFinished == -1 || b[minFirstFinished] > b[i])
            minFirstFinished = i;
        }
      if (minFirstFinished != -1) {
        int restUnknown = unknown - b[minFirstFinished];
        for (int i = 0; i < int(k); i++)
          if (b[i] <= restUnknown) result[i] = 'Y';
      }
    }
    printf("%s\n", result.c_str());
  }
  return 0;
}
