#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    p /= 2;
  }
  return ret;
}
long long power(long long a, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a);
    a = (a * a);
    p /= 2;
  }
  return ret;
}
vector<int> a;
vector<pair<int, int> > p;
vector<bool> empty;
int main() {
  int i, j, tmp;
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int m, k, x, y;
    cin >> m >> k;
    a.clear();
    empty.clear();
    p.clear();
    a.push_back(-1);
    empty.push_back(0);
    for (i = 0; i < k; i++) {
      cin >> tmp;
      a.push_back(tmp);
      empty.push_back(0);
    }
    for (i = 0; i < m - 1; i++) {
      cin >> x >> y;
      p.push_back(make_pair(x, y));
    }
    bool fl = 0;
    int sub = 0;
    int pos = m;
    for (i = 0; i < m - 1; i++) {
      x = p[i].first;
      y = p[i].second;
      if (!y) {
        if (x)
          a[x]--;
        else
          sub++;
      } else {
        fl = 1;
        pos = i;
        break;
      }
    }
    for (i = 1; i < k + 1; i++)
      if (a[i] <= sub) empty[i] = 1;
    for (i = pos; i < m - 1; i++) {
      x = p[i].first;
      if (x) {
        a[x]--;
        empty[x] = 0;
      } else
        sub++;
    }
    if (fl) {
      int done = INT_MAX;
      for (i = 1; i < k + 1; i++)
        if (empty[i]) done = min(done, a[i]);
      sub -= done;
    }
    for (i = 1; i < k + 1; i++)
      if (a[i] <= sub) empty[i] = 1;
    for (i = 1; i < k + 1; i++) {
      if (empty[i])
        cout << "Y";
      else
        cout << "N";
    }
    cout << endl;
  }
  return 0;
}
