#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <map>
#include <time.h>
#include <string>
#include <algorithm>

using namespace std;

#define For(i,n) for(i=0;i<(n);i++)
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define ll long long int

const int INF=2e9;
const int mod=1e9+7;
const ll LONGINF=4e9;
const double eps=1e-9;

void solve(){
    int m,n,a[100100],j,unk=0,b,t,i,mini=INF,p[100100],q[100100];
    bool g=false;
    vector<bool> stt(100100,true);
    vector<char> st;
    vector<int> psb;
    scanf("%d%d",&m,&n);
    st.assign(n+1,'N');
    a[0]=INF;
    For(i,n){
        scanf("%d",&a[i+1]);
    }
    For(i,m-1){
    scanf("%d%d",&p[i],&q[i]);
    if(q[i]==1) g=true;
    if(g) stt[p[i]]=false;
    }
    g=true;
    For(i,m-1){
        if(g&&(q[i]==1)){
            For(j,n+1){
            printf("%d\n",(int)stt[j]);
                if((unk>=a[j])&&stt[j]){
                printf("%d\n",(int)stt[j]);
                    if(j!=p[i]) psb.pb(j);
                    mini=min(a[j],mini);
                }
            }
            g=false;
        }
        if(p[i]==0){
            unk++;
        }
        a[p[i]]--;
    }
    printf("%d\n",mini);
    if(g){
        mini=0;
    }
    for(i=n;i>0;i--){
        if(!psb.empty()&&psb.back()==i){
            st[i]='Y';
            psb.pop_back();
        }
        if(a[i]<=unk-mini){
            st[i]='Y';
        }
    }
    FOR(i,1,n+1){
        printf("%c",st[i]);
    }
    printf("\n");
}

int main(){
#pragma comment(linker,"/STACK:268435456")
#ifdef HOME
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#else
    if(0){
        freopen("expedition.in","rt",stdin);
        freopen("expedition.out","wt",stdout);
    }
#endif
    int n,i;
    ll a;
    char c[300];
    string s;
    scanf("%d",&n);
    For(i,n){
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <map>
#include <time.h>
#include <string>
#include <algorithm>

using namespace std;

#define For(i,n) for(i=0;i<(n);i++)
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define ll long long int

const int INF=2e9;
const int mod=1e9+7;
const ll LONGINF=4e9;
const double eps=1e-9;

void solve(){
    int m,n,a[100100],j,unk=0,b,t,i,mini=INF,p[100100],q[100100];
    bool g=false;
    vector<bool> stt(100100,true);
    vector<char> st;
    vector<int> psb;
    scanf("%d%d",&m,&n);
    st.assign(n+1,'N');
    a[0]=INF;
    For(i,n){
        scanf("%d",&a[i+1]);
    }
    For(i,m-1){
    scanf("%d%d",&p[i],&q[i]);
    if(q[i]==1) g=true;
    if(g) stt[p[i]]=false;
    }
    g=true;
    For(i,m-1){
        if(g&&(q[i]==1)){
            For(j,n+1){
                if((unk>=a[j])&&stt[j]){
                    if(j!=p[i]) psb.pb(j);
                    mini=min(a[j],mini);
                }
            }
            g=false;
        }
        if(p[i]==0){
            unk++;
        }
        a[p[i]]--;
    }
    if(g){
        mini=0;
    }
    for(i=n;i>0;i--){
        if(!psb.empty()&&psb.back()==i){
            st[i]='Y';
            psb.pop_back();
        }
        if(a[i]<=unk-mini){
            st[i]='Y';
        }
    }
    FOR(i,1,n+1){
        printf("%c",st[i]);
    }
    printf("\n");
}

int main(){
#pragma comment(linker,"/STACK:268435456")
#ifdef HOME
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#else
    if(0){
        freopen("expedition.in","rt",stdin);
        freopen("expedition.out","wt",stdout);
    }
#endif
    int n,i;
    ll a;
    char c[300];
    string s;
    scanf("%d",&n);
    For(i,n){
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <map>
#include <time.h>
#include <string>
#include <algorithm>

using namespace std;

#define For(i,n) for(i=0;i<(n);i++)
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define ll long long int

const int INF=2e9;
const int mod=1e9+7;
const ll LONGINF=4e9;
const double eps=1e-9;

void solve(){
    int m,n,a[100100],j,unk=0,b,t,i,mini=INF;
    bool g=true;
    vector<char> st;
    vector<int> psb;
    scanf("%d%d",&m,&n);
    st.assign(n+1,'N');
    a[0]=INF;
    For(i,n){
        scanf("%d",&a[i+1]);
    }
    For(i,m-1){
        scanf("%d%d",&b,&t);
        if(g&&(t==1)){
            For(j,n+1){
                if(unk>=a[j]){
                    if(j!=b) psb.pb(j);
                    mini=min(a[j],mini);
                }
            }
            g=false;
        }
        if(b==0){
            unk++;
        }
        a[b]--;
    }
    if(g){
        mini=0;
    }
    for(i=n;i>0;i--){
        if(!psb.empty()&&psb.back()==i){
            st[i]='Y';
            psb.pop_back();
        }
        if(a[i]<=unk-mini){
            st[i]='Y';
        }
    }
    FOR(i,1,n+1){
        printf("%c",st[i]);
    }
    printf("\n");
}

int main(){
#pragma comment(linker,"/STACK:268435456")
#ifdef HOME
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#else
    if(0){
        freopen("expedition.in","rt",stdin);
        freopen("expedition.out","wt",stdout);
    }
#endif
    int n,i;
    ll a;
    char c[300];
    string s;
    scanf("%d",&n);
    For(i,n){
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <vector>
#include <cstdlib>
#include <map>
#include <time.h>
#include <string>
#include <algorithm>

using namespace std;

#define For(i,n) for(i=0;i<(n);i++)
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define ll long long int

const int INF=2e9;
const int mod=1e9+7;
const ll LONGINF=4e9;
const double eps=1e-9;

void solve(){
    int m,n,a[100100],j,unk=0,b[100100],t[100100],i,mini=INF;
    bool g=false;
    vector<char> st;
    vector<bool> stt(100100,true);
    vector<int> psb;
    scanf("%d%d",&m,&n);
    st.assign(n+1,'N');
    a[0]=INF;
    For(i,n){
        scanf("%d",&a[i+1]);
    }
    For(i,m-1){
        scanf("%d%d",&b[i],&t[i]);
        if(t[i]==1) g=true;
        if(g) stt[b[i]]=false;
    }
    g=true;
    For(i,m-1){
        if(g&&(t[i]==1)){
            For(j,n+1){
                if(unk>=a[j]&&stt[j]){
                    if(j!=b[i]) psb.pb(j);
                    mini=min(a[j],mini);
                }
            }
            g=false;
        }
        if(b[i]==0){
            unk++;
        }
        a[b[i]]--;
    }
    if(g){
        mini=0;
    }
    for(i=n;i>0;i--){
        if(!psb.empty()&&psb.back()==i){
            st[i]='Y';
            psb.pop_back();
        }
        if(a[i]<=unk-mini){
            st[i]='Y';
        }
    }
    FOR(i,1,n+1){
        printf("%c",st[i]);
    }
    printf("\n");
}

int main(){
#pragma comment(linker,"/STACK:268435456")
#ifdef HOME
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
#else
    if(0){
        freopen("expedition.in","rt",stdin);
        freopen("expedition.out","wt",stdout);
    }
#endif
    int n,i;
    ll a;
    char c[300];
    string s;
    scanf("%d",&n);
    For(i,n){
        solve();
    }

    return 0;
}


#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
using namespace std;
int main()
{
    int t;
    cin >> t;
    vector<vector<char>>result;
    rep(j,0,t)
    {
        int n,m,k;
        bool afternoenjoy = 0;
        cin >> m >> k;
        vector<int>mit(k,0),a(k);
        vector<char>res(k,'N');
        int numberto= 0,numberafter = 0,minn=1000*1000*1000,x,y;
        rep(i,0,k)
            cin >> a[i];
        rep(i,0,m-1)
        {
            cin >> x >> y;
            x--;
            if (y == 1 && !afternoenjoy)
                afternoenjoy = 1;
            if (x >=0)
            {
                a[x]--;
            }else
                if (!afternoenjoy)
                    numberto++;else
                    numberafter++;
            if (afternoenjoy && x >=0)
                mit[x]=1;
        }
        rep(i,0,a.size())
        {
            if (!mit[i] && numberto >= a[i])
            {
                minn = min(minn,a[i]);
                res[i] = 'Y';
            }
        }
        numberafter += numberto - minn;
        rep(i,0,a.size())
        {
            if (a[i] <= numberafter)
                res[i] = 'Y';
        }
        result.push_back(res);
    }
    rep(i,0,result.size())
    {
        rep(j,0,result[i].size())
            cout << result[i][j];
        cout << endl;
    }
    return 0;
}


#include<cstdio>
#include<vector>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
#include<iterator>
#include<set>
#define rep(i,m,n) for(int i = (m); i < (n); i++)
#define repd(i,m,n) for(int i=(m); i > (n); i--)
using namespace std;
int main()
{
    int t;
    cin >> t;
    vector<vector<char>>result;
    rep(j,0,t)
    {
        int n,m,k;
        bool afternoenjoy = 0;
        cin >> m >> k;
        vector<int>mit(k,0),a(k);
        vector<char>res(k,'N');
        int numberto= 0,numberafter = 0,minn=1000000000,x,y;
        rep(i,0,k)
            cin >> a[i];
        rep(i,0,m-1)
        {
            cin >> x >> y;
            x--;
            if (y == 1 && !afternoenjoy)
                afternoenjoy = 1;
            if (x >=0)
            {
                a[x]--;
            }else
                if (!afternoenjoy)
                    numberto++;else
                    numberafter++;
            if (afternoenjoy && x >=0)
                mit[x]=1;
        }
        rep(i,0,a.size())
        {
            if (!mit[i] && numberto >= a[i])
            {
                minn = min(minn,a[i]);
                res[i] = 'Y';
            }
        }
        numberafter += numberto - minn;
        rep(i,0,a.size())
            if (mit[i] && a[i] <= numberafter)
                res[i] = 'Y';
        result.push_back(res);
    }
    rep(i,0,result.size())
    {
        rep(j,0,result[i].size())
            cout << result[i][j];
        cout << endl;
    }
    return 0;
}


#pragma comment(linker, "/STACK:134217728")

#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long LL;

int T, n, m;

int a[1 << 17], cnt[1 << 17];
int t[1 << 17], r[1 << 17];
int res[1 << 17];

int main()
{
	scanf("%d", &T);
	while (T --> 0)
	{
		scanf("%d%d", &n, &m);
		n--;
		for(int i = 0; i < m; ++i)
			scanf("%d", &a[i]);
		vector<pair<int, int> > S;
		for(int i = 0; i < n; ++i)
		{
			scanf("%d%d", &t[i], &r[i]);
			t[i]--;
			if (t[i] != -1)
			{
				a[t[i]]--;
				cnt[t[i]]++;
			}
		}
		for(int i = 0; i < m; ++i)
			res[i] = 0;
		for(int i = 0; i < m; ++i)
			if (cnt[i] == 0)
				S.push_back(make_pair(a[i], i));
		int free = 0;
		int ok = 0;
		for(int i = 0; i < n; ++i)
		{
			if (r[i] == 1 && !ok)
			{
				pair<int, int> p = *min_element(S.begin(), S.end());
				for(int j = 0; j < S.size(); ++j)
					res[S[j].second] = S[j].first <= free;
				ok = 1;
				free -= p.first;
			}
			if (t[i] != -1)
			{
				cnt[t[i]]--;
				if (cnt[t[i]] == 0)
					S.push_back(make_pair(a[t[i]], t[i]));
			}
			else
				free++;
		}
		for(int i = 0; i < m; ++i)
		{
			if (res[i])
			{
				printf("Y");
				continue;
			}
			if (free >= a[i])
				printf("Y");
			else
				printf("N");
		}
		printf("\n");
	}
	return 0;
}


#pragma comment(linker, "/STACK:134217728")

#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long LL;

int T, n, m;

int a[1 << 17], cnt[1 << 17];
int t[1 << 17], r[1 << 17];

void ASSERT(bool x)
{
	if (!x)
		++*(char*)0;
}

int main()
{
	scanf("%d", &T);
	while (T --> 0)
	{
		scanf("%d%d", &n, &m);
		n--;
		for(int i = 0; i < m; ++i)
			scanf("%d", &a[i]);
		set<pair<int, int> > S;
		for(int i = 0; i < n; ++i)
		{
			scanf("%d%d", &t[i], &r[i]);
			t[i]--;
			if (t[i] != -1)
			{
				a[t[i]]--;
				cnt[t[i]]++;
			}
		}
		for(int i = 0; i < m; ++i)
			if (cnt[i] == 0)
				S.insert(make_pair(a[i], i));
		int free = 0;
		int id = -1;
		for(int i = 0; i < n; ++i)
		{
			if (r[i] == 1 && id == -1)
			{
				ASSERT(!S.empty());
				free -= S.begin()->first;
				id = S.begin()->second;
				ASSERT(free >= 0);
			}
			if (t[i] != -1)
			{
				cnt[t[i]]--;
				if (cnt[t[i]] == 0)
					S.insert(make_pair(a[t[i]], t[i]));
			}
			else
				free++;
		}
		for(int i = 0; i < m; ++i)
		{
			if (i == id)
			{
				printf("Y");
				continue;
			}
			if (free >= a[i])
				printf("Y");
			else
				printf("N");
		}
		printf("\n");
	}
	return 0;
}


#pragma comment(linker, "/STACK:134217728")

#include <cstdio>
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

typedef long long LL;

int T, n, m;

int a[1 << 17];
int t[1 << 17], r[1 << 17];

void ASSERT(bool x)
{
	if (!x)
		++*(char*)0;
}

int main()
{
	scanf("%d", &T);
	while (T --> 0)
	{
		scanf("%d%d", &n, &m);
		n--;
		for(int i = 0; i < m; ++i)
			scanf("%d", &a[i]);
		map<int, int> M;
		set<pair<int, int> > S;
		for(int i = 0; i < n; ++i)
		{
			scanf("%d%d", &t[i], &r[i]);
			t[i]--;
			if (t[i] != -1)
			{
				a[t[i]]--;
				M[t[i]]++;
			}
		}
		for(int i = 0; i < m; ++i)
			if (M[a[i]] == 0)
				S.insert(make_pair(a[i], i));
		int free = 0;
		int id = -1;
		for(int i = 0; i < n; ++i)
		{
			if (r[i] == 1 && id == -1)
			{
				ASSERT(!S.empty());
				free -= S.begin()->first;
				id = S.begin()->second;
				ASSERT(free >= 0);
			}
			if (t[i] != -1)
			{
				M[t[i]]--;
				if (M[t[i]] == 0)
					S.insert(make_pair(a[t[i]], t[i]));
			}
			else
				free++;
		}
		for(int i = 0; i < m; ++i)
		{
			if (i == id)
			{
				printf("Y");
				continue;
			}
			if (free >= a[i])
				printf("Y");
			else
				printf("N");
		}
		printf("\n");
	}
	return 0;
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#include <functional>
#include <time.h>
#include <cmath>
#include <deque>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define double long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define piii pair<int, pair<int, int> >
#define plll pair<ll, pair<ll, ll> >
#pragma comment(linker, "/STACK:36777216")

ll EPS = 1000000007;
double PI = 3.14159265358979323846;
const int MAXN = 1000010;

ll abss(ll h)
{
	return max(h, -h);
}

double fabss(double h)
{
	return max(h, -h);
}

ll ceill(ll x, ll y)
{
	if (x % y != 0)
	{
		return (x / y) + 1;
	}
	return x / y;
}

string itos(ll num)
{
	string str = "";
	while (num != 0)
	{
		str += ((num % 10) + '0');
		num /= 10;
	}
	reverse(str.begin(), str.end());
	return str;
}

ll n, m, k, r, t;

int a[MAXN];
pii b[MAXN];
int c[MAXN];

map <int, int> ma;

int index = 0;

int getMin(int index, int count)
{
	int y = EPS;
	int w = 0;
	for (int i = 1; i <= k; i++)
	{
		if (ma[a[i]] < index && a[i] < y)
		{
			y = a[i];
			w = i;
		}
		if (ma[a[i]] < index && a[i] <= count)
		{
			a[i] = 0;
		}
	}
	a[w] = 0;
	return y;
}

int main()
{
	//freopen("INPUT.txt", "r", stdin);
	//freopen("OUTPUT.txt", "w", stdout);
	scanf("%d", &t);
	for (int q = 0; q < t; q++)
	{
		scanf("%d %d", &m, &k);
		for (int i = 1; i <= k; i++)
		{
			scanf("%d", &a[i]);
		//c[i] = a[i];
		}
	//sort(c, c + k);
		for (int i = 1; i < m; i++)
		{
			scanf("%d %d", &b[i].first, &b[i].second);
			if (b[i].first > 0)
			{
				ma[b[i].first] = i;
			}
		}
		int count = 0;
		int c = 0;
		for (int i = 1; i < m; i++)
		{
			if (b[i].second == 1 && c == 0)
			{
			//a[b[i].first]--;
				count -= getMin(i, count);
				c = 1;
				a[b[i].first]--;
				if (b[i].first == 0)
				{
					count++;
				}
				continue;
			}
			if (b[i].first == 0)
			{
				count++;
				continue;
			}
			a[b[i].first]--;
			if (a[b[i].first] == 0)
			{
				c = 1;
			}
		}
		for (int i = 1; i <= k; i++)
		{
			if (a[i] - count <= 0)
			{
				printf("Y");
			}
			else
			{
				printf("N");
			}
		}
		printf("\n");
		ma.clear();
		for (int i = 0; i <= k; i++)
		{
			a[i] = 0;
		}
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#include <functional>
#include <time.h>
#include <cmath>
#include <deque>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define double long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define piii pair<int, pair<int, int> >
#define plll pair<ll, pair<ll, ll> >
#pragma comment(linker, "/STACK:36777216")

ll EPS = 1000000007;
double PI = 3.14159265358979323846;
const int MAXN = 1000010;

ll abss(ll h)
{
	return max(h, -h);
}

double fabss(double h)
{
	return max(h, -h);
}

ll ceill(ll x, ll y)
{
	if (x % y != 0)
	{
		return (x / y) + 1;
	}
	return x / y;
}

string itos(ll num)
{
	string str = "";
	while (num != 0)
	{
		str += ((num % 10) + '0');
		num /= 10;
	}
	reverse(str.begin(), str.end());
	return str;
}

ll n, m, k, r, t;

int a[MAXN];
pii b[MAXN];
int c[MAXN];

int ma[MAXN];

int index = 0;

int getMin(int index, int count)
{
	int y = EPS;
	int w = 0;
	for (int i = 1; i <= k; i++)
	{
		if (ma[i] < index && a[i] < y)
		{
			y = a[i];
			w = i;
		}
		if (ma[i] < index && a[i] <= count)
		{
			a[i] = 0;
		}
	}
	a[w] = 0;
	return y;
}

int main()
{
	//freopen("INPUT.txt", "r", stdin);
	//freopen("OUTPUT.txt", "w", stdout);
	scanf("%d", &t);
	for (int q = 0; q < t; q++)
	{
		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].first, &b[i].second);
			if (b[i].first > 0)
			{
				ma[b[i].first] = i;
			}
		}
		int count = 0;
		int c = 0;
		for (int i = 1; i < m; i++)
		{
			if (b[i].second == 1 && c == 0)
			{
			//a[b[i].first]--;
				count -= getMin(i, count);
				c = 1;
				a[b[i].first]--;
				if (b[i].first == 0)
				{
					count++;
				}
				continue;
			}
			if (b[i].first == 0)
			{
				count++;
				continue;
			}
			a[b[i].first]--;
			if (a[b[i].first] == 0)
			{
				c = 1;
			}
		}
		for (int i = 1; i <= k; i++)
		{
			if (a[i] - count <= 0)
			{
				printf("Y");
			}
			else
			{
				printf("N");
			}
		}
		printf("\n");
		for (int i = 0; i <= k; i++)
		{
			a[i] = 0;
			ma[i] = 0;
		}
		for (int i = 0; i <= m; i++)
		{
			b[i].first = 0;
			b[i].second = 0;
			ma[i] = 0;
		}
	}
}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iostream>
#include <functional>
#include <time.h>
#include <cmath>
#include <deque>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define double long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define piii pair<int, pair<int, int> >
#define plll pair<ll, pair<ll, ll> >
#pragma comment(linker, "/STACK:36777216")

ll EPS = 1000000007;
double PI = 3.14159265358979323846;
const int MAXN = 1000010;

ll abss(ll h)
{
	return max(h, -h);
}

double fabss(double h)
{
	return max(h, -h);
}

ll ceill(ll x, ll y)
{
	if (x % y != 0)
	{
		return (x / y) + 1;
	}
	return x / y;
}

string itos(ll num)
{
	string str = "";
	while (num != 0)
	{
		str += ((num % 10) + '0');
		num /= 10;
	}
	reverse(str.begin(), str.end());
	return str;
}

ll n, m, k, r, t;

int a[MAXN];
pii b[MAXN];
int c[MAXN];

map <int, int> ma;

int index = 0;

int getMin(int index, int count)
{
	int y = EPS;
	int w = 0;
	for (int i = 1; i <= k; i++)
	{
		if (ma[a[i]] < index && a[i] < y)
		{
			y = a[i];
			w = i;
		}
		if (ma[a[i]] < index && a[i] <= count)
		{
			a[i] = 0;
		}
	}
	a[w] = 0;
	return y;
}

int main()
{
	//freopen("INPUT.txt", "r", stdin);
	//freopen("OUTPUT.txt", "w", stdout);
	scanf("%d", &t);
	for (int q = 0; q < t; q++)
	{
		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].first, &b[i].second);
			if (b[i].first > 0)
			{
				ma[b[i].first] = i;
			}
		}
		int count = 0;
		int c = 0;
		for (int i = 1; i < m; i++)
		{
			if (b[i].second == 1 && c == 0)
			{
			//a[b[i].first]--;
				count -= getMin(i, count);
				c = 1;
				a[b[i].first]--;
				if (b[i].first == 0)
				{
					count++;
				}
				continue;
			}
			if (b[i].first == 0)
			{
				count++;
				continue;
			}
			a[b[i].first]--;
			if (a[b[i].first] == 0)
			{
				c = 1;
			}
		}
		for (int i = 1; i <= k; i++)
		{
			if (a[i] - count <= 0)
			{
				printf("Y");
			}
			else
			{
				printf("N");
			}
		}
		printf("\n");
		ma.clear();
		for (int i = 0; i <= k; i++)
		{
			a[i] = 0;
		}
		for (int i = 0; i <= m; i++)
		{
			b[i].first = 0;
			b[i].second = 0;
		}
	}
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <list>
using namespace std;

bool comp(int i1, int i2)
{
    return i1 > i2;
}

int main()
{
    /*string s1,s2;
    cin>>s1>>s2;
    int k = s1.length();
    string s3 = s1;
    for (int i = 0; i < k; ++i)
    {
        if (s3[i] < 'z')
            ++s3[i];
        if (s3.compare(s2) < 0)
            break;
        else
        {
            string s4 = s3;
            s4.erase(i + 1, k - i - 1);
            s4.append(k - i - 1, 'a');
            if (s4.compare(s2) < 0)
            {
                s3 = s4;
                break;
            }
        }
    }
    if (s3.compare(s1) <=0 || s2.compare(s3) <= 0)
        cout<<"No such string\n";
    else cout<<s3<<endl;*/
    /*string s, t;
    int n;
    cin>>n;
    cin>>s;
    cin>>t;
    vector<int> diff(n);
    vector<bool> hem(n);
    for (int i = 0; i < n; ++i)
    {
        if (s[i]!=t[i])
        {
            hem[i] = true;
        }
    }
    for (int i = 0; i < n; ++i)
    {
        if (hem[i] == true)

    }*/

    int t;
    cin>>t;
    for (int j = 0; j < t; ++j)
    {
        int m,k;
        cin>>m>>k;
        vector<int> food(k);
        vector<bool> ment(k);
        for (int i = 0; i < k; ++i)
            cin>>food[i];
        int zeros = 0;
        int bord = 0;
        bool rej = false;
        for (int i = 0; i < m - 1; ++i)
        {
            int tj, rj;
            cin>>tj>>rj;
            if (rj > 0 && !rej)
            {
                rej = true;
                bord = zeros;
            }
            if (tj > 0)
            {
                --food[tj - 1];
                if (rej) ment[tj - 1] = true;
            }
            else ++zeros;
        }
        int min = bord + 1;
        string res(k, 'N');
        for (int i = 0; i < k; ++i)
        {
            if (ment[i]) continue;
            if (food[i] > bord) continue;
            if (food[i] < min) min = food[i];
            res[i] = 'Y';
        }
        if (min <= bord) zeros -= min;
        for (int i = 0; i < k; ++i)
        {
            if (food[i] > zeros) continue;
            res[i] = 'Y';
        }
        cout<<res<<endl;
    }
    return 0;
}


#include <functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstdio>
#include <complex>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <set>
#include <map>
#include <unordered_set>
using namespace std;

#define int64 long long
#define mp make_pair
const int inf = 1e9;

#ifdef _DEBUG
    const int N = 1010;
#else
    const int N = 1000010;
#endif

const int MOD = 1e9+7;

int t, m, k, a[N], b[N], r[N], ans[N];
bool used[N];
string res;

int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    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;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 10001;

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    vector<int> a(n);
    forn(i, n)
        scanf("%d", &a[i]);

    int cnt = 0;
    bool ok = false;

    forn(i, m - 1) {
        int t, r;
        scanf("%d%d", &t, &r);

        if (!ok && r == 1) {
            int mn = INF;
            forn(j, n) {
                if (a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = true;
            cnt -= mn;
        }

        if (t)
            a[t - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        printf((a[i] <= cnt ? "Y" : "N"));
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 10001;

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    vector<int> a(n), t(m), r(m);
    forn(i, n)
        scanf("%d", &a[i]);

    forn(i, m)
        scanf("%d%d", &t[i], &r[i]);

    int cnt = 0;
    bool ok = false;

    forn(i, m - 1) {
        if (!ok && r[i] == 1) {
            vector<bool> used(n);

            for(int j = i; j < m - 1; j++) {
                if (r[i] != 0) {
                    used[r[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = true;
            cnt -= mn;
        }

        if (t[i])
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        printf((a[i] <= cnt ? "Y" : "N"));
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 100010;

int a[N], t[N], r[N];
bool used[N];

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    forn(i, n)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d%d", &t[i], &r[i]);

    int cnt = 0;
    bool ok = false;

    forn(i, m - 1) {
        if (!ok && r[i] == 1) {
            memset(used, false, sizeof(used));

            for(int j = i; j < m - 1; j++) {
                if (t[i] != 0) {
                    used[t[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = true;
            cnt -= mn;
        }

        if (t[i] != 0)
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        if (a[i] <= cnt)
            printf("Y");
        else
            printf("N");
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 100010;

int a[N], t[N], r[N];
bool used[N];

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    forn(i, n)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d%d", &t[i], &r[i]);

    int cnt = 0;
    bool ok = false;

    forn(i, m - 1) {
        if (!ok && r[i] == 1) {
            memset(used, false, sizeof(used));

            for(int j = i; j < m - 1; j++) {
                if (t[i] != 0) {
                    used[t[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = true;
            cnt -= mn;
        }

        if (t[i])
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        printf((a[i] <= cnt ? "Y" : "N"));
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 10001;

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    vector<int> a(n), t(m), r(m);
    forn(i, n)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d%d", &t[i], &r[i]);

    int cnt = 0;
    bool ok = false;

    forn(i, m - 1) {
        if (!ok && r[i] == 1) {
            vector<bool> used(n);

            for(int j = i; j < m - 1; j++) {
                if (t[i] != 0) {
                    used[t[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = true;
            cnt -= mn;
        }

        if (t[i])
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        printf((a[i] <= cnt ? "Y" : "N"));
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 100010;

int a[N], t[N], r[N];
bool used[N];

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    forn(i, n)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d%d", &t[i], &r[i]);

    int cnt = 0;
    bool ok = true;

    forn(i, m - 1) {
        if (ok && r[i] == 1) {
            memset(used, false, sizeof(used));

            for(int j = i; j < m - 1; j++) {
                if (t[i] != 0) {
                    used[t[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = false;
            cnt -= mn;
        }

        if (t[i] != 0)
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        if (a[i] <= cnt)
            printf("Y");
        else
            printf("N");
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 100010;

int a[N], t[N], r[N];
bool used[N];

void solve() {
    int m, n;
    scanf("\n%d %d\n", &m, &n);

    forn(i, n)
        scanf("%d ", &a[i]);

    forn(i, m - 1)
        scanf("%d %d\n", &t[i], &r[i]);

    int cnt = 0;
    bool ok = false;

    forn(i, m - 1) {
        if (!ok && r[i] == 1) {
            memset(used, false, sizeof(used));

            for(int j = i; j < m - 1; j++) {
                if (t[i] != 0) {
                    used[t[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = true;
            cnt -= mn;
        }

        if (t[i] != 0)
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        if (a[i] <= cnt)
            printf("Y");
        else
            printf("N");
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d\n", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 100010;

int a[N], t[N], r[N];
bool used[N];

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    forn(i, n)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d%d", &t[i], &r[i]);

    int cnt = 0;
    bool ok = true;

    forn(i, m - 1) {
        if (ok && r[i] == 1) {
            memset(used, false, sizeof(used));

            for(int j = i; j < m - 1; j++) {
                if (t[j] != 0) {
                    used[t[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = false;
            cnt -= mn;
        }

        if (t[i] != 0)
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        if (a[i] <= cnt)
            printf("Y");
        else
            printf("N");
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#include <stdio.h>
#include <stack>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <set>
#include <memory.h>
#include <vector>
#include <bitset>
#include <map>
#include <queue>
#include <iomanip>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); i++)
#define mp(a, b) make_pair(a, b)
#define sqr(x) ( (x) * (x) )
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> pii;

const int INF = 1e9;
const ll INF64 = 1e18;
const int MOD = 1000000007;
const int N = 100010;

int a[N], t[N], r[N];
bool used[N];

void solve() {
    int m, n;
    scanf("%d%d", &m, &n);

    forn(i, n)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d%d", &t[i], &r[i]);

    int cnt = 0;
    bool ok = false;

    forn(i, m - 1) {
        if (!ok && r[i] == 1) {
            for(int j = i; j < m - 1; j++) {
                if (t[i] != 0) {
                    used[t[j] - 1] = true;
                }
            }

            int mn = INF;
            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    mn = min(mn, a[j]);
            }

            forn(j, n) {
                if (!used[j] && a[j] <= cnt)
                    a[j] -= mn;
            }

            ok = true;
            cnt -= mn;
        }

        if (t[i])
            a[t[i] - 1]--;
        else
            cnt++;
    }

    forn(i, n) {
        printf((a[i] <= cnt ? "Y" : "N"));
    }

    printf("\n");
}

int main() {
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int T;
    scanf("%d", &T);

    forn(t, T) {
        solve();
    }

    return 0;
}


#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <time.h>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define _(a,b) memset( (a), b, sizeof( a ) )
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__); fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << x << endl;}
#define dbgv(v) {cerr << #v << " = {"; for (typeof(v.begin()) it = v.begin(); it != v.end(); it ++) cerr << *it << ", "; cerr << "}"; cerr << endl;}
#else
#define dbg(...) { }
#define dbgx(x) { }
#define dbgv(v) { }
#endif

typedef unsigned long long ull;
typedef long long lint;
typedef pair < int , int > pii;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;
const lint LINF = 1000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

const int nmax = 100005;

int a[nmax], n, k, T, t[nmax], r[nmax], ans[nmax];
bool any[nmax];

bool read()
{
	scanf("%d%d",&n,&k);
	for (int i = 0; i < k; i ++)
	{
		scanf("%d",&a[i]);
		ans[i] = 0;
		any[i] = 0;
	}
	for (int i = 0; i < n - 1; i ++)
	{
		scanf("%d%d", &t[i], &r[i]);
		t[i]--;
	}
	return false;
}

void solve()
{
	int lft = 0, isFirst = 1;
	for (int i = 0; i < n - 1; i ++)
	{
		if (r[i] == 1)
		{
			if (isFirst)
			{
				int mn_id = -1;
				for (int j = i; j < n - 1; j ++)
				{
					if (r[i] == 0 && t[i] >= 0)
						any[t[i]] = 1;
				}
				for (int j = 0; j < k; j ++)
				{
					if (any[j])
						continue;
					if (mn_id == -1 ||
						a[mn_id] > a[j])
					{
						mn_id = j;
					}
				}
				lft -= a[mn_id];
				a[mn_id] = 0;
			}
			isFirst = 0;

			assert(lft >= 0);
		}

		if (t[i] >= 0)
			a[t[i]]--;
		else
			lft++;
	}

	for (int i = 0; i < k; i ++)
	{
		if (a[i] <= lft)
			ans[i] = 1;
	}

	for (int i = 0; i < k; i ++)
	{
		printf("%c", ans[i] ? 'Y' : 'N');
	}
	printf("\n");
}

int main()
{
	prepare();
	scanf("%d",&T);
	for (int i = 0; i < T; i ++)
	{
		read();
		solve();
	}
	return 0;
}


#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <time.h>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define _(a,b) memset( (a), b, sizeof( a ) )
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__); fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << x << endl;}
#define dbgv(v) {cerr << #v << " = {"; for (typeof(v.begin()) it = v.begin(); it != v.end(); it ++) cerr << *it << ", "; cerr << "}"; cerr << endl;}
#else
#define dbg(...) { }
#define dbgx(x) { }
#define dbgv(v) { }
#endif

typedef unsigned long long ull;
typedef long long lint;
typedef pair < int , int > pii;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;
const lint LINF = 1000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

const int nmax = 100005;

int a[nmax], n, k, T, t[nmax], r[nmax], ans[nmax];
bool any[nmax];

bool read()
{
	scanf("%d%d",&n,&k);
	for (int i = 0; i < k; i ++)
	{
		scanf("%d",&a[i]);
		ans[i] = 0;
		any[i] = 0;
	}
	for (int i = 0; i < n - 1; i ++)
	{
		scanf("%d%d", &t[i], &r[i]);
		t[i]--;
	}
	return false;
}

void solve()
{
	int lft = 0, isFirst = 1;
	for (int i = 0; i < n - 1; i ++)
	{
		if (r[i] == 1)
		{
			if (isFirst)
			{
				int mn_id = -1;
				for (int j = i; j < n - 1; j ++)
				{
					if (t[j] >= 0)
						any[t[j]] = 1;
				}
				for (int j = 0; j < k; j ++)
				{
					if (any[j])
						continue;
					if (mn_id == -1 ||
						a[mn_id] > a[j])
					{
						mn_id = j;
					}
				}
				lft -= a[mn_id];
				a[mn_id] = 0;
			}
			isFirst = 0;

			assert(lft >= 0);
		}

		if (t[i] >= 0)
			a[t[i]]--;
		else
			lft++;
	}

	for (int i = 0; i < k; i ++)
	{
		if (a[i] <= lft)
			ans[i] = 1;
	}

	for (int i = 0; i < k; i ++)
	{
		printf("%c", ans[i] ? 'Y' : 'N');
	}
	printf("\n");
}

int main()
{
	prepare();
	scanf("%d",&T);
	for (int i = 0; i < T; i ++)
	{
		read();
		solve();
	}
	return 0;
}


#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <time.h>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define _(a,b) memset( (a), b, sizeof( a ) )
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__); fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << x << endl;}
#define dbgv(v) {cerr << #v << " = {"; for (typeof(v.begin()) it = v.begin(); it != v.end(); it ++) cerr << *it << ", "; cerr << "}"; cerr << endl;}
#else
#define dbg(...) { }
#define dbgx(x) { }
#define dbgv(v) { }
#endif

typedef unsigned long long ull;
typedef long long lint;
typedef pair < int , int > pii;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;
const lint LINF = 1000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

const int nmax = 100005;

int a[nmax], n, k, T, t[nmax], r[nmax], ans[nmax];
bool any[nmax];

bool read()
{
	scanf("%d%d",&n,&k);
	for (int i = 0; i < k; i ++)
	{
		scanf("%d",&a[i]);
		ans[i] = 0;
		any[i] = 0;
	}
	for (int i = 0; i < n - 1; i ++)
	{
		scanf("%d%d", &t[i], &r[i]);
		t[i]--;
	}
	return false;
}

void solve()
{
	int lft = 0, isFirst = 1, lft2 = 0;
	for (int i = 0; i < n - 1; i ++)
	{
		if (r[i] == 1)
		{
			if (isFirst)
			{
				int mn_id = -1;
				for (int j = i; j < n - 1; j ++)
				{
					if (t[j] >= 0)
						any[t[j]] = 1;
				}
				for (int j = 0; j < k; j ++)
				{
					if (any[j])
						continue;
					if (mn_id == -1 ||
						a[mn_id] > a[j])
					{
						mn_id = j;
					}
				}
				lft2 = lft;
			}
			isFirst = 0;

			assert(lft >= 0);
		}

		if (t[i] >= 0)
			a[t[i]]--;
		else
			lft++;
	}

	for (int i = 0; i < k; i ++)
	{
		if (a[i] <= lft - lft2 || a[i] <= lft2)
			ans[i] = 1;
	}

	for (int i = 0; i < k; i ++)
	{
		printf("%c", ans[i] ? 'Y' : 'N');
	}
	printf("\n");
}

int main()
{
	prepare();
	scanf("%d",&T);
	for (int i = 0; i < T; i ++)
	{
		read();
		solve();
	}
	return 0;
}


#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <time.h>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define _(a,b) memset( (a), b, sizeof( a ) )
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__); fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << x << endl;}
#define dbgv(v) {cerr << #v << " = {"; for (typeof(v.begin()) it = v.begin(); it != v.end(); it ++) cerr << *it << ", "; cerr << "}"; cerr << endl;}
#else
#define dbg(...) { }
#define dbgx(x) { }
#define dbgv(v) { }
#endif

typedef unsigned long long ull;
typedef long long lint;
typedef pair < int , int > pii;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;
const lint LINF = 1000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

const int nmax = 100005;

int a[nmax], n, k, T, t[nmax], r[nmax], ans[nmax];
bool any[nmax];

bool read()
{
	scanf("%d%d",&n,&k);
	for (int i = 0; i < k; i ++)
	{
		scanf("%d",&a[i]);
		ans[i] = 0;
		any[i] = 0;
	}
	for (int i = 0; i < n - 1; i ++)
	{
		scanf("%d%d", &t[i], &r[i]);
		t[i]--;
	}
	return false;
}

void solve()
{
	int lft = 0, isFirst = 1;
	for (int i = 0; i < n - 1; i ++)
	{
		if (r[i] == 1)
		{
			if (isFirst)
			{
				int mn_id = -1;
				for (int j = i; j < n - 1; j ++)
				{
					if (t[j] >= 0)
						any[t[j]] = 1;
				}
				for (int j = 0; j < k; j ++)
				{
					if (any[j])
						continue;

					if (lft >= a[j])
					{
						ans[j] = 1;
					}

					if (mn_id == -1 ||
						a[mn_id] > a[j])
					{
						mn_id = j;
					}
				}

				lft -= a[mn_id];
				a[mn_id] = 0;
			}
			isFirst = 0;

			assert(lft >= 0);
		}

		if (t[i] >= 0)
			a[t[i]]--;
		else
			lft++;
	}

	for (int i = 0; i < k; i ++)
	{
		if (a[i] <= lft)
			ans[i] = 1;
	}

	for (int i = 0; i < k; i ++)
	{
		printf("%c", ans[i] ? 'Y' : 'N');
	}
	printf("\n");
}

int main()
{
	prepare();
	scanf("%d",&T);
	for (int i = 0; i < T; i ++)
	{
		read();
		solve();
	}
	return 0;
}


#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <time.h>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define _(a,b) memset( (a), b, sizeof( a ) )
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__); fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << x << endl;}
#define dbgv(v) {cerr << #v << " = {"; for (typeof(v.begin()) it = v.begin(); it != v.end(); it ++) cerr << *it << ", "; cerr << "}"; cerr << endl;}
#else
#define dbg(...) { }
#define dbgx(x) { }
#define dbgv(v) { }
#endif

typedef unsigned long long ull;
typedef long long lint;
typedef pair < int , int > pii;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;
const lint LINF = 1000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

const int nmax = 100005;

int a[nmax], n, k, T, t[nmax], r[nmax], ans[nmax];
bool any[nmax];

bool read()
{
	scanf("%d%d",&n,&k);
	for (int i = 0; i < k; i ++)
	{
		scanf("%d",&a[i]);
		ans[i] = 0;
		any[i] = 0;
	}
	for (int i = 0; i < n - 1; i ++)
	{
		scanf("%d%d", &t[i], &r[i]);
		t[i]--;
	}
	return false;
}

void solve()
{
	int lft = 0, isFirst = 1, lft2 = 0, mn = 0;
	for (int i = 0; i < n - 1; i ++)
	{
		if (r[i] == 1)
		{
			if (isFirst)
			{
				int mn_id = -1;
				for (int j = i; j < n - 1; j ++)
				{
					if (t[j] >= 0)
						any[t[j]] = 1;
				}
				for (int j = 0; j < k; j ++)
				{
					if (any[j])
						continue;
					if (mn_id == -1 ||
						a[mn_id] > a[j])
					{
						mn_id = j;
					}
				}
				mn = a[mn_id];
				lft2 = lft;
			}
			isFirst = 0;

			assert(lft >= 0);
		}

		if (t[i] >= 0)
			a[t[i]]--;
		else
			lft++;
	}

	for (int i = 0; i < k; i ++)
	{
		if (a[i] <= lft - mn || a[i] <= lft2)
			ans[i] = 1;
	}

	for (int i = 0; i < k; i ++)
	{
		printf("%c", ans[i] ? 'Y' : 'N');
	}
	printf("\n");
}

int main()
{
	prepare();
	scanf("%d",&T);
	for (int i = 0; i < T; i ++)
	{
		read();
		solve();
	}
	return 0;
}


#pragma comment(linker,"/STACK:64000000")
#define _CRT_SECURE_NO_DEPRECATE

#include <iostream>
#include <sstream>
#include <stdio.h>
#include <memory.h>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <time.h>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define _(a,b) memset( (a), b, sizeof( a ) )
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#ifdef _DEBUG
#define dbg(...) {fprintf(stderr, __VA_ARGS__); fflush(stderr);}
#define dbgx(x) {cerr << #x << " = " << x << endl;}
#define dbgv(v) {cerr << #v << " = {"; for (typeof(v.begin()) it = v.begin(); it != v.end(); it ++) cerr << *it << ", "; cerr << "}"; cerr << endl;}
#else
#define dbg(...) { }
#define dbgx(x) { }
#define dbgv(v) { }
#endif

typedef unsigned long long ull;
typedef long long lint;
typedef pair < int , int > pii;
typedef long double ld;

const int INF = 1000 * 1000 * 1000;
const lint LINF = 1000000000000000000LL;
const double eps = 1e-9;

void prepare()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
}

const int nmax = 100005;

int a[nmax], n, k, T, t[nmax], r[nmax], ans[nmax];
bool any[nmax];

bool read()
{
	scanf("%d%d",&n,&k);
	for (int i = 0; i < k; i ++)
	{
		scanf("%d",&a[i]);
		ans[i] = 0;
		any[i] = 0;
	}
	for (int i = 0; i < n - 1; i ++)
	{
		scanf("%d%d", &t[i], &r[i]);
		t[i]--;
	}
	return false;
}

void solve()
{
	int lft = 0, isFirst = 1;
	for (int i = 0; i < n - 1; i ++)
	{
		if (r[i] == 1)
		{
			if (isFirst)
			{
				int mn_id = -1;
				for (int j = i; j < n - 1; j ++)
				{
					if (r[j] == 0 && t[j] >= 0)
						any[t[j]] = 1;
				}
				for (int j = 0; j < k; j ++)
				{
					if (any[j])
						continue;
					if (mn_id == -1 ||
						a[mn_id] > a[j])
					{
						mn_id = j;
					}
				}
				lft -= a[mn_id];
				a[mn_id] = 0;
			}
			isFirst = 0;

			assert(lft >= 0);
		}

		if (t[i] >= 0)
			a[t[i]]--;
		else
			lft++;
	}

	for (int i = 0; i < k; i ++)
	{
		if (a[i] <= lft)
			ans[i] = 1;
	}

	for (int i = 0; i < k; i ++)
	{
		printf("%c", ans[i] ? 'Y' : 'N');
	}
	printf("\n");
}

int main()
{
	prepare();
	scanf("%d",&T);
	for (int i = 0; i < T; i ++)
	{
		read();
		solve();
	}
	return 0;
}


#pragma warning (disable : 4996)
#pragma comment(linker, "/STACK:36777216")

#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <ios>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <sstream>
#include <map>
#include <memory.h>
#include <stdio.h>
#include <cassert>
#include <string.h>
#include <deque>

#define forn(i , n) for (int i = 0; i < n; ++i)
#define down(i, n) for (int i = n - 1; i >= 0; --i)

using namespace std;

typedef unsigned long long int u64;
typedef long long int i64;
typedef vector<int> vint;
typedef vector<i64> vi64;
typedef pair<int, int> pint;
typedef pair<i64, i64> pi64;

#define FILE_NAME "file"
#define CONTEST "seq"
#define M_PI 3.14159265358979323846

double sqr(double a)
{
    return a * a;
}

const i64 inf = 100000000000000000LL;

#define MOD 10000000000007

struct Eda
{
    int col;
    int willGood;
    int ended;
    Eda()
    {
        ended = 0;
        willGood = 0;
        col = 0;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);

#ifdef FILE_INPUT
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif
    int T;
    cin >> T;
    forn(t, T)
    {
        int m, k;
        cin >> m >> k;
        vector<Eda> arr(k);
        forn(i, k)
        {
            cin >> arr[i].col;
        }
        int dontKnow = 0;
        vector<pint> rq(m - 1);
        forn(i, m - 1)
        {
            cin >> rq[i].first >> rq[i].second;
            rq[i].first--; // <0 bad
            if (rq[i].first >= 0)
            {
                arr[rq[i].first].willGood++;
            }
        }
        map<int, set<int>> mp; // ключ сколько осталось, в мапе только если willGood = 0;

        forn(i, k)
        {
            if (arr[i].willGood == 0)
            {
                mp[arr[i].col].insert(i);
            }
        }

        int wasBad = 0;

        forn(i, m - 1)
        {
            int a = rq[i].second;
            int minim = 1000000000;
            if (a == 1)
            {
                if (!wasBad) // какое-то закончилось, теперь все неудачные запросы о нем
                {
                    while (mp.size() && mp.begin()->first <= dontKnow)
                    {
                        minim = min(minim, mp.begin()->first);
                        set<int> & st = mp.begin()->second;
                        for (auto j = st.begin(); j != st.end(); ++j)
                        {
                            int index = *j;
                            arr[index].ended = 1;
                        }
                        mp.erase(mp.begin());
                    }

                    dontKnow -= minim;
                    wasBad = 1;
                }

            }

            int w = rq[i].first;
            if (w >= 0)
            {
                arr[w].col--;
                if (arr[w].col == 0)
                {
                    arr[w].ended = 1;
                }
                arr[w].willGood--;
                if (arr[w].willGood == 0)
                {
                    mp[arr[w].col].insert(w);
                }

            }
            else
            {
                dontKnow++;
            }

        }

        forn(i, k)
        {
            if (arr[i].ended || arr[i].col <= dontKnow)
            {
                cout << "Y";
            }
            else
            {
                cout << "N";
            }
        }
        cout << "\n";

    }
    return 0;
}


#pragma warning (disable : 4996)
#pragma comment(linker, "/STACK:36777216")

#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <assert.h>
#include <stack>
#include <algorithm>
#include <ios>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <queue>
#include <set>
#include <functional>
#include <cmath>
#include <sstream>
#include <map>
#include <memory.h>
#include <stdio.h>
#include <cassert>
#include <string.h>
#include <deque>

#define forn(i , n) for (int i = 0; i < n; ++i)
#define down(i, n) for (int i = n - 1; i >= 0; --i)

using namespace std;

typedef unsigned long long int u64;
typedef long long int i64;
typedef vector<int> vint;
typedef vector<i64> vi64;
typedef pair<int, int> pint;
typedef pair<i64, i64> pi64;

#define FILE_NAME "file"
#define CONTEST "seq"
#define M_PI 3.14159265358979323846

double sqr(double a)
{
    return a * a;
}

const i64 inf = 100000000000000000LL;

#define MOD 10000000000007

struct Eda
{
    int col;
    int willGood;
    int ended;
    Eda()
    {
        ended = 0;
        willGood = 0;
        col = 0;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);

#ifdef FILE_INPUT
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif
    int T;
    cin >> T;
    forn(t, T)
    {
        int m, k;
        cin >> m >> k;
        vector<Eda> arr(k);
        forn(i, k)
        {
            cin >> arr[i].col;
        }
        int dontKnow = 0;
        vector<pint> rq(m - 1);
        forn(i, m - 1)
        {
            cin >> rq[i].first >> rq[i].second;
            rq[i].first--; // <0 bad
            if (rq[i].first >= 0)
            {
                arr[rq[i].first].willGood++;
            }
        }
        map<int, set<int>> mp; // ключ сколько осталось, в мапе только если willGood = 0;

        forn(i, k)
        {
            if (arr[i].willGood == 0)
            {
                mp[arr[i].col].insert(i);
            }
        }

        int wasBad = 0;

        forn(i, m - 1)
        {
            int w = rq[i].first;
            if (w >= 0)
            {
                arr[w].col--;
                if (arr[w].col == 0)
                {
                    arr[w].ended = 1;
                }
                arr[w].willGood--;
                if (arr[w].willGood == 0)
                {
                    mp[arr[w].col].insert(w);
                }

            }
            else
            {
                dontKnow++;
            }

            int a  = rq[i].second;
            int minim = 1000000000;
            if (a == 1)
            {

                while (mp.size() && mp.begin()->first <= dontKnow)
                {
                    minim = min(minim, mp.begin()->first);
                    set<int> & st = mp.begin()->second;
                    for (auto j = st.begin(); j != st.end(); ++j)
                    {
                        int index = *j;
                        arr[index].ended = 1;
                    }
                    mp.erase(mp.begin());
                }
                if (!wasBad) // какое-то закончилось, теперь все неудачные запросы о нем
                {
                    dontKnow -= minim;
                    wasBad = 1;
                }

            }
            else
            {

            }

        }

        forn(i, k)
        {
            if (arr[i].ended || arr[i].col <= dontKnow)
            {
                cout << "Y";
            }
            else
            {
                cout << "N";
            }
        }
        cout << "\n";

    }
    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define ft first
#define sc second
#define endl '\n'
#define sqr(x) ((x) * (x))

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = (int)(1e9);
const li INF64 = (li)(INF) * (li)(INF);
const ld eps = 1e-9;
const ld PI = ld(3.1415926535897932384626433832795);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//#define TASK_NAME "name"

const int N = 1e5 + 555;

int m, k;
int a[N];
bool del[N];
pt q[N], res[N];

inline bool read(){
    if(scanf("%d %d", &m, &k) != 2)
        return false;

    forn(i, k)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d %d", &q[i].ft, &q[i].sc);
    return true;
}

inline void solve(){
    int odd = 0;
    bool badcnt = false;
    set< pt > alive;
    forn(i, k)
        res[i] = mp(-1, i), del[i] = false;

    forn(i, m - 1)
        if(q[i].ft > 0)
            res[q[i].ft - 1].ft = i;

    sort(res, res + k);

    int uk = 0;

    while(uk < k && res[uk].ft < 0){
        alive.insert(mp(a[res[uk].sc], res[uk].sc));
        uk++;
    }

    forn(i, m - 1){
        if(q[i].sc != 0){
            set< pt >::iterator it = alive.begin();
            int mn = 0;
            while(it != alive.end() && it->ft <= odd){
                if(!badcnt)
                    mn = it->ft;
                badcnt = true;
                del[it->sc]  = true;
                alive.erase(it);
                it = alive.begin();
            }
            odd -= mn;
        }
        if(q[i].ft > 0){
            a[q[i].ft - 1]--;
        }
        else
            odd++;

        while(uk < k && res[uk].ft <= i){
            alive.insert(mp(a[res[uk].sc], res[uk].sc));
            uk++;
        }
    }

    { //final
        set< pt >::iterator it = alive.begin();
        int mn = 0;
        while(it != alive.end() && it->ft <= odd){
            if(!badcnt)
                mn = it->ft;
            del[it->sc]  = true;
            badcnt = true;
            alive.erase(it);
            it = alive.begin();
        }
        odd -= mn;
    }

    forn(i, k)
        if(del[i])
            printf("Y");
        else
            printf("N");
    printf("\n");
}

int main(){
#ifdef TASK_NAME
    freopen(TASK_NAME".in", "r", stdin);
    freopen(TASK_NAME".out", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    srand(int(time(NULL)));

    int t;
    scanf("%d", &t);
    forn(tt, t){
        assert(read());
        solve();
    }

    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define ft first
#define sc second
#define endl '\n'
#define sqr(x) ((x) * (x))

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = (int)(1e9);
const li INF64 = (li)(INF) * (li)(INF);
const ld eps = 1e-9;
const ld PI = ld(3.1415926535897932384626433832795);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//#define TASK_NAME "name"

const int N = 1e5 + 555;

int m, k;
int a[N];
bool del[N];
pt q[N], res[N];

inline bool read(){
    if(scanf("%d %d", &m, &k) != 2)
        return false;

    forn(i, k)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d %d", &q[i].ft, &q[i].sc);
    return true;
}

inline void solve(){
    int odd = 0;
    bool badcnt = false;
    set< pt > alive;
    forn(i, k)
        res[i] = mp(-1, -1), del[i] = false;

    forn(i, k){
        if(q[i].ft > 0)
            res[q[i].ft - 1].ft = i;
        res[i].sc = i;
    }

    sort(res, res + k);

    int uk = 0;
    forn(i, m - 1){
        while(uk < k && res[uk].ft < i){
            if(a[res[uk].sc] <= odd)
                del[res[uk].sc] = true;
            if(!del[res[uk].sc])
                alive.insert(mp(a[res[uk].sc], res[uk].sc));
            uk++;
        }
        if(q[i].sc != 0){
            set< pt >::iterator it = alive.begin();
            int mn = INF;
            while(it != alive.end() && it->ft <= odd){
                if(!badcnt)
                    mn = it->ft;
                badcnt = true;
                del[it->sc]  = true;
                alive.erase(it);
                it = alive.begin();
            }
        }
        if(q[i].ft > 0){
            a[q[i].ft - 1]--;
            if(a[q[i].ft - 1] <= 0){
                del[q[i].ft - 1] = true;
                badcnt = true;
            }
        }
        else
            odd++;
    }

    { //final
        set< pt >::iterator it = alive.begin();
        int mn = INF;
        while(it != alive.end() && it->ft <= odd){
            if(!badcnt)
                mn = it->ft;
            del[it->sc]  = true;
            badcnt = true;
            alive.erase(it);
            it = alive.begin();
        }
        odd -= mn;
    }

    forn(i, k)
        if(del[i])
            printf("Y");
        else
            printf("N");
    printf("\n");
}

int main(){
#ifdef TASK_NAME
    freopen(TASK_NAME".in", "r", stdin);
    freopen(TASK_NAME".out", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    srand(int(time(NULL)));

    int t;
    scanf("%d", &t);
    forn(tt, t){
        assert(read());
        solve();
    }

    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define ft first
#define sc second
#define endl '\n'
#define sqr(x) ((x) * (x))

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = (int)(1e9);
const li INF64 = (li)(INF) * (li)(INF);
const ld eps = 1e-9;
const ld PI = ld(3.1415926535897932384626433832795);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//#define TASK_NAME "name"

const int N = 1e5 + 555;

int m, k;
int a[N];
bool del[N];
pt q[N], res[N];

inline bool read(){
    if(scanf("%d %d", &m, &k) != 2)
        return false;

    forn(i, k)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d %d", &q[i].ft, &q[i].sc);
    return true;
}

inline void solve(){
    int odd = 0;
    bool badcnt = false;
    set< pt > alive;
    forn(i, k)
        res[i] = mp(-1, -1), del[i] = false;

    forn(i, k){
        if(q[i].ft > 0)
            res[q[i].ft - 1].ft = i;
        res[i].sc = i;
    }

    sort(res, res + k);

    int uk = 0;
    forn(i, m - 1){
        while(uk < k && res[uk].ft < i){
            if(a[res[uk].sc] <= odd)
                del[res[uk].sc] = true;
            if(!del[res[uk].sc])
                alive.insert(mp(a[res[uk].sc], res[uk].sc));
            uk++;
        }
        if(q[i].sc != 0){
            set< pt >::iterator it = alive.begin();
            int mn = INF;
            while(it != alive.end() && it->ft <= odd){
                if(!badcnt)
                    mn = it->ft;
                badcnt = true;
                del[it->sc]  = true;
                alive.erase(it);
                it = alive.begin();
            }
        }
        if(q[i].ft > 0)
            a[q[i].ft - 1]--;
        else
            odd++;
    }

    { //final
        set< pt >::iterator it = alive.begin();
        int mn = INF;
        while(it != alive.end() && it->ft <= odd){
            if(!badcnt)
                mn = it->ft;
            del[it->sc]  = true;
            badcnt = true;
            alive.erase(it);
            it = alive.begin();
        }
        odd -= mn;
    }

    forn(i, k)
        if(del[i])
            printf("Y");
        else
            printf("N");
    printf("\n");
}

int main(){
#ifdef TASK_NAME
    freopen(TASK_NAME".in", "r", stdin);
    freopen(TASK_NAME".out", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    srand(int(time(NULL)));

    int t;
    scanf("%d", &t);
    forn(tt, t){
        assert(read());
        solve();
    }

    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define ft first
#define sc second
#define endl '\n'
#define sqr(x) ((x) * (x))

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = (int)(1e9);
const li INF64 = (li)(INF) * (li)(INF);
const ld eps = 1e-9;
const ld PI = ld(3.1415926535897932384626433832795);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//#define TASK_NAME "name"

const int N = 1e5 + 555;

int m, k;
int a[N];
bool del[N];
pt q[N], res[N];

inline bool read(){
    if(scanf("%d %d", &m, &k) != 2)
        return false;

    forn(i, k)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d %d", &q[i].ft, &q[i].sc);
    return true;
}

inline void solve(){
    int odd = 0;
    bool badcnt = false;
    set< pt > alive;
    forn(i, k)
        res[i] = mp(-1, -1), del[i] = false;

    forn(i, m - 1)
        if(q[i].ft > 0)
            res[q[i].ft - 1].ft = i;

    forn(i, k)
        res[i].sc = i;

    sort(res, res + k);

    int uk = 0;
    forn(i, m - 1){
        while(uk < k && res[uk].ft < i){
            if(a[res[uk].sc] <= odd)
                del[res[uk].sc] = true;
            if(!del[res[uk].sc])
                alive.insert(mp(a[res[uk].sc], res[uk].sc));
            uk++;
        }
        if(q[i].sc != 0){
            set< pt >::iterator it = alive.begin();
            int mn = 0;
            while(it != alive.end() && it->ft <= odd){
                if(!badcnt)
                    mn = it->ft;
                badcnt = true;
                del[it->sc]  = true;
                alive.erase(it);
                it = alive.begin();
            }
            odd -= mn;
        }
        if(q[i].ft > 0){
            a[q[i].ft - 1]--;
            if(a[q[i].ft - 1] <= 0){
                del[q[i].ft - 1] = true;
                badcnt = true;
            }
        }
        else
            odd++;
    }

    { //final
        set< pt >::iterator it = alive.begin();
        int mn = 0;
        while(it != alive.end() && it->ft <= odd){
            if(!badcnt)
                mn = it->ft;
            del[it->sc]  = true;
            badcnt = true;
            alive.erase(it);
            it = alive.begin();
        }
        odd -= mn;
    }

    forn(i, k)
        if(del[i])
            printf("Y");
        else
            printf("N");
    printf("\n");
}

int main(){
#ifdef TASK_NAME
    freopen(TASK_NAME".in", "r", stdin);
    freopen(TASK_NAME".out", "w", stdout);
#else
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif

    srand(int(time(NULL)));

    int t;
    scanf("%d", &t);
    forn(tt, t){
        assert(read());
        solve();
    }

    return 0;
}


#include <iostream>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define ft first
#define sc second
#define endl '\n'
#define sqr(x) ((x) * (x))

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

const int INF = (int)(1e9);
const li INF64 = (li)(INF) * (li)(INF);
const ld eps = 1e-9;
const ld PI = ld(3.1415926535897932384626433832795);

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

//#define TASK_NAME "name"

const int N = 1e5 + 555;

int m, k;
int a[N];
bool del[N];
pt q[N], res[N];

inline bool read(){
    if(scanf("%d %d", &m, &k) != 2)
        return false;

    forn(i, k)
        scanf("%d", &a[i]);

    forn(i, m - 1)
        scanf("%d %d", &q[i].ft, &q[i].sc);
    return true;
}

inline void solve(){
    int odd = 0;
    bool badcnt = false;
    set< pt > alive;
    forn(i, k)
        res[i] = mp(-1, -1), del[i] = false;

    forn(i, k){
        if(q[i].ft > 0)
            res[q[i].ft - 1].ft = i;
        res[i].sc = i;
    }

    sort(res, res + k);

    int uk = 0;
    forn(i, m - 1){
        while(uk < k && res[uk].ft < i){
            if(a[res[uk].sc] <= odd)
                del[res[uk].sc] = true;
            if(!del[res[uk].sc])
                alive.insert(mp(a[res[uk].sc], res[uk].sc));
            uk++;
        }
        if(q[i].sc != 0){
            set< pt >::iterator it = alive.begin();
            int mn = INF;
            while(it != alive.end() && it->ft <= odd){
                if(!badcnt)
                    mn = it->ft;
                badcnt = true;
                del[it->sc]  = true;
                alive.erase(it);
                it = alive.begin();
            }
        }
        if(q[i].ft > 0)
            a[q[i].ft - 1]--;
        else
            odd++;
    }

    { //final
        set< pt >::iterator it = alive.begin();
        int mn = INF;
        while(it != alive.end() && it->ft <= odd){
            if(!badcnt)
                mn = it->ft;
            del[it->sc]  = true;
            badcnt = true;
            alive.erase(it);
            it = alive.begin();
        }
        odd -= mn;
    }

    forn(i, k)
        if(del[i])
            printf("Y");
        else
            printf("N");
    printf("\n");
}

int main(){
#ifdef TASK_NAME
    freopen(TASK_NAME".in", "r", stdin);
    freopen(TASK_NAME".out", "w", stdout);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    srand(int(time(NULL)));

    int t;
    scanf("%d", &t);
    forn(tt, t){
        assert(read());
        solve();
    }

    return 0;
}


#pragma comment(linker, "/STACK:60000000")
#define _CRT_SECURE_NO_WARNINGS

#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define next NEXTHUI
#define prev PREVHUI
#define y1 Y1HUI

typedef long long int64;
typedef pair <int, int> pii;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const int64 inf64 = ((int64)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
const string task = "";

template <class T> T sqr (T x) {return x * x;}

int n, m;
int a[100500];
int last[100500];
char ans[100500];
int x[100500], y[100500];

void solve() {
    scanf("%d%d", &n, &m);
    forn(i, m) {
        scanf("%d", &a[i]);
        ans[i] = 'N';
        last[i] = -1;
    }
    forn(i, n - 1) {
        scanf("%d%d", &x[i], &y[i]);
        x[i]--;
        if (x[i] >= 0) last[x[i]] = i;
    }

    int s = 0;
    bool first = 1;
    forn(i, n - 1) {
        if (first && y[i] == 1) {
            first = 0;
            int mn = inf;
            forn(j, m)
                if (a[j] <= s && last[j] < i) {
                    ans[j] = 'Y';
                    mn = min(mn, a[j]);
                }
            s -= mn;
        }
        if (x[i] != -1) {
            a[x[i]]--;
        } else {
            s++;
        }

    }
    cerr << s << endl;
    forn(i, m)
        if (a[i] <= s) ans[i] = 'Y';

    forn(i, m) {
        printf("%c", ans[i]);
    }
    printf("\n");
}

int main () {
//  freopen ((task + ".in").data(), "r", stdin);
//  freopen ((task + ".out").data(), "w", stdout);
//  freopen ("input.txt", "r", stdin);
//  freopen ("output.txt", "w", stdout);
    int tt;
    scanf("%d", &tt);
    forn(ii, tt) solve();
    return 0;
}


#pragma comment(linker, "/STACK:60000000")
#define _CRT_SECURE_NO_WARNINGS

#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define next NEXTHUI
#define prev PREVHUI
#define y1 Y1HUI

typedef long long int64;
typedef pair <int, int> pii;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const int64 inf64 = ((int64)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
const string task = "";

template <class T> T sqr (T x) {return x * x;}

int n, m;
int a[100500];
int last[100500];
char ans[100500];
int x[100500], y[100500];

void solve() {
    scanf("%d%d", &n, &m);
    forn(i, m) {
        scanf("%d", &a[i]);
        ans[i] = 'N';
        last[i] = -1;
    }
    forn(i, n - 1) {
        scanf("%d%d", &x[i], &y[i]);
        x[i]--;
        if (x[i] >= 0) last[x[i]] = i;
    }

    int s = 0;
    bool first = 1;
    forn(i, n - 1) {
        if (y[i] == 0) continue;
        if (first) {
            first = 0;
            int mn = inf;
            forn(j, m)
                if (a[j] <= s && last[j] < i) {
                    ans[j] = 'Y';
                    mn = min(mn, a[j]);
                }
            s -= mn;
        }
        if (x[i] != -1) {
            a[x[i]]--;
        } else {
            s++;
        }

    }
    cerr << s << endl;
    forn(i, m)
        if (a[i] <= s) ans[i] = 'Y';

    forn(i, m) {
        printf("%c", ans[i]);
    }
    printf("\n");
}

int main () {
//  freopen ((task + ".in").data(), "r", stdin);
//  freopen ((task + ".out").data(), "w", stdout);
//  freopen ("input.txt", "r", stdin);
//  freopen ("output.txt", "w", stdout);
    int tt;
    scanf("%d", &tt);
    forn(ii, tt) solve();
    return 0;
}


#pragma comment(linker, "/STACK:60000000")
#define _CRT_SECURE_NO_WARNINGS

#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define next NEXTHUI
#define prev PREVHUI
#define y1 Y1HUI

typedef long long int64;
typedef pair <int, int> pii;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const int64 inf64 = ((int64)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
const string task = "";

template <class T> T sqr (T x) {return x * x;}

int n, m;
int a[100500];
char ans[100500];

void solve() {
	scanf("%d%d", &n, &m);
	forn(i, m) {
		scanf("%d", &a[i]);
		ans[i] = 'N';
	}

	int s = 0;
	bool first = 1;
	forn(i, n - 1) {
		int x, y;
		scanf("%d%d", &x, &y);
		x--;
		if (x != -1) {
			a[x]--;
		} else {
			s++;
		}
		if (y == 0) continue;
		if (first) {
			first = 0;
			int mn = a[0];
			forn(j, m)
				if (a[j] <= s) {
					ans[j] = 'Y';
					mn = min(mn, a[j]);
				}
			s -= mn;
		}
	}
	forn(i, m)
		if (a[i] <= s) ans[i] = 'Y';

	forn(i, m) {
		printf("%c", ans[i]);
	}
	printf("\n");
}

int main () {
//	freopen ((task + ".in").data(), "r", stdin);
//	freopen ((task + ".out").data(), "w", stdout);
//	freopen ("input.txt", "r", stdin);
//	freopen ("output.txt", "w", stdout);
	int tt;
	scanf("%d", &tt);
	forn(ii, tt) solve();
	return 0;
}


#pragma comment(linker, "/STACK:60000000")
#define _CRT_SECURE_NO_WARNINGS

#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define next NEXTHUI
#define prev PREVHUI
#define y1 Y1HUI

typedef long long int64;
typedef pair <int, int> pii;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const int64 inf64 = ((int64)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
const string task = "";

template <class T> T sqr (T x) {return x * x;}

int n, m;
int a[100500];
int last[100500];
char ans[100500];
int x[100500], y[100500];

void solve() {
	scanf("%d%d", &n, &m);
	forn(i, m) {
		scanf("%d", &a[i]);
		ans[i] = 'N';
		last[i] = -1;
	}
	forn(i, n - 1) {
		scanf("%d%d", &x[i], &y[i]);
		x[i]--;
		if (x[i] >= 0) last[x[i]] = i;
	}

	int s = 0;
	bool first = 1;
	forn(i, n - 1) {
		if (x[i] != -1) {
			a[x[i]]--;
		} else {
			s++;
		}
		if (y[i] == 0) continue;
		if (first) {
			first = 0;
			int mn = a[0];
			forn(j, m)
				if (a[j] <= s && last[j] <= i) {
					ans[j] = 'Y';
					mn = min(mn, a[j]);
				}
			s -= mn;
		}
	}
	forn(i, m)
		if (a[i] <= s) ans[i] = 'Y';

	forn(i, m) {
		printf("%c", ans[i]);
	}
	printf("\n");
}

int main () {
//	freopen ((task + ".in").data(), "r", stdin);
//	freopen ((task + ".out").data(), "w", stdout);
//	freopen ("input.txt", "r", stdin);
//	freopen ("output.txt", "w", stdout);
	int tt;
	scanf("%d", &tt);
	forn(ii, tt) solve();
	return 0;
}


#pragma comment(linker, "/STACK:60000000")
#define _CRT_SECURE_NO_WARNINGS

#include <bitset>
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <sstream>
#include <iomanip>
#include <complex>
#include <queue>
#include <functional>

using namespace std;

#define forn(i, n) for(int i = 0; i < (int)(n); i++)
#define ford(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define last(a) int(a.size() - 1)
#define all(a) a.begin(), a.end()
#define seta(a,x) memset (a, x, sizeof (a))
#define I (int)
#define next NEXTHUI
#define prev PREVHUI
#define y1 Y1HUI

typedef long long int64;
typedef pair <int, int> pii;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const int64 inf64 = ((int64)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
const string task = "";

template <class T> T sqr (T x) {return x * x;}

int n, m;
int a[100500];
int last[100500];
char ans[100500];
int x[100500], y[100500];

void solve() {
	scanf("%d%d", &n, &m);
	forn(i, m) {
		scanf("%d", &a[i]);
		ans[i] = 'N';
		last[i] = -1;
	}
	forn(i, n - 1) {
		scanf("%d%d", &x[i], &y[i]);
		x[i]--;
		if (x[i] >= 0) last[x[i]] = i;
	}

	int s = 0;
	bool first = 1;
	forn(i, n - 1) {
		if (x[i] != -1) {
			a[x[i]]--;
		} else {
			s++;
		}
		if (y[i] == 0) continue;
		if (first) {
			first = 0;
			int mn = inf;
			forn(j, m)
				if (a[j] <= s && last[j] < i) {
					ans[j] = 'Y';
					mn = min(mn, a[j]);
				}
			s -= mn;
			cerr << mn << endl;
		}
	}
	cerr << s << endl;
	forn(i, m)
		if (a[i] <= s) ans[i] = 'Y';

	forn(i, m) {
		printf("%c", ans[i]);
	}
	printf("\n");
}

int main () {
//	freopen ((task + ".in").data(), "r", stdin);
//	freopen ((task + ".out").data(), "w", stdout);
//	freopen ("input.txt", "r", stdin);
//	freopen ("output.txt", "w", stdout);
	int tt;
	scanf("%d", &tt);
	forn(ii, tt) solve();
	return 0;
}


#include<cstdio>
#include<iostream>
long long const MAX=100005;
using namespace std;
bool isused[MAX];
long meals[MAX];
long food[MAX];
long lastuse[MAX];
bool angry[MAX];
int main()
{
    long t,m,k;
    long unknown,first,mi;
    scanf("%ld",&t);
    int temp;
    for(long g=0;g<t;++g)
        {
        first=-1;
        unknown=0;
        mi=0;
        scanf("%ld%ld",&m,&k);
        for(long i=1;i<=k;++i)
            {
                scanf("%ld",&meals[i]);
                lastuse[i]=-1;
                isused[i]=false;
            }
        for(long i=0;i<m-1;++i)
            {
                scanf("%ld%d",&food[i],&temp);
                if(temp==1){
                        angry[i]=true;
                        if(first==-1)first=i;
                        }
                else angry[i]=false;
                if(first==-1){
                    if(food[i]==0)++unknown;
                    else --meals[food[i]];
                }
            //    cout<<"i=="<<i<<" un=="<<unknown<<endl;
                lastuse[food[i]]=i;
            }
        if(first>=0)
            {

            for(int i=1;i<=k;i++)
                {
          //     printf("for i==%ld lastuse[i]==%ld meals[i]==%ld\n",i,lastuse[i],meals[i]);
                if(lastuse[i]<first&&unknown>=meals[i])
                    {
                    isused[i]=true;
                    if(unknown-meals[i]>mi)mi=unknown-meals[i];
                    }
                }
            unknown=mi;
            }
        if(first==-1)first=m;
        for(long i=first;i<m-1;++i)
            {
                if(food[i]!=0)
                    {
                        --meals[food[i]];
                    }
                else ++unknown;
            }
        for(long i=1;i<=k;++i)
            {

                if(unknown>=meals[i])isused[i]=true;
                if(isused[i]==true)printf("Y");
                else printf("N");
               // printf(" for i==%ld lastuse[i]==%ld meals[i]==%ld , unknown is %ld\n",i,lastuse[i],meals[i],unknown);
            }
        printf("\n");
        }
}


#include<stdio.h>
#include <string>
#include<set>
#include<vector>
int a[100010]={0};
char res[100010]={0};
int t[100010]={0};
int r[100010]={0};
using namespace std;
int main()
{
    int tc;
    scanf("%d",&tc);
    for(int i=0;i<tc;i++)
    {
        int m,k;
        scanf("%d%d",&m,&k);
        for(int j=0;j<k;j++)
        {
            scanf("%d",&a[j]);
        }
        int unknown=0;
        int unknownBeforeUpset=0;
        int upset = -1;
        int rdy=0;
        set<int> st;
        for(int j=0;j<m-1;j++)
        {
            scanf("%d%d",&t[j],&r[j]);
            t[j]--;
            if (r[j] == 1 && upset == -1)
                upset = j;
            if (t[j] == -1)
            {
                unknown++;
                if (upset == -1)
                    unknownBeforeUpset++;
            }
            else
                a[t[j]]--;
        }
        string result(k, 'N');
        if(upset==-1)
        {
            for(int j=0;j<k;j++)
            {
                if(a[j]<=unknown)
                {
                    result[j]='Y';
                }
            }
        }
        else
        {
            vector<bool> usedAfter(k, false);
            for (int j = upset; j < m - 1; j++)
                if (t[j] != -1)
                    usedAfter[t[j]] = true;
            int minFirstFinished = -1;
            for(int j=0;j<k;j++)
            {
                if (!usedAfter[j] && unknownBeforeUpset >= a[j])
                {
                    result[j] = 'Y';
                    if (minFirstFinished == -1 || a[minFirstFinished] > a[j])
                        minFirstFinished = j;
                }
            }
            if (minFirstFinished != -1)
            {
                int restUnknown = unknown - a[minFirstFinished];
                for(int j=0;j<k;j++)
                {
                    if (a[j] <= restUnknown)
                        result[j] = 'Y';
                }
            }
        }
        printf("%s\n", result.c_str());
    }
    return 0;
}


#include<stdio.h>
#include <string>
#include<set>
#include<vector>
int a[100010]={0};
char res[100010]={0};
int t[100010]={0};
int r[100010]={0};
using namespace std;
int main()
{
    int tc;
    scanf("%d",&tc);
    for(int i=0;i<tc;i++)
    {
        int m,k;
        scanf("%d%d",&m,&k);
        for(int j=0;j<k;j++)
        {
            scanf("%d",&a[j]);
        }
        int unknown=0;
        int unknownBeforeUpset=0;
        int upset = -1;
        int rdy=0;
        set<int> st;
        for(int j=0;j<m-1;j++)
        {
            scanf("%d%d",&t[j],&r[j]);
            t[j]--;
            if (r[j] == 1 && upset == -1)
                upset = i;
            if (t[j] == -1)
            {
                unknown++;
                if (upset == -1)
                    unknownBeforeUpset++;
            }
            else
                a[t[j]]--;
        }
        string result(k, 'N');
        if(upset==-1)
        {
            for(int j=0;j<k;j++)
            {
                if(a[j]<=unknown)
                {
                    result[j]='Y';
                }
            }
        }
        else
        {
            vector<bool> usedAfter(k, false);
            for (int i = upset; i < m - 1; i++)
                if (t[i] != -1)
                    usedAfter[t[i]] = true;
            int minFirstFinished = -1;
            for(int j=0;j<k;j++)
            {
                if (!usedAfter[j] && unknownBeforeUpset >= a[j])
                {
                    result[j] = 'Y';
                    if (minFirstFinished == -1 || a[minFirstFinished] > a[j])
                        minFirstFinished = j;
                }
            }
            if (minFirstFinished != -1)
            {
                int restUnknown = unknown - a[minFirstFinished];
                for(int j=0;j<k;j++)
                {
                    if (a[j] <= restUnknown)
                        result[j] = 'Y';
                }
            }
        }
        printf("%s\n", result.c_str());
    }
    return 0;
}


#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#define _CRT_NO_DEPRECEATE
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>

#define pb push_back
#define ll long long
#define pll pair<ll, ll>
#define mp make_pair
#define sq(x) ((x)*(x))
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define _MOD 1000000007LL
#define MOD(x) ((x) % (_MOD))
#define NMOD(x) (((x) + 2LL * (_MOD)) % (_MOD))
#define INF (2e9)
#define LINF (1e16)
#define EPS (1e-8)
#define PI (3.1415926535897932384626433832795)
#define y1 asdf_1
#define y0 asdf_2
#define j0 jj0
typedef unsigned long long ull;
typedef long double ldd;

using namespace std;

int m, k;
int a[100010];
int yes[100010];
int timer = 0;

void solve()
{
    timer++;
    cin >> m >> k;
    for (int i = 0; i < k; i++)
        cin >> a[i];
    int t, r;
    int unk = 0;
    bool was_upset = 0;
    for (int i = 0; i < m - 1; i++)
    {
        cin >> t >> r;
        if (r == 1 && was_upset == 0)
        {
            was_upset = 1;
            int mn = -1;
            for (int j = 0; j < k; j++)
                if ((j != t - 1) && (a[j] <= unk))
                {
                    yes[j] = timer;
                    if (mn == -1 || a[j] < mn)
                        mn = a[j];
                }
            unk -= mn;
        }

        if (t == 0)
            unk++;
        else
            a[t - 1]--;
    }
    for (int i = 0; i < k; i++)
    {
        if (yes[i] == timer || a[i] <= unk)
            cout << 'Y';
        else
            cout << 'N';
    }
}

int main()
{
    //freopen("input.txt", "w", stdout); testgen(200000); return 0;

    ios_base::sync_with_stdio(false); cin.tie(0);
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    int ts;
    cin >> ts;
    for (int tt = 0; tt < ts; tt++)
    {
        solve();
        cout << endl;
    }

    return 0;
}