#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t-- > 0) {
    int m, k;
    cin >> m >> k;
    vector<int> a(k);
    for (int i = 0; i < k; i++) cin >> a[i];
    int n = m - 1;
    vector<int> t(n), r(n);
    for (int i = 0; i < n; i++) cin >> t[i] >> r[i];
    int unknown = 0;
    bool isFirst = true;
    string ans = "";
    for (int i = 0; i < k; i++) ans += 'N';
    for (int i = 0; i < n; i++) {
      if (r[i] == 1 && isFirst) {
        isFirst = false;
        vector<bool> was(k, false);
        for (int j = i; j < n; j++)
          if (t[j] != 0) was[t[j] - 1] = true;
        int ind_min = -1;
        for (int j = 0; j < k; j++) {
          if (a[j] <= unknown && !was[j]) {
            if (ind_min == -1 || a[ind_min] > a[j]) ind_min = j;
            ans[j] = 'Y';
          }
        }
        unknown -= a[ind_min];
        a[ind_min] = 0;
      }
      if (t[i] == 0)
        unknown++;
      else
        a[t[i] - 1]--;
    }
    for (int i = 0; i < k; i++)
      if (a[i] <= unknown) ans[i] = 'Y';
    cout << ans << '\n';
  }
  return 0;
}
