#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int n, k;
bool vis[100005], ans[100005];
int tp[100005], rsp[100005], v[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc;
  cin >> tc;
  for (; tc-- > 0;) {
    cin >> n >> k;
    n--;
    for (int i = 1; i <= k; i++) {
      cin >> v[i];
      vis[i] = ans[i] = 0;
    }
    for (int i = 1; i <= n; i++) cin >> tp[i] >> rsp[i];
    bool flag = 1;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      if (rsp[i] && flag) {
        flag = 0;
        for (int j = i; j <= n; j++) vis[tp[j]] = 1;
        int mn = 1000000069;
        for (int j = 1; j <= k; j++)
          if (cnt >= v[j] && !vis[j]) {
            ans[j] = 1;
            if (mn > v[j]) mn = v[j];
          }
        cnt -= mn;
      }
      if (tp[i])
        v[tp[i]]--;
      else
        cnt++;
    }
    for (int i = 1; i <= k; i++)
      if (!ans[i] && cnt >= v[i]) ans[i] = 1;
    for (int i = 1; i <= k; i++) {
      if (ans[i])
        cout << "Y";
      else
        cout << "N";
    }
    cout << endl;
  }
  return 0;
}
