#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T sqr(T x) {
  return x * x;
}
const double EPS = 1e-9;
struct Solver {
  int m, k;
  vector<int> a;
  vector<int> t;
  vector<int> r;
  void solve() {
    scanf("%d%d", &m, &k);
    --m;
    a.resize(k);
    for (int i = 0; i < (int)k; ++i) {
      scanf("%d", &a[i]);
    }
    t.resize(m);
    r.resize(m);
    for (int i = 0; i < (int)m; ++i) {
      scanf("%d%d", &t[i], &r[i]);
    }
    vector<char> was_after_border(k, false);
    int cnt_free = 0;
    int cnt_free_to_border = -1;
    for (int i = 0; i < (int)m; ++i) {
      if (r[i] == 1 && cnt_free_to_border == -1) {
        cnt_free_to_border = cnt_free;
      }
      if (t[i]) {
        --a[t[i] - 1];
        if (cnt_free_to_border != -1) {
          was_after_border[t[i] - 1] = true;
        }
      } else {
        ++cnt_free;
      }
    }
    int min_id = -1;
    for (int i = 0; i < (int)k; ++i) {
      if (!was_after_border[i] && (min_id == -1 || a[i] < a[min_id])) {
        min_id = i;
      }
    }
    string ans;
    for (int i = 0; i < (int)k; ++i) {
      bool can = false;
      if (cnt_free_to_border >= a[i] && !was_after_border[i]) {
        can = true;
      }
      if (cnt_free >= a[i] + a[min_id]) {
        can = true;
      }
      if (cnt_free_to_border == -1) {
        can = cnt_free >= a[i];
      }
      ans += can ? 'Y' : 'N';
    }
    printf("%s\n", ans.c_str());
  }
};
int main() {
  int T;
  scanf("%d", &T);
  while (T-- > 0) {
    Solver solver;
    solver.solve();
  }
  return 0;
}
