#include <bits/stdc++.h>
using namespace std;
const int kN = 100010;
const int kK = 100010;
int Z, N, K, A[kK];
int T[kN], R[kN];
void read();
void solve();
int main() {
  ios::sync_with_stdio(false);
  cin >> Z;
  for (int zi = 1; zi <= Z; ++zi) read(), solve();
  return 0;
}
void read() {
  cin >> N >> K;
  for (int i = 1; i <= K; ++i) cin >> A[i];
  for (int i = 1; i < N; ++i) cin >> T[i] >> R[i];
}
void solve() {
  static int rem_before[kK], rem_all[kK];
  static bool pick_after[kK];
  int qq_tm, unk_before, unk_all;
  qq_tm = N;
  for (int i = 1; i < N; ++i)
    if (R[i] == 1) {
      qq_tm = i;
      break;
    }
  copy(&A[1], &A[K + 1], &rem_before[1]);
  copy(&A[1], &A[K + 1], &rem_all[1]);
  fill(&pick_after[1], &pick_after[K + 1], false);
  unk_before = unk_all = 0;
  for (int i = 1; i < N; ++i) {
    if (i >= qq_tm) pick_after[T[i]] = true;
    if (T[i] != 0) {
      --rem_all[T[i]];
      if (i < qq_tm) --rem_before[T[i]];
    } else {
      ++unk_all;
      if (i < qq_tm) ++unk_before;
    }
  }
  string res(K, 'N');
  int min_remove = unk_before;
  for (int i = 1; i <= K; ++i)
    if (!pick_after[i] && rem_before[i] <= unk_before)
      res[i - 1] = 'Y', min_remove = min(min_remove, rem_before[i]);
  for (int i = 1; i <= K; ++i)
    if (rem_all[i] <= unk_all - min_remove) res[i - 1] = 'Y';
  cout << res << "\n";
}
