#include <bits/stdc++.h>
using namespace std;
long long n, mx, mxx, sm;
vector<long long> a, b, ti, dv;
int main() {
  ios_base::sync_with_stdio(0);
  long long m, t;
  cin >> t;
  for (int e = 1; e <= t; e++) {
    cin >> n >> m;
    b.resize(m + 1);
    for (int i = 1; i <= m; i++) cin >> b[i];
    long long unknown = 0, unbefup = 0;
    long long ups = 0;
    long long firstFin = 0;
    ti.resize(n);
    dv.resize(n);
    for (int i = 1; i < n; i++) {
      cin >> ti[i] >> dv[i];
      if (dv[i] && !ups) ups = i;
      if (!ti[i]) {
        unknown++;
        if (!ups) unbefup++;
      } else
        b[ti[i]]--;
    }
    if (!ups)
      for (int i = 1; i <= m; i++) cout << (b[i] <= unknown ? 'Y' : 'N');
    else {
      vector<long long> usedAfter(m + 1, 0);
      for (int i = ups; i < n; i++)
        if (ti[i]) usedAfter[ti[i]] = 1;
      vector<char> result(m + 1, 'N');
      long long firstMinFin = 0;
      for (int i = 1; i <= m; i++) {
        if (!usedAfter[i] && b[i] <= unbefup) {
          result[i] = 'Y';
          if (!firstMinFin || b[i] < b[firstMinFin]) firstMinFin = i;
        }
      }
      if (firstMinFin) {
        long long restUnk = unknown - b[firstMinFin];
        for (int i = 1; i <= m; i++) {
          if (b[i] <= restUnk) result[i] = 'Y';
        }
      }
      for (int i = 1; i <= m; i++) cout << result[i];
    }
    cout << "\n";
  }
  return 0;
}
