// clang-format off
#include<bits/stdc++.h>
#define pb push_back
#define P make_pair
#define fi first
#define se second
#define bit(s,x) (((s)>>(x))&1)
#define pnp(s) __builtin_popcountll(s)
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
mt19937 gen(time(0));
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii; typedef pair<ll,int> pli; typedef pair<ll,ll> pll; typedef pair<int,ll> pil;
inline ll read(){
ll x=0,f=1,c=getchar();
while(c<'0'||c>'9')f=(c=='-'?-1:1),c=getchar();
while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
return x*f;
}
const int mod=998244353;
inline int fp(int x,ll p=mod-2,int m=mod,int res=1){
for(;p;p>>=1){if(p&1)res=1ll*res*x%m;x=1ll*x*x%m;}
return res;
}
inline void plust(int &x,int y){x=x+y>=mod?x+y-mod:x+y;}
const int N=5e5+3;
// clang-format on
int n,dfn[N],tim,st[19][N],val[N],id[N];
ll dep[N];
vector<pil>G[N];
inline void dfs(int u,int fa){
st[0][dfn[u]=++tim]=fa;
for(auto tmp:G[u])if(tmp.fi!=fa){
int v=tmp.fi;dep[v]=dep[u]+tmp.se;
dfs(v,u);
}
}
inline int pmin(int x,int y){return dfn[x]<dfn[y]?x:y;}
inline int lca(int u,int v){
if(u==v)return u;
if((u=dfn[u])>(v=dfn[v]))swap(u,v);
int k=__lg(v-u++);
return pmin(st[k][u],st[k][v-(1<<k)+1]);
}
inline ll dist(int u,int v){
if(!u || !v)return 0;
int l=lca(u,v);
return dep[u]+dep[v]-(dep[l]<<1);
}
pii a[N];
int main() {
//freopen("data.in", "r", stdin);
// freopen(".in","r",stdin);
// freopen("myans.out","w",stdout);
n=read();int Q=read();
rep(i,1,n)val[i]=read(),id[i]=i;
sort(id+1,id+n+1,[&](int x,int y){return val[x]<val[y];});
rep(i,1,n-1){
int u=read(),v=read(),w=read();
G[u].pb(P(v,w));
G[v].pb(P(u,w));
}
dfs(1,0);
rep(j,1,18)rep(i,1,n-(1<<j)+1)st[j][i]=pmin(st[j-1][i],st[j-1][i+(1<<(j-1))]);
int p=n;
rep(i,1,n){
if(val[id[i]] > val[id[i-1]] + 1){p=i-1;break;}
int j=id[i];a[i]=a[i-1];
if(!a[i].fi){a[i].fi=j;continue;}
if(!a[i].se){a[i].se=j;continue;}
if(dist(a[i].fi,j)>max(dist(a[i].se,j),dist(a[i].fi,a[i].se))){
a[i].se=j;
continue;
}
if(dist(a[i].se,j)>max(dist(a[i],fi,j),dist(a[i].fi,a[i].se))){
a[i].fi=j;
continue;
}
}
val[0]=-1;
while(Q--){
int x=read();ll k=read();
int l=1,r=p;
while(l<=r){
int mid=(l+r)>>1;
ll d=max(dist(x,a[mid].fi),dist(x,a[mid].se));
if(d>k)r=mid-1;
else l=mid+1;
}
printf("%d\n",val[id[r]]+1);
}
return 0;
}