#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define ll long long
#define lll __int128
#define fi first
#define se second
#define e emplace
#define eb emplace_back
#define db double
#define ef emplace_front
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vp vector<pii>
#define vt vector<tup>
#define all(x) x.begin(),x.end()
#define mp make_pair
#define FastI
#define FastO
//#define int ll
bool ST;
static const ll MOD=1e9+7,Phi=998244352,inv2=499122177,Root=3,iRoot=332748118;
static const ll inf=1073741823,Inf=4294967296,INF=1e18;
static const ld eps=1e-9,pi=3.1415926535;
char in[1<<20],*p1=in,*p2=in;
char out[1<<20],*p3=out;
using namespace std;
struct tup
{
int x,y,z;
tup(int X=0,int Y=0,int Z=0)
{x=X,y=Y,z=Z;}
bool operator <(const tup nd)const
{return x<nd.x;}
};
#ifdef FastI
#define getchar() (p1==p2&&(p2=(p1=in)+fread(in,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#endif
#ifdef FastO
#define putchar(x) (p3-out==1<<20?fwrite(out,1,1<<20,stdout),p3=out,0:0,*p3++=x)
#define puts(x) write(x,'\n')
#endif
namespace FastIO
{
template<typename T> inline void write(T x,char ch=' ')
{
if(is_same<char,T>::value)putchar(x);
else
{
if(x<0)x=-x,putchar('-');
static char st[25];
int top=0;
do st[top++]=x%10+'0',x/=10;while(x);
while(top)putchar(st[--top]);
}
ch!='~'?putchar(ch):0;
}
inline void write(const char*x,char ch=' ')
{
for(int i=0;x[i]!='\0';++i)putchar(x[i]);
ch!='~'?putchar(ch):0;
}
inline void read(char&s){do s=getchar();while(s=='\n'||s==' ');}
inline void read(char s[])
{
int len=0;char st;
do st=getchar();while(st=='\n'||st==' ');
s[++len]=st,st=getchar();
while(st!='\n'&&st!=' '&&st!='\r')s[++len]=st,st=getchar();
s[++len]='\0';
}
template<typename T> inline void read(T &s)
{
char ch=getchar();s=0;
while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
bool tf=(ch=='-'&&(ch=getchar()));
while(ch>='0'&&ch<='9')s=(s<<1)+(s<<3)+ch-'0',ch=getchar();
s=tf?-s:s;
}
inline void edl(){putchar('\n');}
template<typename T1,typename T2> inline void read(pair<T1,T2> &s){read(s.fi),read(s.se);}
template<typename T,typename...Args> inline void write(T x,Args...args){write(x,'~'),write(args...);}
template<typename T,typename...Args> inline void read(T&x,Args&...args){read(x),read(args...);}
#ifdef FastO
struct Writer{~Writer(){fwrite(out,1,p3-out,stdout);}}Writ;
#endif
}
using namespace FastIO;
namespace MTool
{
inline int Cadd(int a,int b){return (ll)a+b>=MOD?(ll)a+b-MOD:a+b;}
inline int Cdel(int a,int b){return a-b<0?a-b+MOD:a-b;}
inline int Cmul(int a,int b){return 1ll*a*b%MOD;}
inline int sqr(int a){return 1ll*a*a%MOD;}
inline void Madd(int&a,int b){a=((ll)a+b>=MOD?(ll)a+b-MOD:a+b);}
inline void Mdel(int&a,int b){a=(a-b<0?a-b+MOD:a-b);}
inline void Mmul(int&a,int b){a=1ll*a*b%MOD;}
inline int Cmod(int x){return (x%MOD+MOD)%MOD;}
inline void Mmod(int&x){x=(x%MOD+MOD)%MOD;}
template<typename T> inline bool Mmax(T&a,T b){return a<b?a=b,1:0;}
template<typename T> inline bool Mmin(T&a,T b){return a>b?a=b,1:0;}
template<typename...Args> inline void Madd(int&a,int b,Args...args){Madd(a,b),Madd(a,args...);}
template<typename...Args> inline void Mmul(int&a,int b,Args...args){Mmul(a,b),Mmul(a,args...);}
template<typename...Args> inline void Mdel(int&a,int b,Args...args){Mdel(a,b),Mdel(a,args...);}
template<typename...Args> inline int Cadd(int a,int b,Args...args){return Cadd(Cadd(a,b),args...);}
template<typename...Args> inline int Cmul(int a,int b,Args...args){return Cmul(Cmul(a,b),args...);}
template<typename...Args> inline int Cdel(int a,int b,Args...args){return Cdel(Cdel(a,b),args...);}
template<typename...Args,typename T> inline bool Mmax(T&a,T b,Args...args){return Mmax(a,b)|Mmax(a,args...);}
template<typename...Args,typename T> inline bool Mmin(T&a,T b,Args...args){return Mmin(a,b)|Mmin(a,args...);}
inline int power(int x,int y){int s=1;for(;y;y>>=1,Mmul(x,x))if(y&1)Mmul(s,x);return s;}
}
using namespace MTool;
namespace WrongAnswer_90
{
int n,m,ls[200010],rs[200010],dep[200010],fa[200010];
ll a[200010];
mt19937_64 rnd(time(0));
map<pii,ull> hash;
ull get(ull x,ull y)
{
if(x>y)swap(x,y);
ull val=x*1145141919810100ull+y*123456789012345ull;
// val=val*987654321098765ull;
// val=val*y+123123123123ull;
return val;
}
namespace Segment
{
#define ls(x) t[x].ls
#define rs(x) t[x].rs
struct{int ls,rs,v;ull v0,v1,l,r;}t[20000010];
void update(int x)
{
int Ls=ls(x),Rs=rs(x);
if(!t[ls(x)].l)return t[x]=t[Rs],ls(x)=Ls,rs(x)=Rs,void();
if(!t[rs(x)].l)return t[x]=t[Ls],ls(x)=Ls,rs(x)=Rs,void();
t[x].v=t[ls(x)].v^t[rs(x)].v;
t[x].l=t[ls(x)].l,t[x].r=t[rs(x)].r;
if(t[ls(x)].v&1)
{
t[x].v0=t[ls(x)].v0^t[rs(x)].v1^get(t[ls(x)].r,t[rs(x)].l);
t[x].v1=t[ls(x)].v1^t[rs(x)].v0;
}
else
{
t[x].v0=t[ls(x)].v0^t[rs(x)].v0;
t[x].v1=t[ls(x)].v1^t[rs(x)].v1^get(t[ls(x)].r,t[rs(x)].l);
}
}
int pos[10000010];
int up[20000010];
void build(int p,int l,int r)
{
if(l==r)return pos[l]=p,void();
int mid=(l+r)>>1;
t[p].ls=(l+r);
t[p].rs=t[p].ls^1;
up[ls(p)]=up[rs(p)]=p;
build(ls(p),l,mid);
build(rs(p),mid+1,r);
}
void change(int x,int y)
{
int xx=x;
x=pos[x];
t[x].v+=y;
if(!t[x].v)t[x].v0=t[x].v1=t[x].l=t[x].r=0;
else
{
t[x].v0=(t[x].v&2)?get(xx,xx):0;
t[x].v1=((t[x].v-1)&2)?get(xx,xx):0;
t[x].l=t[x].r=xx;
}
while(x)x=up[x],update(x);
}
#undef ls
#undef rs
}
using namespace Segment;
ll aa[200010];
pair<int,ll> b[200010];
void mian()
{
vector<ll> tmp;
int x;
ll y;
read(n,m);
for(int i=1;i<=n;++i)read(a[i]),dep[i]=1;
for(int i=n+1;i<n*2;++i)
{
read(ls[i],rs[i]);
fa[ls[i]]=fa[rs[i]]=i;
dep[i]=max(dep[ls[i]],dep[rs[i]])+1;
a[i]=a[ls[i]]+a[rs[i]];
}
if(dep[n*2-1]>100)
{
for(int i=1;i<=m;++i)puts("NO");
return;
}
for(int i=1;i<n*2-1;++i)tmp.eb(a[i]);
memcpy(aa,a,sizeof(a));
int tat=0;
for(int i=1;i<m;++i)
{
read(x,y),b[i]=mp(x,y);
y=y-a[x];
for(int i=x;i!=n*2-1;i=fa[i])
a[i]+=y,tmp.eb(a[i]);
}
sort(all(tmp));
tmp.resize(unique(all(tmp))-tmp.begin());
build(1,1,tmp.size());
memcpy(a,aa,sizeof(a));
for(int i=1;i<n*2-1;++i)
{
a[i]=lower_bound(all(tmp),a[i])-tmp.begin()+1;
// cerr<<a[i]<<endl;
change(a[i],1);
}
ull sum=0;
for(int i=n+1;i<n*2;++i)sum^=get(a[ls[i]],a[rs[i]]);
if(t[1].v0==sum)puts("YES");
else puts("NO");
// exit(0);
for(int i=1;i<m;++i)
{
x=b[i].fi,y=b[i].se;
y=y-tmp[a[x]-1];
for(int i=x;i!=n*2-1;i=fa[i])
{
change(a[i],-1);
sum^=get(a[ls[fa[i]]],a[rs[fa[i]]]);
}
for(int i=x;i!=n*2-1;i=fa[i])
{
int pr=tmp[a[i]-1]+y;
a[i]=lower_bound(all(tmp),tmp[a[i]-1]+y)-tmp.begin()+1;
change(a[i],1);
sum^=get(a[ls[fa[i]]],a[rs[fa[i]]]);
}
if(t[1].v0==sum)puts("YES");
else puts("NO");
}
}
inline void Mian()
{
int T=1,C;
// read(T);
while(T--)mian();
}
}
bool ED;
signed main()
{
// ios::sync_with_stdio(0);
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
WrongAnswer_90::Mian();
return 0;
}