#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9;
const long long LINF = (long long)8e18;
const long double EPS = 1e-9;
int n, k;
int main() {
  int ncase;
  int a, b;
  cin >> ncase;
  for (int tcase = 0; tcase < ncase; tcase++) {
    scanf("%d%d", &n, &k);
    vector<int> tr(k);
    for (int i = 0; i < k; i++) {
      scanf("%d", &tr[i]);
    }
    int xset = INF;
    int freep = 0;
    string oks(k, 'N');
    vector<int> clone;
    int clonefree;
    vector<int> used(k, -1);
    for (int i = 1; i < n; i++) {
      scanf("%d%d", &a, &b);
      if (b && clone.empty()) {
        xset = i;
        clone = tr;
        clonefree = freep;
      }
      if (a) {
        used[a - 1] = i;
        tr[a - 1]--;
      } else {
        freep++;
      }
    }
    if (!clone.empty()) {
      int mn = INF;
      for (int i = 0; i < k; i++) {
        if (used[i] < xset) {
          mn = min(mn, clone[i]);
          if (clonefree >= clone[i]) {
            oks[i] = 'Y';
          }
        }
      }
      freep -= mn;
    }
    for (int i = 0; i < k; i++) {
      if (freep >= tr[i]) {
        oks[i] = 'Y';
      }
    }
    cout << oks << "\n";
  }
  return 0;
}
