#include <bits/stdc++.h>
using namespace std;
void solve();
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) solve();
}
const int N = 1e5 + 5;
std::vector<int> last(N);
void solve() {
  int m, k;
  cin >> m >> k;
  std::vector<int> a(k);
  for (int i = 0; i < k; ++i) {
    cin >> a[i];
    last[i] = -1;
  }
  std::vector<pair<int, int> > q(m - 1);
  int idx = 0;
  int cnt = 0;
  for (int i = 1; i < m; ++i) {
    cin >> q[i - 1].first >> q[i - 1].second;
    if (q[i - 1].first == 0) {
      cnt++;
    }
    if (q[i - 1].second == 1 and idx == 0) {
      idx = i - 1;
    }
  }
  for (int i = 0; i < m - 1; ++i) {
    if (q[i].first) {
      last[q[i].first - 1] = i;
    }
  }
  int cnt2 = 0;
  for (int i = 0; i < idx; ++i) {
    if (q[i].first != 0) {
      a[q[i].first - 1]--;
    } else {
      cnt2++;
    }
  }
  string ans;
  ans.assign(k, 'N');
  int temp = 1e6;
  for (int i = 0; i < k; ++i) {
    if (last[i] < idx and a[i] <= cnt2) {
      ans[i] = 'Y';
      temp = min(temp, a[i]);
    }
  }
  for (int i = idx; i < m - 1; ++i) {
    if (q[i].first != 0) {
      a[q[i].first - 1]--;
    }
  }
  if (temp != int(1e6)) cnt -= temp;
  for (int i = 0; i < k; ++i) {
    if (a[i] - cnt <= 0) {
      ans[i] = 'Y';
    }
  }
  cout << ans << '\n';
}
