#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int maxn=1e6+10;
int b[maxn],c[maxn];
int n,q;
int fa[maxn];
vector<int>v[maxn];
int dfn[maxn];
int cnt;
int mp[maxn];
struct Tree{
int l,r;
pair<int,int>maxx;
}tree[4*maxn];
int maxx[maxn],maxx2[maxn],maxx3[maxn];
int sz[maxn];
void dfs(int id)
{
dfn[id]=++cnt;
mp[cnt]=id;
maxx[id]=b[id];
sz[id]=1;
for(int i:v[id])
{
dfs(i);
sz[id]+=sz[i];
if(maxx[i]>maxx[id])
{
if(maxx[id]!=maxx2[id])
{
maxx3[id]=maxx2[id];
}
maxx2[id]=maxx[id];
maxx[id]=maxx[i];
}
else if(maxx[i]>maxx2[id])
{
maxx3[id]=maxx2[id];
maxx2[id]=maxx[i];
}
else if(maxx[i]>maxx3[id]&&maxx[i]!=maxx2[id])
{
maxx3[id]=maxx[i];
}
if(maxx2[i]>maxx2[id])
{
maxx3[id]=maxx2[id];
maxx2[id]=maxx2[i];
}
else if(maxx2[i]>maxx3[id]&&maxx2[i]!=maxx2[id])
{
maxx3[id]=maxx2[i];
}
if(maxx3[i]>maxx3[id]&&maxx3[i]!=maxx2[id])
{
maxx3[id]=maxx3[i];
}
}
}
pair<int,int>merge(pair<int,int>_a,pair<int,int>_b)
{
if(_b.first>_a.first)
{
_a.second=_a.first;
_a.first=_b.first;
}
else if(_b.first>_a.second&&_b.first!=_a.first)
{
_a.second=_b.first;
}
if(_b.second>_a.second&&_b.second!=_a.first)
{
_a.second=_b.second;
}
return _a;
}
void build(int id,int l,int r)
{
tree[id].l=l;
tree[id].r=r;
if(l==r)
{
tree[id].maxx.first=c[mp[l]];
return;
}
int mid=l+r>>1;
build(id*2,l,mid);
build(id*2+1,mid+1,r);
tree[id].maxx=merge(tree[id*2].maxx,tree[id*2+1].maxx);
}
pair<int,int>ask(int id,int l,int r)
{
if(l>r||tree[id].r<l||tree[id].l>r)
{
return {0,0};
}
if(tree[id].l>=l&&tree[id].r<=r)
{
return tree[id].maxx;
}
return merge(ask(id*2,l,r),ask(id*2+1,l,r));
}
signed main()
{
// freopen("soldier15.in","r",stdin);
// freopen("soldier15.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(int i=2;i<=n;i++)
{
cin>>fa[i];
v[fa[i]].push_back(i);
}
for(int i=1;i<=n;i++)
{
cin>>b[i]>>c[i];
}
dfs(1);
build(1,1,n);
while(q--)
{
int s;
cin>>s;
if(sz[s]==1)
{
cout<<"0\n";
continue;
}
pair<int,int>maxxx=merge(ask(1,1,dfn[s]-1),ask(1,dfn[s]+sz[s],n));
if(maxx3[s]==0)
{
if(maxxx.first==0)
{
cout<<maxx2[s]%maxx[s]<<endl;
}
else if(maxx[s]==maxx2[s]+maxxx.first)
{
cout<<max(maxx2[s],maxx2[s]+maxxx.second)<<endl;
}
else if(maxx[s]>maxx2[s]+maxxx.first)
{
cout<<maxx2[s]+maxxx.first<<endl;
}
else if(maxx[s]<maxx2[s]+maxxx.first)
{
cout<<maxx[s]<<endl;
}
continue;
}
if(maxxx.first==0)
{
if(maxx[s]==maxx2[s])
{
cout<<maxx3[s]<<endl;
}
else
{
cout<<maxx2[s]<<endl;
}
continue;
}
if(maxx[s]==maxx2[s]+maxxx.first)
{
cout<<max(max(maxx2[s],maxx2[s]+maxxx.second),maxx3[s]+maxxx.first)<<endl;
}
else if(maxx[s]>maxx2[s]+maxxx.first)
{
cout<<maxx2[s]+maxxx.first<<endl;
}
else if(maxx[s]<maxx2[s]+maxxx.first)
{
cout<<maxx[s]<<endl;
}
}
return 0;
}
/*
in:
10 3
1
2
3
2
4
6
5
1
4
6 6
4 2
10 6
7 1
1 6
2 2
9 7
5 3
9 6
9 7
3
6
4
out:
10
8
9
*/