#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int N = 1000010;
const int MOD = 1e9 + 7;
int t, m, k, a[N], b[N], r[N], ans[N];
bool used[N];
string res;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d%d", &m, &k);
    for (int i = 1; i <= k; i++) scanf("%d", &a[i]);
    for (int i = 1; i < m; i++) scanf("%d%d", &b[i], &r[i]);
    for (int i = 1; i <= k; i++) used[i] = false;
    int ind = -1;
    for (int i = 1; i < m; i++)
      if (r[i] == 1) {
        ind = i;
        break;
      }
    for (int i = 1; i <= k; i++) ans[i] = false;
    res = "";
    int s = 0;
    if (ind == -1) {
      for (int i = 1; i < m; i++)
        if (b[i] != 0)
          a[b[i]]--;
        else
          s++;
      for (int i = 1; i <= k; i++)
        if (a[i] <= s) ans[i] = true;
    } else {
      for (int i = 1; i < ind; i++)
        if (b[i] != 0)
          a[b[i]]--;
        else
          s++;
      for (int i = ind; i < m; i++)
        if (b[i] != 0) used[b[i]] = true;
      int val = inf;
      for (int i = 1; i <= k; i++)
        if (a[i] <= s) {
          if (!used[i]) {
            val = min(val, a[i]);
            ans[i] = true;
          }
        }
      for (int i = ind; i < m; i++)
        if (b[i] != 0)
          a[b[i]]--;
        else
          s++;
      for (int i = 1; i <= k; i++)
        if (a[i] <= s - val) ans[i] = true;
    }
    for (int i = 1; i <= k; i++)
      if (ans[i])
        res += 'Y';
      else
        res += 'N';
    cout << res;
    printf("\n");
  }
  return 0;
}
