#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int N = 100005;
const int inf = 2000000000;
struct mytype {
  int t, r;
} b[N];
int a[N], cnt[N];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    bool nul = 0;
    cnt[0] = 0;
    for (int i = 1; i <= m; i++) {
      cin >> a[i];
      cnt[i] = 0;
      if (!a[i]) nul = 1;
    }
    for (int i = 1; i < n; i++) {
      cin >> b[i].t >> b[i].r;
      cnt[b[i].t]++;
    }
    int any = 0;
    for (int i = 1; i < n; i++) {
      int t = b[i].t, r = b[i].r;
      if (r && !nul) {
        int d = inf;
        for (int j = 1; j <= m; j++)
          if (!cnt[j] && a[j] <= any) {
            d = min(d, a[j]);
            a[j] = 0;
          }
        any -= d;
        nul = 1;
      }
      cnt[t]--;
      if (t)
        a[t]--;
      else
        any++;
      a[t] = max(a[t], 0);
      if (t && !a[t]) nul = 1;
    }
    for (int i = 1; i <= m; i++)
      if (a[i] <= any)
        cout << 'Y';
      else
        cout << 'N';
    cout << '\n';
  }
}
