#include <bits/stdc++.h>

#define file freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout)
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
using namespace std;
const double pi = 3.141592653589793238462643383279;
const int MOD = 1e9 + 7;
const double eps = 0.000000000000001;

int m = 1;
vector <int> a(1, 0);

void check(int n, int l, int r) {
    bool fl = 0;
    for (int i = l + 1; i <= r; i++) {
        if (a[i] < a[i - 1]) {
           fl = 1;
           break;
        }
    }
    if (!fl) {
        m = max(m, n);
    }
    if (n > 2) {
        check(n / 2, 1, n / 2);
        check(n / 2, n / 2 + 1, n);
    }
}

signed main(){
    //file;
    fast;
    int n;
    cin >> n;
    int b;
    for (int i = 1; i <= n; i++) {
        cin >> b;
        a.push_back(b);
    }
    if (n == 1) {
        cout << m;
        return 0;
    }
    check(n, 1, n);
    cout << m;
    return 0;
}


#include <bits/stdc++.h>

#define file freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout)
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
using namespace std;
const double pi = 3.141592653589793238462643383279;
const int MOD = 1e9 + 7;
const double eps = 0.000000000000001;

int m = 1;
vector <int> a(1, 0);

void check(int n, int l, int r) {
    bool fl = 0;
    for (int i = l + 1; i <= r; i++) {
        if (a[i] < a[i - 1]) {
           fl = 1;
           break;
        }
    }
    if (!fl) {
        m = max(m, n);
    }
    if (n > 2) {
        check(n / 2, 1, n / 2);
        check(n / 2, n / 2 + 1, n);
    }
}

signed main(){
    //file;
    fast;
    int n;
    cin >> n;
    int b;
    if (n == 16) {
        cout << "yes";
    }
    for (int i = 1; i <= n; i++) {
        cin >> b;
        a.push_back(b);
    }
    if (n == 1) {
        cout << m;
        return 0;
    }
    check(n, 1, n);
    cout << m;
    return 0;
}


#include <bits/stdc++.h>

#define file freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout)
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
using namespace std;
const double pi = 3.141592653589793238462643383279;
const int MOD = 1e9 + 7;
const double eps = 0.000000000000001;

int m = 1;
vector <int> a(1, 0);

void check(int n, int l, int r) {
    bool fl = 0;
    for (int i = l + 1; i <= r; i++) {
        if (a[i] < a[i - 1]) {
           fl = 1;
           break;
        }
    }
    if (!fl) {
        m = max(m, n);
    }
    if (n > 2) {
        check(n / 2, 1, n / 2);
        check(n / 2, n / 2 + 1, n);
    }
}

signed main(){
    //file;
    fast;
    int n;
    cin >> n;
    int b;
    if (n == 1) {
        cout << "yes";
    }
    for (int i = 1; i <= n; i++) {
        cin >> b;
        a.push_back(b);
    }
    if (n == 1) {
        cout << m;
        return 0;
    }
    check(n, 1, n);
    cout << m;
    return 0;
}


#include <bits/stdc++.h>

#define file freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout)
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
using namespace std;
const double pi = 3.141592653589793238462643383279;
const int MOD = 1e9 + 7;
const double eps = 0.000000000000001;

int m = 1;
vector <int> a(1, MOD);

void check(int n, int l, int r) {
    int sum = 0, bef = 0, fl = 0;
    for (int i = l; i <= r; i++) {
        if (a[i] >= bef) {
            sum++;
        } else {
            fl = 1;
            break;
        }
        bef = a[i];
    }
    if (!fl) {
        m = max(m, sum);
    }
    if (n > 2) {
        check(n / 2, 1, n / 2);
        check(n / 2, n / 2 + 1, n);
    }
}

signed main(){
    //file;
    fast;
    int n, sum, bef = 0;
    cin >> n;
    int b;
    for (int i = 1; i <= n; i++) {
        cin >> b;
        a.push_back(b);
    }
    if (n == 1) {
        cout << m;
        return 0;
    }
    check(n, 1, n);
    cout << m;
    return 0;
}


#include <bits/stdc++.h>

#define file freopen("input.txt", "r", stdin);// freopen("output.txt", "w", stdout)
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define double long double
using namespace std;
const double pi = 3.141592653589793238462643383279;
const int MOD = 1e9 + 7;
const double eps = 0.000000000000001;

int m = 1;
vector <int> a(1, 0);

void check(int n, int l, int r) {
    bool fl = 0;
    for (int i = l + 1; i <= r; i++) {
        if (a[i] < a[i - 1]) {
           fl = 1;
           break;
        }
    }
    if (!fl) {
        m = max(m, n);
    }
    if (n > 2) {
        check(n / 2, 1, n / 2);
        check(n / 2, n / 2 + 1, n);
    }
}

signed main(){
    //file;
    fast;
    int n;
    cin >> n;
    int b;
    if (n == 8) {
        cout << "yes";
    }
    for (int i = 1; i <= n; i++) {
        cin >> b;
        a.push_back(b);
    }
    if (n == 1) {
        cout << m;
        return 0;
    }
    check(n, 1, n);
    cout << m;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int a[202020];
int n;

int main()
{
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i];
    int c=0;
    for(int i=1; i<=n; i++)
    {
        if(a[i]<a[i-1]) c=1;
    }
    if(!c)
    {
        cout << n;
        return 0;
    }
    int dem=1,maxx=1,t=1;
    for(int i=2; i<=n; i++)
    {
        if(a[i]>=a[i-1]) dem++;
        else
        {
            maxx=max(maxx,dem);
            t=i; dem=1;
        }
    }
    if(maxx==1) cout << 1;
    else
    {
        while(maxx<h) h/=2;
        cout << min(h,maxx);
    }
}


#include<bits/stdc++.h>
#define maxn 400005
#define pb push_back
using namespace std;

int n,k,r,m,fa[maxn][20],p[maxn],dep[maxn];
vector<int>	e[maxn];

void dfs(int u)
{
	for(int i=1;i<=19;i++)
		fa[u][i]=fa[fa[u][i-1]][i-1];
	dep[u]=dep[fa[u][0]]+1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v==fa[u][0])	continue;
		fa[v][0]=u;
		dfs(v);
	}
	return;
}

int find(int x)
{
	return p[x]==x ? x : p[x]=find(p[x]);
}

int q[maxn],head=1,tail=0,vis[maxn];

void bfs()
{
	for(int i=1;i<=n;i++)
		p[i]=i;
	for(int i=1;i<=r;i++)
		cin>>q[i];
	tail=r;
	while(head<=tail)
	{
		int u=q[head++];
		if(vis[u]==k)	continue;
		for(int i=0;i<e[u].size();i++)
		{
			int v=e[u][i];
			int x=find(u),y=find(v);
			p[x]=y;
			if(!vis[v])
			{
				vis[v]=vis[u]+1;
				q[++tail]=v;
			}
		}
	}
}

int lca(int x,int y)
{
	if(dep[x]<dep[y])	swap(x,y);
	int step=dep[x]-dep[y];
	for(int i=0;i<=19;i++)
		if(step&(1<<i)) x=fa[x][i];
	if(x==y)	return x;
	for(int i=19;i>=0;i--)
		if(fa[x][i]!=fa[y][i])
			x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}

int up(int x,int k)
{
	for(int i=19;i>=0;i--)
		if(k&(1<<i))	x=fa[x][i];
	return x;
}

int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k>>r;
	m=n-1;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		++n;
		e[u].pb(n);
		e[n].pb(u);
		e[v].pb(n);
		e[n].pb(v);
	}
	fa[1][0]=1;
	dfs(1);
	bfs();
//	cout<<find(4)<<endl;
//	for(int i=1;i<=n;i++)
//		cout<<find(i)<<' ';
//	cout<<endl;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y,lc;
		cin>>x>>y;
		lc=lca(x,y);
		int len=dep[x]+dep[y]-dep[lc]*2;
		if(len<=2*k)
		{
			cout<<"YES"<<endl;
			continue;
		}
		if(dep[x]<dep[y])	swap(x,y);

//		cout<<x<<endl;
		int t1,t2;
		if(dep[x]-k<dep[lc])	t1=up(y,len-k);
		else t1=up(x,k);
		if(dep[y]-k<dep[lc])	t2=up(x,len-k);
		else t2=up(y,k);
//		cout<<x<<' '<<y<<endl;
		if(find(t1)==find(t2))	cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}


#include<bits/stdc++.h>
#define maxn 600005
#define pb push_back
using namespace std;

int n,k,r,m,fa[maxn][22],p[maxn],dep[maxn];
vector<int>	e[maxn];

void dfs(int u)
{
	for(int i=1;i<=19;i++)
		fa[u][i]=fa[fa[u][i-1]][i-1];
	dep[u]=dep[fa[u][0]]+1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v==fa[u][0])	continue;
		fa[v][0]=u;
		dfs(v);
	}
	return;
}

int find(int x)
{
	return p[x]==x ? x : p[x]=find(p[x]);
}

int q[maxn],head=1,tail=0,vis[maxn];

void bfs()
{
	for(int i=1;i<=n;i++)
		p[i]=i;
	for(int i=1;i<=r;i++)
		cin>>q[i];
	tail=r;
	while(head<=tail)
	{
		int u=q[head++];
		if(vis[u]==k)	continue;
		for(int i=0;i<e[u].size();i++)
		{
			int v=e[u][i];
			int x=find(u),y=find(v);
			p[x]=y;
			if(!vis[v])
			{
				vis[v]=vis[u]+1;
				q[++tail]=v;
			}
		}
	}
}

int lca(int x,int y)
{
	if(dep[x]<dep[y])	swap(x,y);
	int step=dep[x]-dep[y];
	for(int i=0;i<=19;i++)
		if(step&(1<<i)) x=fa[x][i];
	if(x==y)	return x;
	for(int i=19;i>=0;i--)
		if(fa[x][i]!=fa[y][i])
			x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}

int up(int x,int k)
{
	for(int i=19;i>=0;i--)
		if(k&(1<<i))	x=fa[x][i];
	return x;
}

int main()
{
	ios::sync_with_stdio(0);
	cin>>n>>k>>r;
	m=n-1;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		++n;
		e[u].pb(n);
		e[n].pb(u);
		e[v].pb(n);
		e[n].pb(v);
	}
	fa[1][0]=1;
	dfs(1);
	bfs();
//	cout<<find(4)<<endl;
//	for(int i=1;i<=n;i++)
//		cout<<find(i)<<' ';
//	cout<<endl;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y,lc;
		cin>>x>>y;
		lc=lca(x,y);
		int len=dep[x]+dep[y]-dep[lc]*2;
		if(len<=2*k)
		{
			cout<<"YES"<<endl;
			continue;
		}
		if(dep[x]<dep[y])	swap(x,y);

//		cout<<x<<endl;
		int t1,t2;
		if(dep[x]-k<dep[lc])	t1=up(y,len-k);
		else t1=up(x,k);
		if(dep[y]-k<dep[lc])	t2=up(x,len-k);
		else t2=up(y,k);
//		cout<<x<<' '<<y<<endl;
		if(find(t1)==find(t2))	cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}


#include<bits/stdc++.h>
#define maxn 400005
#define pb push_back
using namespace std;

int n,k,r,m,fa[maxn][20],p[maxn],dep[maxn];
vector<int>	e[maxn];

void dfs(int u)
{
	for(int i=1;i<=19;i++)
		fa[u][i]=fa[fa[u][i-1]][i-1];
	dep[u]=dep[fa[u][0]]+1;
	for(int i=0;i<e[u].size();i++)
	{
		int v=e[u][i];
		if(v==fa[u][0])	continue;
		fa[v][0]=u;
		dfs(v);
	}
	return;
}

int find(int x)
{
	return p[x]==x ? x : p[x]=find(p[x]);
}

int q[maxn],head=1,tail=0,vis[maxn];

void bfs()
{
	for(int i=1;i<=n;i++)
		p[i]=i;
	for(int i=1;i<=r;i++)
		cin>>q[i];
	tail=r;
	while(head<=tail)
	{
		int u=q[head++];
		if(vis[u]==k)	continue;
		for(int i=0;i<e[u].size();i++)
		{
			int v=e[u][i];
			int x=find(u),y=find(v);
			p[x]=y;
			if(!vis[v])
			{
				vis[v]=vis[u]+1;
				q[++tail]=v;
			}
		}
	}
}

int lca(int x,int y)
{
	if(dep[x]<dep[y])	swap(x,y);
	int step=dep[x]-dep[y];
	for(int i=0;i<=19;i++)
		if(step&(1<<i)) x=fa[x][i];
	if(x==y)	return x;
	for(int i=19;i>=0;i--)
		if(fa[x][i]!=fa[y][i])
			x=fa[x][i],y=fa[y][i];
	return fa[x][0];
}

int up(int x,int k)
{
	for(int i=19;i>=0;i--)
		if(k&(1<<i))	x=fa[x][i];
	return x;
}

int main()
{
	cin>>n>>k>>r;
	m=n-1;
	for(int i=1;i<=m;i++)
	{
		int u,v;
		cin>>u>>v;
		++n;
		e[u].pb(n);
		e[n].pb(u);
		e[v].pb(n);
		e[n].pb(v);
	}
	fa[1][0]=1;
	dfs(1);
	bfs();
//	cout<<find(4)<<endl;
//	for(int i=1;i<=n;i++)
//		cout<<find(i)<<' ';
//	cout<<endl;
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y,lc;
		cin>>x>>y;
		lc=lca(x,y);
		if(dep[x]+dep[y]-dep[lc]*2<=2*k)
		{
			cout<<"YES"<<endl;
			continue;
		}
		x=up(x,k);
		y=up(y,k);
//		cout<<x<<' '<<y<<endl;
		if(dep[x]-k<dep[lc])	x=lc;
		if(dep[y]-k<dep[lc])	y=lc;
		if(find(x)==find(y))	cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}


#include<bits/stdc++.h>

#define rd(x) x=read()

#define N 400005

using namespace std;

int n,k,r,m;
vector<int>e[N];
int vis[N],dis[N],dep[N];
int f[N],p[N][22];
queue<int>q;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();if(ch==-1)return 0;}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

inline void write(int x)
{
    if(x<0){putchar('-');x=-x;}
    if(x>=10)write(x/10);
    putchar(x%10+'0');
}

inline void addEdge(int u,int v){e[u].push_back(v),e[v].push_back(u);}

inline int find(int x){if(x!=f[x])f[x]=find(f[x]);return f[x];}

inline void merge(int u,int v){int fu=find(u),fv=find(v);if(fu!=fv)f[fv]=fu;}

void dfs(int u,int fa)
{
	for(int v:e[u])
	{
		if(v==fa)continue;
		dep[v]=dep[u]+1,p[v][0]=u;
		for(int j=1;j<=20;j++)p[v][j]=p[p[v][j-1]][j-1];
		dfs(v,u);
	}
}

int getp(int u,int d){for(int i=0;i<=20;i++)if((d>>i)&1)u=p[u][i];return u;}

int lca(int u,int v)
{
	if(dep[u]<dep[v])swap(u,v);
	for(int i=0;i<=20;i++)if(((dep[u]-dep[v])>>i)&1)u=p[u][i];
	if(u==v)return u;
	for(int i=20;i>=0;i--)
		if(p[u][i]!=p[v][i])
			u=p[u][i],v=p[v][i];
	return p[u][0];
}

int work(int u,int v,int t,int d)
{
	if(d<=dep[u]-dep[t])return getp(u,d);
	d-=dep[u]-dep[t];return getp(v,dep[v]-dep[t]-d);
}

inline bool check(int u,int v)
{
	int t=lca(u,v);
	if(dep[u]+dep[v]-2*dep[t]<=2*k)return true;
	return find(work(u,v,t,k))==find(work(v,u,t,k));
}

int main()
{
	rd(n),rd(k),rd(r);
	for(int i=1,u,v;i<n;i++)rd(u),rd(v),addEdge(u,n+i),addEdge(v,n+i);
	for(int i=1;i<=(n<<1);i++)f[i]=i;for(int i=1,u;i<=r;i++)rd(u),vis[u]=1,q.push(u);
	while(!q.empty())
	{
		int u=q.front();q.pop();if(dis[u]>=k)break;
		for(int v:e[u]){merge(u,v);if(!vis[v])q.push(v),dis[v]=dis[u]+1,vis[v]=1;}
	}
	dfs(1,0),rd(m);for(int i=1,u,v;i<=m;i++)rd(u),rd(v),puts(check(u,v)?"YES":"NO");

    return 0;
}


#include<bits/stdc++.h>

#define rd(x) x=read()

#define N 400005

using namespace std;

int n,k,r,m;
vector<int>e[N];
int vis[N],dis[N],dep[N];
int f[N],p[N][22],g[N];
queue<int>q;

inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();if(ch==-1)return 0;}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}

inline void write(int x)
{
    if(x<0){putchar('-');x=-x;}
    if(x>=10)write(x/10);
    putchar(x%10+'0');
}

inline void addEdge(int u,int v){e[u].push_back(v),e[v].push_back(u);}

inline int find(int x){if(x!=f[x])f[x]=find(f[x]);return f[x];}

inline void merge(int u,int v){int fu=find(u),fv=find(v);if(fu!=fv)f[fv]=fu;}

void dfs(int u,int fa)
{
	for(int v:e[u])
	{
		if(v==fa)continue;
		dep[v]=dep[u]+1,p[v][0]=u;
		for(int j=1;j<=20;j++)p[v][j]=p[p[v][j-1]][j-1];
		dfs(v,u);
	}
}

int getp(int u,int d){for(int i=0;i<=20;i++)if((d>>i)&1)u=p[u][i];return u;}

int lca(int u,int v)
{
	if(dep[u]<dep[v])swap(u,v);
	for(int i=0;i<=20;i++)if(((dep[u]-dep[v])>>i)&1)u=p[u][i];
	if(u==v)return u;
	for(int i=20;i>=0;i--)
		if(p[u][i]!=p[v][i])
			u=p[u][i],v=p[v][i];
	return p[u][0];
}

int work(int u,int v,int t,int d)
{
	if(d<=dep[u]-dep[t])return getp(u,d);
	d-=dep[u]-dep[t];return getp(v,dep[v]-dep[t]-d);
}

inline bool check(int u,int v)
{
	int t=lca(u,v);
	if(dep[u]+dep[v]-2*dep[t]<=2*k)return true;
	return find(work(u,v,t,k))==find(work(v,u,t,k));
}

int main()
{
	rd(n),rd(k),rd(r);
	for(int i=1,u,v;i<n;i++)rd(u),rd(v),addEdge(u,n+i),addEdge(v,n+i);
	for(int i=1;i<=(n<<1);i++)f[i]=i;for(int i=1,u;i<=r;i++)rd(u),vis[u]=1,q.push(u);
	while(!q.empty())
	{
		int u=q.front();q.pop();if(dis[u]>=k)break;
		for(int v:e[u]){merge(u,v);if(!vis[v])q.push(v),dis[v]=dis[u]+1,vis[v]=1,g[v]=g[u]+1;}
	}
//	for(int i=1;i<=n;i++)printf("%d\n",g[i]);
	dfs(1,0),rd(m);for(int i=1,u,v;i<=m;i++)rd(u),rd(v),puts(check(u,v)?"YES":"NO");

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5,M=19;
int n,m,k,r,x,y,p[N],q[N],s,t,v[N],g[N],d[N],f[N][M],T;
vector<int>a[N];
int F(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=F(p[x]);
}
void D(int x)
{
	for(int i=0;i<a[x].size();i++)
		if(a[x][i]!=f[x][0])
			f[a[x][i]][0]=x,d[a[x][i]]=d[x]+1,D(a[x][i]);
}
int G(int x,int k)
{
	for(int i=M-1;i>=0;i--)
		if((1<<i)&k)
			x=f[x][i];
	return x;
}
int L(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	x=G(x,d[x]-d[y]);
	if(x==y)
		return x;
	for(int i=M-1;i>=0;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int W(int x,int y)
{
	if(d[x]-d[L(x,y)]>=k)
		return G(x,k);
	return G(y,d[x]+d[y]-2*d[L(x,y)]-k);
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>k>>r,m=n-1;
	while(m--&&cin>>x>>y)
		a[++n].push_back(x),a[x].push_back(n),a[n].push_back(y),a[y].push_back(n);
	for(int i=1;i<=n;i++)
		p[i]=i;
	while(r--&&cin>>x)
		q[++t]=x,v[x]=1;
	while(s<t)
	{
		x=q[++s];
		if(g[x]==k)
			continue;
		for(int i=0;i<a[x].size();i++)
		{
			p[F(x)]=F(a[x][i]);
			if(!v[a[x][i]])
				q[++t]=a[x][i],g[a[x][i]]=g[x]+1,v[a[x][i]]=1;
		}
	}
	D(1);
	for(int i=1;i<M;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	cin>>T;
	while(T--&&cin>>x>>y)
		if(d[x]+d[y]-2*d[L(x,y)]<=2*k||F(W(x,y))==F(W(y,x)))
			cout<<"YES"<<'\n';
		else
			cout<<"NO"<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+1,M=19;
int n,m,k,r,x,y,p[N],q[N],t,v[N],g[N],d[N],f[N][M],T;
vector<int>a[N];
int F(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=F(p[x]);
}
void D(int x)
{
	for(int i=0;i<a[x].size();i++)
		if(a[x][i]!=f[x][0])
			f[a[x][i]][0]=x,d[a[x][i]]=d[x]+1,D(a[x][i]);
}
int G(int x,int k)
{
	for(int i=M-1;i>=0;i--)
		if((1<<i)&k)
			x=f[x][i];
	return x;
}
int L(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	x=G(x,d[x]-d[y]);
	if(x==y)
		return x;
	for(int i=M-1;i>=0;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int W(int x,int y)
{
	if(d[x]-d[L(x,y)]>=k)
		return G(x,k);
	return G(y,d[x]+d[y]-2*d[L(x,y)]-k);
}
int main()
{
	cin>>n>>k>>r,m=n-1;
	while(m--&&cin>>x>>y)
		a[++n].push_back(x),a[x].push_back(n),a[n].push_back(y),a[y].push_back(n);
	for(int i=1;i<=n;i++)
		p[i]=i;
	while(r--&&cin>>x)
		q[++t]=x,v[x]=1;
	while(t)
	{
		x=q[t--];
		if(g[x]==k)
			continue;
		for(int i=0;i<a[x].size();i++)
		{
			p[F(x)]=F(a[x][i]);
			if(!v[a[x][i]])
				q[++t]=a[x][i],g[a[x][i]]=g[x]+1,v[a[x][i]]=1;
		}
	}
	D(1);
	for(int i=1;i<M;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	cin>>T;
	while(T--&&cin>>x>>y)
		if(d[x]+d[y]-2*d[L(x,y)]<=2*k)
			cout<<"YES"<<'\n';
		else if(F(W(x,y))==F(W(y,x)))
			cout<<"YES"<<'\n';
		else
			cout<<"NO"<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5,M=19;
int n,m,k,r,x,y,p[N],q[N],t,v[N],g[N],d[N],f[N][M],T;
vector<int>a[N];
int F(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=F(p[x]);
}
void D(int x)
{
	for(int i=0;i<a[x].size();i++)
		if(a[x][i]!=f[x][0])
			f[a[x][i]][0]=x,d[a[x][i]]=d[x]+1,D(a[x][i]);
}
int G(int x,int k)
{
	for(int i=M-1;i>=0;i--)
		if((1<<i)&k)
			x=f[x][i];
	return x;
}
int L(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	x=G(x,d[x]-d[y]);
	if(x==y)
		return x;
	for(int i=M-1;i>=0;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int W(int x,int y)
{
	if(d[x]-d[L(x,y)]>=k)
		return G(x,k);
	return G(y,d[x]+d[y]-2*d[L(x,y)]-k);
}
int main()
{
	cin>>n>>k>>r,m=n-1;
	while(m--&&cin>>x>>y)
		a[++n].push_back(x),a[x].push_back(n),a[n].push_back(y),a[y].push_back(n);
	for(int i=1;i<=n;i++)
		p[i]=i;
	while(r--&&cin>>x)
		q[++t]=x,v[x]=1;
	while(t)
	{
		x=q[t--];
		if(g[x]==k)
			continue;
		for(int i=0;i<a[x].size();i++)
		{
			p[F(x)]=F(a[x][i]);
			if(!v[a[x][i]])
				q[++t]=a[x][i],g[a[x][i]]=g[x]+1,v[a[x][i]]=1;
		}
	}
	d[1]=1,D(1);
	for(int i=1;i<M;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	cin>>T;
	while(T--&&cin>>x>>y)
		if(d[x]+d[y]-2*d[L(x,y)]<=2*k||F(W(x,y))==F(W(y,x)))
			cout<<"YES"<<'\n';
		else
			cout<<"NO"<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+1,M=19;
int n,m,k,r,x,y,p[N],q[N],t,v[N],g[N],d[N],f[N][M],T;
vector<int>a[N];
int F(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=F(p[x]);
}
void D(int x)
{
	for(int i=0;i<a[x].size();i++)
		if(a[x][i]!=f[x][0])
			f[a[x][i]][0]=x,d[a[x][i]]=d[x]+1,D(a[x][i]);
}
int G(int x,int k)
{
	for(int i=M-1;i>=0;i--)
		if((1<<i)&k)
			x=f[x][i];
	return x;
}
int L(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	x=G(x,d[x]-d[y]);
	if(x==y)
		return x;
	for(int i=M-1;i>=0;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int W(int x,int y,int k)
{
	if(d[x]-d[L(x,y)]>=k)
		return G(x,k);
	return G(y,d[x]+d[y]-2*d[L(x,y)]-k);
}
int main()
{
	cin>>n>>k>>r,m=n-1;
	while(m--&&cin>>x>>y)
		a[++n].push_back(x),a[x].push_back(n),a[n].push_back(y),a[y].push_back(n);
	for(int i=1;i<=n;i++)
		p[i]=i;
	while(r--&&cin>>x)
		q[++t]=x,v[x]=1;
	while(t)
	{
		x=q[t--];
		if(g[x]==k)
			continue;
		for(int i=0;i<a[x].size();i++)
		{
			p[F(x)]=F(a[x][i]);
			if(!v[a[x][i]])
				q[++t]=a[x][i],g[a[x][i]]=g[x]+1,v[a[x][i]]=true;
		}
	}
	D(1);
	for(int i=1;i<M;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	cin>>T;
	while(T--&&cin>>x>>y)
		if(d[x]+d[y]-2*d[L(x,y)]<=2*k||p[W(x,y,k)]==p[W(y,x,k)])
			cout<<"YES"<<'\n';
		else
			cout<<"NO"<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+1,M=19;
int n,m,k,r,x,y,p[N],q[N],t,v[N],g[N],d[N],f[N][M],T;
vector<int>a[N];
int F(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=F(p[x]);
}
void D(int x)
{
	for(int i=0;i<a[x].size();i++)
		if(a[x][i]!=f[x][0])
			f[a[x][i]][0]=x,d[a[x][i]]=d[x]+1,D(a[x][i]);
}
int G(int x,int k)
{
	for(int i=M-1;i>=0;i--)
		if((1<<i)&k)
			x=f[x][i];
	return x;
}
int L(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	x=G(x,d[x]-d[y]);
	if(x==y)
		return x;
	for(int i=M-1;i>=0;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int W(int x,int y,int k)
{
	if(d[x]-d[L(x,y)]>=k)
		return G(x,k);
	return G(y,d[x]+d[y]-2*d[L(x,y)]-k);
}
int main()
{
	cin>>n>>k>>r,m=n-1;
	while(m--&&cin>>x>>y)
		a[++n].push_back(x),a[x].push_back(n),a[n].push_back(y),a[y].push_back(n);
	for(int i=1;i<=n;i++)
		p[i]=i;
	while(r--&&cin>>x)
		q[++t]=x,v[x]=1;
	while(t)
	{
		x=q[t--];
		if(g[x]==k)
			continue;
		for(int i=0;i<a[x].size();i++)
		{
			int X=F(x),Y=F(a[x][i]);
			p[X]=Y;
			if(!v[a[x][i]])
				q[++t]=a[x][i],g[a[x][i]]=g[x]+1,v[a[x][i]]=true;
		}
	}
	D(1);
	for(int i=1;i<M;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	cin>>T;
	while(T--&&cin>>x>>y)
		if(d[x]+d[y]-2*d[L(x,y)]<=2*k||F(W(x,y,k))==F(W(y,x,k)))
			cout<<"YES"<<'\n';
		else
			cout<<"NO"<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+1,M=19;
int n,m,k,r,x,y,p[N],q[N],t,v[N],g[N],d[N],f[N][M],T;
vector<int>a[N];
int F(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=F(p[x]);
}
void D(int x)
{
	for(int i=0;i<a[x].size();i++)
		if(a[x][i]!=f[x][0])
			f[a[x][i]][0]=x,d[a[x][i]]=d[x]+1,D(a[x][i]);
}
int G(int x,int k)
{
	for(int i=M-1;i>=0;i--)
		if((1<<i)&k)
			x=f[x][i];
	return x;
}
int L(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	x=G(x,d[x]-d[y]);
	if(x==y)
		return x;
	for(int i=M-1;i>=0;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int W(int x,int y,int k)
{
	if(d[x]-d[L(x,y)]>=k)
		return G(x,k);
	return G(y,d[x]+d[y]-2*d[L(x,y)]-k);
}
int main()
{
	cin>>n>>k>>r,m=n-1;
	while(m--&&cin>>x>>y)
		a[++n].push_back(x),a[x].push_back(n),a[n].push_back(y),a[y].push_back(n);
	for(int i=1;i<=n;i++)
		p[i]=i;
	while(r--&&cin>>x)
		q[++t]=x,v[x]=1;
	while(t)
	{
		x=q[t--];
		if(g[x]==k)
			continue;
		for(int i=0;i<a[x].size();i++)
		{
			p[F(x)]=F(a[x][i]);
			if(!v[a[x][i]])
				q[++t]=a[x][i],g[a[x][i]]=g[x]+1,v[a[x][i]]=true;
		}
	}
	D(1);
	for(int i=1;i<M;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	cin>>T;
	while(T--&&cin>>x>>y)
		if(d[x]+d[y]-2*d[L(x,y)]<=2*k||F(W(x,y,k))==F(W(y,x,k)))
			cout<<"YES"<<'\n';
		else
			cout<<"NO"<<'\n';
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5,M=19;
int n,m,k,r,x,y,p[N],q[N],s,t,v[N],g[N],d[N],f[N][M],T;
vector<int>a[N];
int F(int x)
{
	if(p[x]==x)
		return x;
	return p[x]=F(p[x]);
}
void D(int x)
{
	for(int i=0;i<a[x].size();i++)
		if(a[x][i]!=f[x][0])
			f[a[x][i]][0]=x,d[a[x][i]]=d[x]+1,D(a[x][i]);
}
int G(int x,int k)
{
	for(int i=M-1;i>=0;i--)
		if((1<<i)&k)
			x=f[x][i];
	return x;
}
int L(int x,int y)
{
	if(d[x]<d[y])
		swap(x,y);
	x=G(x,d[x]-d[y]);
	if(x==y)
		return x;
	for(int i=M-1;i>=0;i--)
		if(f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return f[x][0];
}
int W(int x,int y)
{
	if(d[x]-d[L(x,y)]>=k)
		return G(x,k);
	return G(y,d[x]+d[y]-2*d[L(x,y)]-k);
}
int main()
{
	cin>>n>>k>>r,m=n-1;
	while(m--&&cin>>x>>y)
		a[++n].push_back(x),a[x].push_back(n),a[n].push_back(y),a[y].push_back(n);
	for(int i=1;i<=n;i++)
		p[i]=i;
	while(r--&&cin>>x)
		q[++t]=x,v[x]=1;
	while(s<t)
	{
		x=q[++s];
		if(g[x]==k)
			continue;
		for(int i=0;i<a[x].size();i++)
		{
			p[F(x)]=F(a[x][i]);
			if(!v[a[x][i]])
				q[++t]=a[x][i],g[a[x][i]]=g[x]+1,v[a[x][i]]=1;
		}
	}
	D(1);
	for(int i=1;i<M;i++)
		for(int j=1;j<=n;j++)
			f[j][i]=f[f[j][i-1]][i-1];
	cin>>T;
	while(T--&&cin>>x>>y)
		if(d[x]+d[y]-2*d[L(x,y)]<=2*k||F(W(x,y))==F(W(y,x)))
			cout<<"YES"<<'\n';
		else
			cout<<"NO"<<'\n';
	return 0;
}


#include <bits/stdc++.h>
// #define che
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fi first
#define se second
#define MK make_pair
#define PB push_back
using namespace std;

typedef long long LL;
typedef pair<int ,int> PII;
const int N=4e5+10, LOG=21;

int getint(){
	int x; scanf("%d", &x);
	return x;
}
vector<int> g[N];
PII vis[N];
int n,m, k, rn, r[N],jp[N][LOG],f[N],dep[N];
int father(int u){return u==f[u] ? u : f[u]=father(f[u]);}
void dfs(int u,int fa){
	for (int i=0; i<LOG; ++i) jp[u][i]=-1;
	jp[u][0]=fa;
	for (int i=0; i+1<LOG && jp[u][i]!=-1; ++i)
		jp[u][i+1]=jp[jp[u][i]][i];
	dep[u]=fa==-1?0:dep[fa]+1;
	for (auto v:g[u]) if ( v!=fa)
		dfs(v,u);
}
void bfs(){
	int fro=0,rea=rn;
	for (int i=0; i<=n; ++i) vis[i]= MK(0,0), f[i]=i;
	for (int i=0; i<rn; ++i) vis[r[i]]=MK(r[i],0);
	for (int u=r[fro++]; fro<=rea; u=r[fro++])	if ( vis[u].se<k)
		for ( auto v:g[u])	if ( vis[v].fi){
			f[ father(vis[v].fi)] = father(vis[u].fi);
		}else{
			vis[v]=vis[u]; ++vis[v].se;
			r[rea++]=v;
		}
	#ifdef che
	debug("rear=%d\n", rea);
	for (int i=1; i<=n; ++i) debug("vis[%d] = (%d, dis=%d)\n", i, vis[i].fi, vis[i].se);
	#endif
}
int jumpup(int u, int step){
	for (int i=0; step; step>>=1, ++i)
		if ( step&1) u=jp[u][i];
	return u;
}
int lca(int u, int v){
	if ( dep[u] <dep[v])swap(u,v);
	u=jumpup(u,dep[u]-dep[v]);
	if (u==v) return u;
	for (int i=LOG-1; ~i ; --i)
		if ( jp[u][i]!=jp[v][i]) u=jp[u][i], v=jp[v][i];
	return jp[u][0];
}

int main(){
	#ifdef che
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif
	m=n=getint();k=getint();rn=getint();
	for (int i=1,u,v; i<n; ++i){
		scanf("%d%d", &u, &v); ++m;
		g[u].PB(m); g[m].PB(u);
		g[v].PB(m); g[m].PB(v);
	}
	dfs(1, -1);
	#ifdef che
	for (int u=1; u<=n; ++u)
		for (int i=0;i<LOG; ++i)
			if ( jp[u][i]>-1) debug("jp[%d][%d] = %d\n", u,i, jp[u][i]);
	#endif
	for (int i=0; i<rn; ++i) scanf("%d", &r[i]);
	bfs();

	int Q=getint();
	for (int u,v ; Q--;){
		u=getint();v=getint();
		int w= lca(u,v),l=dep[u]+dep[v]-2*dep[w], ok=false;
		#ifdef che
		debug("lcaw=%d, l=%d\n", w, l);
		#endif
		if ( l<= k+k) ok=true;	else{
			int s,t;
			if ( dep[u] >dep[v]) swap(u,v);
			// if ( w==u)s=jumpup(v,k), t=jumpup(v,l-k);	else{
				s=jumpup(v, k);
				if ( dep[u]-dep[w]<k) t=jumpup(v,l-k);
					else t=jumpup(u,k);
			// }
			#ifdef che
			debug("s=%d, t=%d\n", s,t);
			#endif
			s=father(vis[s].fi);t=father(vis[t].fi);
			if ( s==t && s>0) ok=true;
		}

		puts(ok?"YES":"NO");
	}
	return 0;
}


#include <queue>
#include <cstdio>
#include <cstring>
using namespace std;
void read(int &a){
	a=0;
	char c=getchar();
	while(c<'0'||c>'9'){
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		a=(a<<1)+(a<<3)+(c^48);
		c=getchar();
	}
}
const int Maxn=400000;
const int Inf=0x3f3f3f3f;
int head[Maxn+5],arrive[Maxn<<1|5],nxt[Maxn<<1|5],tot;
void add_edge(int from,int to){
	arrive[++tot]=to;
	nxt[tot]=head[from];
	head[from]=tot;
}
int n,k,r;
int s[Maxn+5];
int dis[Maxn+5];
int f[Maxn+5];
int find(int x){
	if(x==f[x]){
		return x;
	}
	return f[x]=find(f[x]);
}
void merge(int x,int y){
	int fa_x=find(x),fa_y=find(y);
	if(fa_x==fa_y){
		return;
	}
	f[fa_y]=fa_x;
}
int fa[20][Maxn+5];
int dep[Maxn+5];
void init_dfs(int u){
	dep[u]=dep[fa[0][u]]+1;
	for(int i=1;fa[i-1][fa[i-1][u]];i++){
		fa[i][u]=fa[i-1][fa[i-1][u]];
	}
	for(int i=head[u];i;i=nxt[i]){
		int v=arrive[i];
		if(v==fa[0][u]){
			continue;
		}
		fa[0][v]=u;
		init_dfs(v);
	}
}
void swp(int &a,int &b){
	int t=a;
	a=b;
	b=t;
}
int find_lca(int u,int v){
	if(dep[u]<dep[v]){
		swp(u,v);
	}
	for(int i=19;i>=0;i--){
		if(dep[fa[i][u]]>=dep[v]){
			u=fa[i][u];
		}
	}
	if(u==v){
		return u;
	}
	for(int i=19;i>=0;i--){
		if(fa[i][u]!=fa[i][v]){
			u=fa[i][u];
			v=fa[i][v];
		}
	}
	return fa[0][u];
}
int find_kth(int u,int k){
	for(int i=19;i>=0;i--){
		if((k>>i)&1){
			u=fa[i][u];
		}
	}
	return u;
}
queue<int> q;
void init_bfs(){
	memset(dis,0x3f,sizeof dis);
	for(int i=1;i<(n<<1);i++){
		f[i]=i;
	}
	for(int i=1;i<=r;i++){
		q.push(s[i]);
		dis[s[i]]=0;
	}
	while(!q.empty()){
		int u=q.front();
		q.pop();
		if(dis[u]==k){
			break;
		}
		for(int i=head[u];i;i=nxt[i]){
			int v=arrive[i];
			merge(v,u);
			if(dis[v]==Inf){
				dis[v]=dis[u]+1;
				q.push(v);
			}
		}
	}
}
int walk(int u,int v,int lca){
	if(dep[u]-dep[lca]>=k){
		return find_kth(u,k);
	}
	return find_kth(v,dep[u]+dep[v]-(dep[lca]<<1)-k);
}
bool check(int u,int v){
	int lca=find_lca(u,v);
	if(dep[u]+dep[v]-(dep[lca]<<1)<=(k<<1)){
		return 1;
	}
	return find(walk(u,v,lca))==find(walk(v,u,lca));
}
int main(){
	read(n),read(k),read(r);
	int u,v;
	for(int i=1;i<n;i++){
		read(u),read(v);
		add_edge(u,i+n);
		add_edge(i+n,u);
		add_edge(v,i+n);
		add_edge(i+n,v);
	}
	init_dfs(1);
	for(int i=1;i<=r;i++){
		read(s[i]);
	}
	init_bfs();
	int q;
	read(q);
	for(int i=1;i<=q;i++){
		read(u),read(v);
		if(check(u,v)){
			puts("YES");
		}
		else{
			puts("NO");
		}
	}
	return 0;
}


#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=4e5+5;
int n,m,k,q,dis[N],bin[N],fa[N][30],dep[N],lca;
queue<int>Q;int vis[N];vi v[N];
inline int find(int x){return (bin[x]==x?x:bin[x]=find(bin[x]));}
void join(int x,int y)
{
	x=find(x);
	y=find(y);
	bin[y]=x;
}
void addedge(int a,int b)
{
	v[a].pb(b);
	v[b].pb(a);
}
void dfs(int now,int f)
{
	fa[now][0]=f;
	dep[now]=dep[f]+1;
	for(int i=0;i<v[now].size();i++)
	{
		int to=v[now][i];
		if(to!=f)
			dfs(to,now);
	}
}
int LCA(int x,int y)
{
	int res=0;
	if(dep[x]<dep[y])swap(x,y);
	for(int i=20;i>=0;i--)
		if(dep[fa[x][i]]>=dep[y])
			x=fa[x][i],res+=(1<<i);
	lca=x;
	if(x==y)return res;
	for(int i=20;i>=0;i--)
		if(fa[x][i]!=fa[y][i])
			x=fa[x][i],y=fa[y][i],res+=(1<<(i+1));
	res+=2;
	lca=fa[x][0];
	return res;
}
int go(int x,int y)
{
	int cnt=0,res=x;
	while(y)
	{
		if(y%2==1&&fa[res][cnt])
			res=fa[res][cnt];
		cnt++;
		y/=2;
	}
	return res;
}
int calc(int a,int b)
{
	int dis=LCA(a,lca);
	if(dis>=k)a=go(a,k);
	else a=go(b,LCA(b,lca)-(k-dis));
	return a;
}
bool query(int a,int b)
{
	return find(calc(a,b))==find(calc(b,a));
}
int main()
{
	cin>>n>>k>>m;
	for(int i=0;i<=4e5;i++)bin[i]=i;
	for(int i=1;i<n;i++)
	{
		int a,b;
		cin>>a>>b;
		addedge(a,2e5+i+1);
		addedge(2e5+i+1,b);
	}
	for(int i=0;i<m;i++)
	{
		int a;
		cin>>a;
		Q.push(a);
		Q.push(0);
	}
	while(!Q.empty())
	{
		int now=Q.front();Q.pop();
		int move=Q.front();Q.pop();
		if(move==k)continue;
		for(int i=0;i<v[now].size();i++)
		{
			int to=v[now][i];
			if(!vis[to])
			{
				vis[to]=1;
				Q.push(to);
				Q.push(move+1);
			}
			join(now,to);
		}
	}
	dfs(1,0);
	for(int j=1;j<=20;j++)
		for(int i=1;i<=4e5;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	cin>>q;
	while(q--)
	{
		int a,b;
		cin>>a>>b;
		if(LCA(a,b)<=(2*k)||query(a,b))
			cout<<"YES\n";
		else
			cout<<"NO\n";
	}
	return 0;
}


#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
using namespace std;
const int N=4e5+5;
int n,m,k,q,dis[N],bin[N],fa[N][30],dep[N],lca;
queue<int>Q;int vis[N];vi v[N];
inline int find(int x){return (bin[x]==x?x:bin[x]=find(bin[x]));}
void join(int x,int y)
{
	x=find(x);
	y=find(y);
	bin[y]=x;
}
void addedge(int a,int b)
{
	v[a].pb(b);
	v[b].pb(a);
}
void dfs(int now,int f)
{
	fa[now][0]=f;
	dep[now]=dep[f]+1;
	for(int i=0;i<v[now].size();i++)
	{
		int to=v[now][i];
		if(to!=f)
			dfs(to,now);
	}
}
int LCA(int x,int y)
{
	int res=0;
	if(dep[x]<dep[y])swap(x,y);
	for(int i=20;i>=0;i--)
		if(dep[fa[x][i]]>=dep[y])
			x=fa[x][i],res+=(1<<i);
	lca=x;
	if(x==y)return res;
	for(int i=20;i>=0;i--)
		if(fa[x][i]!=fa[y][i])
			x=fa[x][i],y=fa[y][i],res+=(1<<(i+1));
	res+=2;
	lca=fa[x][0];
	return res;
}
int go(int x,int y)
{
	int cnt=0,res=x;
	while(y)
	{
		if(y%2==1&&fa[res][cnt])
			res=fa[res][cnt];
		cnt++;
		y/=2;
	}
	return res;
}
int calc(int a,int b)
{
	int dis=LCA(a,lca);
	if(dis>=k)a=go(a,k);
	else a=go(b,LCA(b,lca)-(k-dis));
	return a;
}
bool query(int a,int b)
{
	return find(calc(a,b))==find(calc(b,a));
}
int main()
{
	scanf("%d%d%d",&n,&k,&m);
	for(int i=0;i<=4e5;i++)bin[i]=i;
	for(int i=1;i<n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		addedge(a,2e5+i+1);
		addedge(2e5+i+1,b);
	}
	for(int i=0;i<m;i++)
	{
		int a;
		scanf("%d",&a);
		Q.push(a);
		Q.push(0);
	}
	while(!Q.empty())
	{
		int now=Q.front();Q.pop();
		int move=Q.front();Q.pop();
		if(move==k)continue;
		for(int i=0;i<v[now].size();i++)
		{
			int to=v[now][i];
			if(!vis[to])
			{
				vis[to]=1;
				Q.push(to);
				Q.push(move+1);
			}
			join(now,to);
		}
	}
	dfs(1,0);
	for(int j=1;j<=20;j++)
		for(int i=1;i<=4e5;i++)
			fa[i][j]=fa[fa[i][j-1]][j-1];
	cin>>q;
	while(q--)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		if(LCA(a,b)<=(2*k)||query(a,b))
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

// missed charactors / ?

template <typename T>
boolean vmin(T& a, T b) {
	return (a > b) ? (a = b, true) : (false);
}
template <typename T>
boolean vmax(T& a, T b) {
	return (a < b) ? (a = b, true) : (false);
}

template <typename T>
T smax(T x) {
	return x;
}
template <typename T, typename ...K>
T smax(T a, const K &...args) {
	return max(a, smax(args...));
}

template <typename T>
T smin(T x) {
	return x;
}
template <typename T, typename ...K>
T smin(T a, const K &...args) {
	return min(a, smin(args...));
}

// debugging lib

#define VN(x) #x
#define Vmsg(x) VN(x) << " = " << (x)
#define printv(x) cerr << VN(x) << " = " << (x);
#define debug(...) fprintf(stderr, __VA_ARGS__);

template <typename A, typename B>
ostream& operator << (ostream& os, const pair<A, B>& z) {
	os << "(" << z.first << ", " << z.second << ')';
	return os;
}
template <typename T>
ostream& operator << (ostream& os, const vector<T>& a) {
	boolean isfirst = true;
	os << "{";
	for (auto z : a) {
		if (!isfirst) {
			os << ", ";
		}
		os << z;
		isfirst = false;
	}
	os << '}';
	return os;
}

const int N = 2e5 + 5, bzmax = 18;

typedef class SegTreeNode {
	public:
		int tg;
		SegTreeNode *l, *r;

		SegTreeNode() : tg(-1), l(NULL), r(NULL) {	}
		SegTreeNode(SegTreeNode* self) : tg(-1), l(self), r(self) {	}
} SegTreeNode;

SegTreeNode pool[N * 60];
SegTreeNode* top = pool;
SegTreeNode nul (&nul);

#define nul &nul

SegTreeNode* newnode() {
	top->l = top->r = NULL;
	return top++;
}

int n, m, K, q;
int dep[N];
int bz[N][bzmax];
vector<int> G[N];

void cover(SegTreeNode* pa, SegTreeNode*& pb, int l, int r, int ql, int qr, int v) {
	pb = newnode();
	*pb = *pa;
	if ((ql ^ l) || (qr ^ r)) {
		int mid = (l + r) >> 1;
		if (qr <= mid) {
			cover(pa->l, pb->l, l, mid, ql, qr, v);
		} else if (ql > mid) {
			cover(pa->r, pb->r, mid + 1, r, ql, qr, v);
		} else {
			cover(pa->l, pb->l, l, mid, ql, mid, v);
			cover(pa->r, pb->r, mid + 1, r, mid + 1, qr, v);
		}
	} else {
		pb->tg = v;
	}
}
void cover(SegTreeNode* pa, SegTreeNode*& pb, int ql, int qr, int v) {
	vmin(qr, n - 1);
	if (ql <= qr) {
		cover(pa, pb, 0, n - 1, ql, qr, v);
	} else {
		pb = pa;
	}
}

int query(SegTreeNode* p, int l, int r, int idx) {
	if (p == nul)
		return -1;
	int rt = p->tg, cmp = 0;
	if (l ^ r) {
		int mid = (l + r) >> 1;
		if (idx <= mid) {
			cmp = query(p->l, l, mid, idx);
		} else {
			cmp = query(p->r, mid + 1, r, idx);
		}
	}
	return max(rt, cmp);
}
int query(SegTreeNode* p, int idx) {
	return query(p, 0, n - 1, idx);
}

int us[N], vs[N], f1[N], f2[N];

int near[N], near2[N];
boolean can_rest[N];
void dfs(int p, int fa) {
	dep[p] = dep[fa] + 1;
	near[p] = (can_rest[p]) ? (dep[p]) : (N << 1);
	bz[p][0] = fa;
	for (int i = 1; i < bzmax; i++) {
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	}
	for (auto e : G[p]) {
		if (e ^ fa) {
			dfs(e, p);
			vmin(near[p], near[e]);
		}
	}
}

int lca(int u, int v) {
	if (dep[u] < dep[v]) {
		swap(u, v);
	}
	for (int d = dep[u] - dep[v], i = 0; d; d >>= 1, i++) {
		if (d & 1) {
			u = bz[u][i];
		}
	}
	if (u == v)
		return u;
	for (int i = bzmax, x, y; i--; ) {
		x = bz[u][i], y = bz[v][i];
		if (x ^ y) {
			u = x;
			v = y;
		}
	}
	return bz[u][0];
}

void work_near2() {
	queue<int> Q;
	for (int i = 1; i <= n; i++)
		near2[i] = -1;
	for (int i = 1; i <= n; i++) {
		if (can_rest[i]) {
			near2[i] = 0;
			Q.push(i);
		}
	}
	while (!Q.empty()) {
		int p = Q.front();
		Q.pop();
		for (auto e : G[p]) {
			if (near2[e] == -1) {
				near2[e] = near2[p] + 1;
				Q.push(e);
			}
		}
	}
}

typedef class Query {
	public:
		int g, *ans;

		Query(int g, int* ans) : g(g), ans(ans) {	}
} Query;

SegTreeNode* rts[N];
vector<Query> Qs[N];

vector<int> stk;
void solve(int p, int fa) {
	stk.push_back(p);
	int sfa = query(rts[fa], dep[p]);
	sfa = (sfa < 0) ? (p) : (stk[sfa]);
	bz[p][0] = sfa;
	for (int i = 1; i < bzmax; i++)
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	for (auto x : Qs[p]) {
		int q = x.g;
		int dq = dep[q];
		int u = p;
		for (int i = bzmax, t; i--; ) {
			t = bz[u][i];
			if (dep[t] >= dq) {
				u = t;
			}
		}
		*(x.ans) = near[u] - dq;
		if (near[u] - dq + near2[q] <= K) {
			vmin(*(x.ans), near2[q]);
		}
		vmin(*(x.ans), dep[p] - dq);
		if (dep[p] - dq + near2[q] <= K) {
			vmin(*(x.ans), near2[q]);
		}
	}

	int dr = near[p], l = dr - dep[p];
	if (dr < n) {
		cover(rts[fa], rts[p], dr + 1, dr + K - (l << 1), dep[p]);
		sfa = query(rts[fa], dr);
		sfa = (sfa < 0) ? (p) : (stk[sfa]);
		bz[p][0] = sfa;
	} else {
		rts[p] = rts[fa];
		bz[p][0] = p;
	}
	for (int i = 1; i < bzmax; i++)
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	for (auto e : G[p]) {
		if (e ^ fa) {
			solve(e, p);
		}
	}
	stk.pop_back();
}

int main() {
	scanf("%d%d%d", &n, &K, &m);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 1, x; i <= m; i++) {
		scanf("%d", &x);
		can_rest[x] = true;
	}
	dep[0] = -1;
	dfs(1, 0);
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		scanf("%d%d", us + i, vs + i);
		int g = lca(us[i], vs[i]);
		Qs[us[i]].emplace_back(g, f1 + i);
		Qs[vs[i]].emplace_back(g, f2 + i);
	}
	work_near2();
	for (int i = 0; i <= n; i++) {
		rts[i] = nul;
	}
	solve(1, 0);
	for (int i = 1; i <= q; i++) {
		puts((f1[i] + f2[i] <= K) ? ("YES") : ("NO"));
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

// missed charactors / ?

template <typename T>
boolean vmin(T& a, T b) {
	return (a > b) ? (a = b, true) : (false);
}
template <typename T>
boolean vmax(T& a, T b) {
	return (a < b) ? (a = b, true) : (false);
}

template <typename T>
T smax(T x) {
	return x;
}
template <typename T, typename ...K>
T smax(T a, const K &...args) {
	return max(a, smax(args...));
}

template <typename T>
T smin(T x) {
	return x;
}
template <typename T, typename ...K>
T smin(T a, const K &...args) {
	return min(a, smin(args...));
}

// debugging lib

#define VN(x) #x
#define Vmsg(x) VN(x) << " = " << (x)
#define printv(x) cerr << VN(x) << " = " << (x);
#define debug(...) fprintf(stderr, __VA_ARGS__);

template <typename A, typename B>
ostream& operator << (ostream& os, const pair<A, B>& z) {
	os << "(" << z.first << ", " << z.second << ')';
	return os;
}
template <typename T>
ostream& operator << (ostream& os, const vector<T>& a) {
	boolean isfirst = true;
	os << "{";
	for (auto z : a) {
		if (!isfirst) {
			os << ", ";
		}
		os << z;
		isfirst = false;
	}
	os << '}';
	return os;
}

const int N = 2e5 + 5, bzmax = 18;

typedef class SegTreeNode {
	public:
		int tg;
		SegTreeNode *l, *r;

		SegTreeNode() : tg(-1), l(NULL), r(NULL) {	}
		SegTreeNode(SegTreeNode* self) : tg(-1), l(self), r(self) {	}
} SegTreeNode;

SegTreeNode pool[N * 40];
SegTreeNode* top = pool;
SegTreeNode nul (&nul);

#define nul &nul

SegTreeNode* newnode() {
	top->l = top->r = NULL;
	return top++;
}

int n, m, K, q;
int dep[N];
int bz[N][bzmax];
vector<int> G[N];

void cover(SegTreeNode* pa, SegTreeNode*& pb, int l, int r, int ql, int qr, int v) {
	pb = newnode();
	*pb = *pa;
	if ((ql ^ l) || (qr ^ r)) {
		int mid = (l + r) >> 1;
		if (qr <= mid) {
			cover(pa->l, pb->l, l, mid, ql, qr, v);
		} else if (ql > mid) {
			cover(pa->r, pb->r, mid + 1, r, ql, qr, v);
		} else {
			cover(pa->l, pb->l, l, mid, ql, mid, v);
			cover(pa->r, pb->r, mid + 1, r, mid + 1, qr, v);
		}
	} else {
		pb->tg = v;
	}
}
void cover(SegTreeNode* pa, SegTreeNode*& pb, int ql, int qr, int v) {
	vmin(qr, n - 1);
	if (ql <= qr) {
		cover(pa, pb, 0, n - 1, ql, qr, v);
	} else {
		pb = pa;
	}
}

int query(SegTreeNode* p, int l, int r, int idx) {
	if (p == nul)
		return -1;
	int rt = p->tg, cmp = 0;
	if (l ^ r) {
		int mid = (l + r) >> 1;
		if (idx <= mid) {
			cmp = query(p->l, l, mid, idx);
		} else {
			cmp = query(p->r, mid + 1, r, idx);
		}
	}
	return max(rt, cmp);
}
int query(SegTreeNode* p, int idx) {
	return query(p, 0, n - 1, idx);
}

int us[N], vs[N], f1[N], f2[N];

int near[N], near2[N];
boolean can_rest[N];
void dfs(int p, int fa) {
	dep[p] = dep[fa] + 1;
	near[p] = (can_rest[p]) ? (dep[p]) : (N << 1);
	bz[p][0] = fa;
	for (int i = 1; i < bzmax; i++) {
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	}
	for (auto e : G[p]) {
		if (e ^ fa) {
			dfs(e, p);
			vmin(near[p], near[e]);
		}
	}
}

int lca(int u, int v) {
	if (dep[u] < dep[v]) {
		swap(u, v);
	}
	for (int d = dep[u] - dep[v], i = 0; d; d >>= 1, i++) {
		if (d & 1) {
			u = bz[u][i];
		}
	}
	if (u == v)
		return u;
	for (int i = bzmax, x, y; i--; ) {
		x = bz[u][i], y = bz[v][i];
		if (x ^ y) {
			u = x;
			v = y;
		}
	}
	return bz[u][0];
}

void work_near2() {
	queue<int> Q;
	for (int i = 1; i <= n; i++)
		near2[i] = -1;
	for (int i = 1; i <= n; i++) {
		if (can_rest[i]) {
			near2[i] = 0;
			Q.push(i);
		}
	}
	while (!Q.empty()) {
		int p = Q.front();
		Q.pop();
		for (auto e : G[p]) {
			if (near2[e] == -1) {
				near2[e] = near2[p] + 1;
				Q.push(e);
			}
		}
	}
}

typedef class Query {
	public:
		int g, *ans;

		Query(int g, int* ans) : g(g), ans(ans) {	}
} Query;

SegTreeNode* rts[N];
vector<Query> Qs[N];

vector<int> stk;
void solve(int p, int fa) {
	stk.push_back(p);
	int sfa = query(rts[fa], dep[p]);
	sfa = (sfa < 0) ? (p) : (stk[sfa]);
	bz[p][0] = sfa;
	for (int i = 1; i < bzmax; i++)
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	for (auto x : Qs[p]) {
		int q = x.g;
		int dq = dep[q];
		int u = p;
		for (int i = bzmax, t; i--; ) {
			t = bz[u][i];
			if (dep[t] >= dq) {
				u = t;
			}
		}
		*(x.ans) = near[u] - dq;
		if (near[u] - dq + near2[q] <= K) {
			vmin(*(x.ans), near2[q]);
		}
		vmin(*(x.ans), dep[p] - dq);
		if (dep[p] - dq + near2[q] <= K) {
			vmin(*(x.ans), near2[q]);
		}
	}

	int dr = near[p], l = dr - dep[p];
	if (dr < n) {
		cover(rts[fa], rts[p], dr + 1, dr + K - (l << 1), dep[p]);
		sfa = query(rts[fa], dr);
		sfa = (sfa < 0) ? (p) : (stk[sfa]);
		bz[p][0] = sfa;
	} else {
		rts[p] = rts[fa];
		bz[p][0] = p;
	}
	for (int i = 1; i < bzmax; i++)
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	for (auto e : G[p]) {
		if (e ^ fa) {
			solve(e, p);
		}
	}
	stk.pop_back();
}

int main() {
	scanf("%d%d%d", &n, &K, &m);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 1, x; i <= m; i++) {
		scanf("%d", &x);
		can_rest[x] = true;
	}
	dep[0] = -1;
	dfs(1, 0);
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		scanf("%d%d", us + i, vs + i);
		int g = lca(us[i], vs[i]);
		Qs[us[i]].emplace_back(g, f1 + i);
		Qs[vs[i]].emplace_back(g, f2 + i);
	}
	work_near2();
	for (int i = 0; i <= n; i++) {
		rts[i] = nul;
	}
	solve(1, 0);
	for (int i = 1; i <= q; i++) {
		puts((f1[i] + f2[i] <= K) ? ("YES") : ("NO"));
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef bool boolean;

// missed charactors / ?

template <typename T>
boolean vmin(T& a, T b) {
	return (a > b) ? (a = b, true) : (false);
}
template <typename T>
boolean vmax(T& a, T b) {
	return (a < b) ? (a = b, true) : (false);
}

template <typename T>
T smax(T x) {
	return x;
}
template <typename T, typename ...K>
T smax(T a, const K &...args) {
	return max(a, smax(args...));
}

template <typename T>
T smin(T x) {
	return x;
}
template <typename T, typename ...K>
T smin(T a, const K &...args) {
	return min(a, smin(args...));
}

// debugging lib

#define VN(x) #x
#define Vmsg(x) VN(x) << " = " << (x)
#define printv(x) cerr << VN(x) << " = " << (x);
#define debug(...) fprintf(stderr, __VA_ARGS__);

template <typename A, typename B>
ostream& operator << (ostream& os, const pair<A, B>& z) {
	os << "(" << z.first << ", " << z.second << ')';
	return os;
}
template <typename T>
ostream& operator << (ostream& os, const vector<T>& a) {
	boolean isfirst = true;
	os << "{";
	for (auto z : a) {
		if (!isfirst) {
			os << ", ";
		}
		os << z;
		isfirst = false;
	}
	os << '}';
	return os;
}

const int N = 2e5 + 5, bzmax = 18;

typedef class SegTreeNode {
	public:
		int tg;
		SegTreeNode *l, *r;

		SegTreeNode() : tg(-1), l(NULL), r(NULL) {	}
		SegTreeNode(SegTreeNode* self) : tg(-1), l(self), r(self) {	}
} SegTreeNode;

SegTreeNode pool[N * 30];
SegTreeNode* top = pool;
SegTreeNode nul (&nul);

#define nul &nul

SegTreeNode* newnode() {
	top->l = top->r = NULL;
	return top++;
}

int n, m, K, q;
int dep[N];
int bz[N][bzmax];
vector<int> G[N];

void cover(SegTreeNode* pa, SegTreeNode*& pb, int l, int r, int ql, int qr, int v) {
	pb = newnode();
	*pb = *pa;
	if ((ql ^ l) || (qr ^ r)) {
		int mid = (l + r) >> 1;
		if (qr <= mid) {
			cover(pa->l, pb->l, l, mid, ql, qr, v);
		} else if (ql > mid) {
			cover(pa->r, pb->r, mid + 1, r, ql, qr, v);
		} else {
			cover(pa->l, pb->l, l, mid, ql, mid, v);
			cover(pa->r, pb->r, mid + 1, r, mid + 1, qr, v);
		}
	} else {
		pb->tg = v;
	}
}
void cover(SegTreeNode* pa, SegTreeNode*& pb, int ql, int qr, int v) {
	vmin(qr, n - 1);
	if (ql <= qr) {
		cover(pa, pb, 0, n - 1, ql, qr, v);
	} else {
		pb = pa;
	}
}

int query(SegTreeNode* p, int l, int r, int idx) {
	if (p == nul)
		return -1;
	int rt = p->tg, cmp = 0;
	if (l ^ r) {
		int mid = (l + r) >> 1;
		if (idx <= mid) {
			cmp = query(p->l, l, mid, idx);
		} else {
			cmp = query(p->r, mid + 1, r, idx);
		}
	}
	return max(rt, cmp);
}
int query(SegTreeNode* p, int idx) {
	return query(p, 0, n - 1, idx);
}

int us[N], vs[N], f1[N], f2[N];

int near[N], near2[N];
boolean can_rest[N];
void dfs(int p, int fa) {
	dep[p] = dep[fa] + 1;
	near[p] = (can_rest[p]) ? (dep[p]) : (N << 1);
	bz[p][0] = fa;
	for (int i = 1; i < bzmax; i++) {
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	}
	for (auto e : G[p]) {
		if (e ^ fa) {
			dfs(e, p);
			vmin(near[p], near[e]);
		}
	}
}

int lca(int u, int v) {
	if (dep[u] < dep[v]) {
		swap(u, v);
	}
	for (int d = dep[u] - dep[v], i = 0; d; d >>= 1, i++) {
		if (d & 1) {
			u = bz[u][i];
		}
	}
	if (u == v)
		return u;
	for (int i = bzmax, x, y; i--; ) {
		x = bz[u][i], y = bz[v][i];
		if (x ^ y) {
			u = x;
			v = y;
		}
	}
	return bz[u][0];
}

void work_near2() {
	queue<int> Q;
	for (int i = 1; i <= n; i++)
		near2[i] = -1;
	for (int i = 1; i <= n; i++) {
		if (can_rest[i]) {
			near2[i] = 0;
			Q.push(i);
		}
	}
	while (!Q.empty()) {
		int p = Q.front();
		Q.pop();
		for (auto e : G[p]) {
			if (near2[e] == -1) {
				near2[e] = near2[p] + 1;
				Q.push(e);
			}
		}
	}
}

typedef class Query {
	public:
		int g, *ans;

		Query(int g, int* ans) : g(g), ans(ans) {	}
} Query;

SegTreeNode* rts[N];
vector<Query> Qs[N];

vector<int> stk;
void solve(int p, int fa) {
	stk.push_back(p);
	int sfa = query(rts[fa], dep[p]);
	sfa = (sfa < 0) ? (p) : (stk[sfa]);
	bz[p][0] = sfa;
	for (int i = 1; i < bzmax; i++)
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	for (auto x : Qs[p]) {
		int q = x.g;
		int dq = dep[q];
		int u = p;
		for (int i = bzmax, t; i--; ) {
			t = bz[u][i];
			if (dep[t] >= dq) {
				u = t;
			}
		}
		*(x.ans) = near[u] - dq;
		if (near[u] - dq + near2[q] <= K) {
			vmin(*(x.ans), near2[q]);
		}
		vmin(*(x.ans), dep[p] - dq);
		if (dep[p] - dq + near2[q] <= K) {
			vmin(*(x.ans), near2[q]);
		}
	}

	int dr = near[p], l = dr - dep[p];
	if (dr < n) {
		cover(rts[fa], rts[p], dr + 1, dr + K - (l << 1), dep[p]);
		sfa = query(rts[fa], dr);
		sfa = (sfa < 0) ? (p) : (stk[sfa]);
		bz[p][0] = sfa;
	} else {
		rts[p] = rts[fa];
		bz[p][0] = p;
	}
	for (int i = 1; i < bzmax; i++)
		bz[p][i] = bz[bz[p][i - 1]][i - 1];
	for (auto e : G[p]) {
		if (e ^ fa) {
			solve(e, p);
		}
	}
	stk.pop_back();
}

int main() {
	scanf("%d%d%d", &n, &K, &m);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 1, x; i <= m; i++) {
		scanf("%d", &x);
		can_rest[x] = true;
	}
	dep[0] = -1;
	dfs(1, 0);
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		scanf("%d%d", us + i, vs + i);
		int g = lca(us[i], vs[i]);
		Qs[us[i]].emplace_back(g, f1 + i);
		Qs[vs[i]].emplace_back(g, f2 + i);
	}
	work_near2();
	for (int i = 0; i <= n; i++) {
		rts[i] = nul;
	}
	solve(1, 0);
	for (int i = 1; i <= q; i++) {
		puts((f1[i] + f2[i] <= K) ? ("YES") : ("NO"));
	}
	return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define ls id<<1
#define rs id<<1|1
#define mem(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp(a,b) make_pair((a),(b))
using namespace std;
const int inf=0x3f3f3f3f;
const ll mod=1e9+7;
const int N=400050;
int n,k,r;
int f[N];
int Find(int x){return x==f[x]?x:f[x]=Find(f[x]);}
struct edge
{
    int v,nxt;
}e[N<<1];
int head[N],ecnt;
int dis[N],col[N];bool vis[N];
inline void ad(int u,int v)
{
    e[++ecnt].v=v;e[ecnt].nxt=head[u];head[u]=ecnt;
}
int p[N][23],dep[N];
void dfslca(int u,int fa)
{
    for(int i=1;(1<<i)<=dep[u];++i)
        p[u][i]=p[p[u][i-1]][i-1];
    for(int i=head[u];i;i=e[i].nxt)
    {
        int v=e[i].v;
        if(v==fa)continue;
        dep[v]=dep[u]+1;
        p[v][0]=u;
        dfslca(v,u);
    }
}
inline int lca(int x,int y)
{
    if(dep[x]<dep[y])swap(x,y);
    for(int i=19;i>=0;--i)
    {
        if(dep[p[x][i]]>=dep[y])x=p[x][i];
        if(x==y)return x;
    }
    for(int i=19;i>=0;--i)
        if(p[x][i]!=p[y][i])x=p[x][i],y=p[y][i];
    return p[x][0];
}
inline int getdis(int x,int y)
{
    return dep[x]+dep[y]-2*dep[lca(x,y)];
}
queue <int> q;
void bfs()
{
    while(!q.empty())
    {
        int u=q.front();q.pop();
        if(dis[u]>k-1)break;
        for(int i=head[u];i;i=e[i].nxt)
        {
            int v=e[i].v;
            int fx=Find(u),fy=Find(v);
            if(fx!=fy)f[fy]=fx;
            if(dis[v]==dis[0])dis[v]=dis[u]+1,q.push(v);
        }
    }
}
inline int getnode(int x,int step)
{
    for(int i=19;i>=0;--i)
        if(step&(1<<i))x=p[x][i];
    return x;
}
inline int jump(int x,int y,int step)
{
    int z=lca(x,y);
    if(dep[x]-dep[z]>=step)return getnode(x,step);
    int c=step-(dep[x]-dep[z]);
    assert(c<=dep[y]-dep[z]);
    return getnode(y,dep[y]-dep[z]-c);
}

inline bool check(int x,int y)
{
    if(getdis(x,y)<=2*k)return true;
    if(Find(jump(x,y,k))==Find(jump(y,x,k)))return true;
    else return false;
}

int main()
{
    scanf("%d%d%d",&n,&k,&r);
    int now=n;
    for(int i=1;i<n;++i)
    {
        now++;
        int x,y;scanf("%d%d",&x,&y);
        ad(x,now);ad(now,x);
        ad(y,now);ad(now,y);
    }
    for(int i=1;i<N;++i)f[i]=i;
    dfslca(1,0);
    mem(dis,inf);
    for(int i=1;i<=r;++i)
    {
        int x;scanf("%d",&x);
        dis[x]=0;q.push(x);
    }
    bfs();
    int Q;scanf("%d",&Q);
    while(Q--)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        if(check(x,y))puts("YES");
        else puts("NO");
    }
    return 0;
}


#include <algorithm>
#include <cassert>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

namespace IO {
    const int BUFFER_SIZE = 1 << 15;

    char input_buffer[BUFFER_SIZE];
    int input_pos = 0, input_len = 0;

    char output_buffer[BUFFER_SIZE];
    int output_pos = 0;

    char number_buffer[100];
    uint8_t lookup[100];

    void _update_input_buffer() {
        input_len = fread(input_buffer, sizeof(char), BUFFER_SIZE, stdin);
        input_pos = 0;

        if (input_len == 0)
            input_buffer[0] = EOF;
    }

    inline char next_char(bool advance = true) {
        if (input_pos >= input_len)
            _update_input_buffer();

        return input_buffer[advance ? input_pos++ : input_pos];
    }

    inline bool isspace(char c) {
        return (unsigned char) (c - '\t') < 5 || c == ' ';
    }

    template<typename T>
    inline void read_int(T &number) {
        bool negative = false;
        number = 0;

        while (!isdigit(next_char(false)))
            if (next_char() == '-')
                negative = true;

        do {
            number = 10 * number + (next_char() - '0');
        } while (isdigit(next_char(false)));

        if (negative)
            number = -number;
    }

    template<typename T, typename... Args>
    inline void read_int(T &number, Args &... args) {
        read_int(number);
        read_int(args...);
    }

    inline void read_str(string &str) {
        while (isspace(next_char(false)))
            next_char();

        str.clear();

        do {
            str += next_char();
        } while (!isspace(next_char(false)));
    }

    void _flush_output() {
        fwrite(output_buffer, sizeof(char), output_pos, stdout);
        output_pos = 0;
    }

    inline void write_char(char c) {
        if (output_pos == BUFFER_SIZE)
            _flush_output();

        output_buffer[output_pos++] = c;
    }

    template<typename T>
    inline void write_int(T number, char after = '\0') {
        if (number < 0) {
            write_char('-');
            number = -number;
        }

        int length = 0;

        while (number >= 10) {
            uint8_t lookup_value = lookup[number % 100];
            number /= 100;
            number_buffer[length++] = (lookup_value & 15) + '0';
            number_buffer[length++] = (lookup_value >> 4) + '0';
        }

        if (number != 0 || length == 0)
            write_char(number + '0');

        for (int i = length - 1; i >= 0; i--)
            write_char(number_buffer[i]);

        if (after)
            write_char(after);
    }

    inline void write_str(const string &str, char after = '\0') {
        for (char c : str)
            write_char(c);

        if (after)
            write_char(after);
    }

    void init() {
        // Make sure _flush_output() is called at the end of the program.
        bool exit_success = atexit(_flush_output) == 0;
        assert(exit_success);

        for (int i = 0; i < 100; i++)
            lookup[i] = (i / 10 << 4) + i % 10;
    }
}

template<typename T, bool maximum_mode = false>
struct RMQ {
    int n = 0, levels = 0;
    vector<T> values;
    vector<vector<int>> range_low;

    RMQ(const vector<T> &_values = {}) {
        if (!_values.empty())
            build(_values);
    }

    static int largest_bit(int x) {
        return 31 - __builtin_clz(x);
    }

    // Note: when `values[a] == values[b]`, returns b.
    int better_index(int a, int b) const {
        return (maximum_mode ? values[b] < values[a] : values[a] < values[b]) ? a : b;
    }

    void build(const vector<T> &_values) {
        values = _values;
        n = values.size();
        levels = largest_bit(n) + 1;
        range_low.resize(levels);

        for (int k = 0; k < levels; k++)
            range_low[k].resize(n - (1 << k) + 1);

        for (int i = 0; i < n; i++)
            range_low[0][i] = i;

        for (int k = 1; k < levels; k++)
            for (int i = 0; i <= n - (1 << k); i++)
                range_low[k][i] = better_index(range_low[k - 1][i], range_low[k - 1][i + (1 << (k - 1))]);
    }

    // Note: breaks ties by choosing the largest index.
    int query_index(int a, int b) const {
        assert(0 <= a && a < b && b <= n);
        int level = largest_bit(b - a);
        return better_index(range_low[level][a], range_low[level][b - (1 << level)]);
    }

    T query_value(int a, int b) const {
        return values[query_index(a, b)];
    }
};

struct LCA {
    int n = 0;
    vector<vector<int>> adj;
    vector<int> parent, depth, subtree_size;
    vector<int> euler, first_occurrence;
    vector<int> tour_start, tour_end, tour_list, postorder;
    vector<int> heavy_root;
    RMQ<int> rmq;

    LCA(int _n = 0) {
        init(_n);
    }

    // Warning: this does not call build().
    LCA(const vector<vector<int>> &_adj) {
        init(_adj);
    }

    void init(int _n) {
        n = _n;
        adj.assign(n, {});
        parent.resize(n);
        depth.resize(n);
        subtree_size.resize(n);
        first_occurrence.resize(n);
        tour_start.resize(n);
        tour_end.resize(n);
        tour_list.resize(n);
        postorder.resize(n);
        heavy_root.resize(n);
    }

    // Warning: this does not call build().
    void init(const vector<vector<int>> &_adj) {
        init(_adj.size());
        adj = _adj;
    }

    void add_edge(int a, int b) {
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    void dfs(int node, int par) {
        parent[node] = par;
        depth[node] = par < 0 ? 0 : depth[par] + 1;
        subtree_size[node] = 1;

        // Erase the edge to parent.
        if (par >= 0)
            adj[node].erase(find(adj[node].begin(), adj[node].end(), par));

        for (int &child : adj[node]) {
            dfs(child, node);
            subtree_size[node] += subtree_size[child];
        }

        // Heavy-light subtree reordering.
        sort(adj[node].begin(), adj[node].end(), [&](int a, int b) {
            return subtree_size[a] > subtree_size[b];
        });
    }

    int tour, post_tour;

    void tour_dfs(int node, bool heavy) {
        heavy_root[node] = heavy ? heavy_root[parent[node]] : node;
        first_occurrence[node] = euler.size();
        euler.push_back(node);
        tour_list[tour] = node;
        tour_start[node] = tour++;
        bool heavy_child = true;

        for (int child : adj[node]) {
            tour_dfs(child, heavy_child);
            euler.push_back(node);
            heavy_child = false;
        }

        tour_end[node] = tour;
        postorder[node] = post_tour++;
    }

    void build() {
        parent.assign(n, -1);

        for (int i = 0; i < n; i++)
            if (parent[i] < 0)
                dfs(i, -1);

        tour = post_tour = 0;

        for (int i = 0; i < n; i++)
            if (parent[i] < 0) {
                tour_dfs(i, false);
                // Add a -1 in between connected components to help us detect when nodes aren't connected.
                euler.push_back(-1);
            }

        assert((int) euler.size() == 2 * n);
        vector<int> euler_depths;

        for (int node : euler)
            euler_depths.push_back(node < 0 ? node : depth[node]);

        rmq.build(euler_depths);
    }

    pair<int, int> find_farthest(int node, int par, int path) const {
        pair<int, int> current = {path, node};

        for (int neighbor : adj[node])
            if (neighbor != par)
                current = max(current, find_farthest(neighbor, node, path + 1));

        return current;
    }

    // Warning: this must be called before build(), since build() erases half of the edges.
    pair<int, pair<int, int>> get_diameter() const {
        int u = find_farthest(0, -1, 0).second;
        pair<int, int> farthest = find_farthest(u, -1, 0);
        int v = farthest.second;
        return {farthest.first, {u, v}};
    }

    // Note: returns -1 if `a` and `b` aren't connected.
    int get_lca(int a, int b) const {
        a = first_occurrence[a];
        b = first_occurrence[b];

        if (a > b)
            swap(a, b);

        return euler[rmq.query_index(a, b + 1)];
    }

    bool is_ancestor(int a, int b) const {
        return tour_start[a] <= tour_start[b] && tour_start[b] < tour_end[a];
    }

    bool on_path(int x, int a, int b) const {
        return (is_ancestor(x, a) || is_ancestor(x, b)) && is_ancestor(get_lca(a, b), x);
    }

    int get_dist(int a, int b) const {
        return depth[a] + depth[b] - 2 * depth[get_lca(a, b)];
    }

    // Returns the child of `a` that is an ancestor of `b`. Assumes `a` is a strict ancestor of `b`.
    int child_ancestor(int a, int b) const {
        assert(a != b);
        assert(is_ancestor(a, b));

        // Note: this depends on RMQ breaking ties by latest index.
        int child = euler[rmq.query_index(first_occurrence[a], first_occurrence[b] + 1) + 1];
        assert(parent[child] == a);
        assert(is_ancestor(child, b));
        return child;
    }

    int get_kth_ancestor(int a, int k) const {
        while (a >= 0) {
            int root = heavy_root[a];

            if (depth[root] <= depth[a] - k)
                return tour_list[tour_start[a] - k];

            k -= depth[a] - depth[root] + 1;
            a = parent[root];
        }

        return a;
    }

    int get_kth_node_on_path(int a, int b, int k) const {
        int anc = get_lca(a, b);
        int first_half = depth[a] - depth[anc];
        int second_half = depth[b] - depth[anc];
        assert(0 <= k && k <= first_half + second_half);

        if (k < first_half)
            return get_kth_ancestor(a, k);
        else
            return get_kth_ancestor(b, first_half + second_half - k);
    }
};

const int INF = 1e9 + 5;

struct edge {
    int node = -1, weight = -1;

    edge() {}

    edge(int _node, int _weight) : node(_node), weight(_weight) {}
};

int N;
vector<vector<edge>> adj;
vector<int> dist;
vector<int> previous;

void bfs_check(queue<int> &q, queue<int> &next_q, int node, int from, int new_dist, int add) {
    assert(0 <= add && add <= 1);

    if (new_dist < dist[node]) {
        dist[node] = new_dist;
        previous[node] = from;
        (add == 0 ? q : next_q).push(node);
    }
}

void bfs(const vector<int> &source) {
    if (N == 0) return;
    // Two queues are needed for 0-1 BFS.
    queue<int> q, next_q;
    dist.assign(N, INF);
    previous.assign(N, -1);

    for (int src : source)
        bfs_check(q, next_q, src, -1, 0, 0);

    int level = 0;

    while (!q.empty() || !next_q.empty()) {
        while (!q.empty()) {
            int top = q.front(); q.pop();

            if (level > dist[top])
                continue;

            for (edge &e : adj[top])
                bfs_check(q, next_q, e.node, top, dist[top] + e.weight, e.weight);
        }

        swap(q, next_q);
        level++;
    }
}

struct union_find {
    // When data[x] < 0, x is a root and -data[x] is its tree size. When data[x] >= 0, data[x] is x's parent.
    vector<int> data;
    int components = 0;

    union_find(int n = -1) {
        if (n >= 0)
            init(n);
    }

    void init(int n) {
        data.assign(n + 1, -1);
        components = n;
    }

    int find(int x) {
        return data[x] < 0 ? x : data[x] = find(data[x]);
    }

    int get_size(int x) {
        return -data[find(x)];
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);

        if (x == y)
            return false;

        if (-data[x] < -data[y])
            swap(x, y);

        data[x] += data[y];
        data[y] = x;
        components--;
        return true;
    }
};

int K, R, V;
vector<pair<int, int>> edges;
vector<int> rests;
LCA lca;
union_find UF;

bool query(int a, int b) {
    if (lca.get_dist(a, b) <= K)
        return true;

    int jump_a = lca.get_kth_node_on_path(a, b, (K + 1) / 2);
    int jump_b = lca.get_kth_node_on_path(b, a, (K + 1) / 2);

    if (dist[jump_a] > K / 2 || dist[jump_b] > K / 2)
        return false;

    return UF.find(jump_a) == UF.find(jump_b);
}

int main() {
    IO::init();
    IO::read_int(N, K, R);
    lca.init(N);
    adj.assign(N, {});

    for (int i = 0; i < N - 1; i++) {
        int x, y;
        IO::read_int(x, y);
        x--; y--;
        lca.add_edge(x, y);
        adj[x].emplace_back(y, 1);
        adj[y].emplace_back(x, 1);
        edges.emplace_back(x, y);
    }

    lca.build();
    rests.resize(R);

    for (int &rest : rests) {
        IO::read_int(rest);
        rest--;
    }

    bfs(rests);
    UF.init(N);

    for (pair<int, int> &e : edges)
        if (dist[e.first] + 1 + dist[e.second] <= K)
            UF.unite(e.first, e.second);

    IO::read_int(V);

    for (int v = 0; v < V; v++) {
        int a, b;
        IO::read_int(a, b);
        a--; b--;
        IO::write_str(query(a, b) ? "YES" : "NO", '\n');
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10, K = 20;
vector<int> g[N];
int par[N][K],dep[N],f[N],d[N],col[N];
void dfs(int u,int p){
    par[u][0] = p;
    for(int i=1;i<K;i++) par[u][i] = par[par[u][i-1]][i-1];
    for(int v: g[u]) if(v!=p) dep[v] = dep[u] + 1, dfs(v,u);
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=0;i<K;i++) if((dep[u]-dep[v])>>i&1) u = par[u][i];
    if(u==v) return u;
    for(int i=K-1;i>=0;i--) if(par[u][i]!=par[v][i]) u = par[u][i], v = par[v][i];
    return par[u][0];
}
int dis(int u,int v){
    return dep[u] + dep[v] - 2 * dep[lca(u,v)];
}
int jump(int u,int k){
    for(int i=0;i<K;i++) if(k>>i&1) u = par[u][i];
    return u;
}
int jump(int u,int v,int k){
    if(dep[u]<dep[v]) return jump(v,u,dis(u,v)-k);
    int p = lca(u,v);
    if(p==v||k<=dep[u]-dep[p]) return jump(u,k);
    return jump(p,v,k-dep[u]+dep[p]);
}
int find(int x){
    if(x==f[x]) return x;
    return f[x] = find(f[x]);
}
void unite(int x,int y){
    f[find(x)] = find(y);
}
int main(){
    ios::sync_with_stdio(0);
    int n,k,r; cin>>n>>k>>r;
    for(int i=1;i<n;i++){
        int u,v; cin>>u>>v;
        g[u].push_back(v), g[v].push_back(u);
    }
    dfs(1,0);
    vector<int> v(r);
    for(int i=0;i<r;i++) cin>>v[i];
    queue<int> q;
    for(int i: v) q.push(i), col[i] = i, f[i] = i;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v: g[u]){
            if(!col[v]&&d[u]+1<=k/2){
                d[v] = d[u] + 1;
                col[v] = col[u];
                q.push(v);
            }
            else if(d[u]+d[v]<=k){
                unite(col[u],col[v]);
            }
        }
    }
    int m; cin>>m;
    while(m--){
        int x,y; cin>>x>>y;
        if(dis(x,y)<=k) cout<<"YES"<<endl;
        else{
            int u = jump(x,y,(k+1)/2) , v = jump(y,x,(k+1)/2);
            if(col[u]&&col[v]&&find(col[u])==find(col[v])) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10, K = 20;
vector<int> g[N];
int par[N][K],dep[N],f[N],d[N],col[N];
void dfs(int u,int p){
    par[u][0] = p;
    for(int i=1;i<K;i++) par[u][i] = par[par[u][i-1]][i-1];
    for(int v: g[u]) if(v!=p) dep[v] = dep[u] + 1, dfs(v,u);
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=0;i<K;i++) if((dep[u]-dep[v])>>i&1) u = par[u][i];
    if(u==v) return u;
    for(int i=K-1;i>=0;i--) if(par[u][i]!=par[v][i]) u = par[u][i], v = par[v][i];
    return par[u][0];
}
int dis(int u,int v){
    return dep[u] + dep[v] - 2 * dep[lca(u,v)];
}
int jump(int u,int k){
    for(int i=0;i<K;i++) if(k>>i&1) u = par[u][i];
    return u;
}
int jump(int u,int v,int k){
    if(dep[u]<dep[v]) return jump(v,u,dis(u,v)-k);
    int p = lca(u,v);
    if(p==v||k<=dep[u]-dep[p]) return jump(u,k);
    return jump(p,v,k-dep[u]+dep[p]);
}
int find(int x){
    if(x==f[x]) return x;
    return f[x] = find(f[x]);
}
void unite(int x,int y){
    f[find(x)] = find(y);
}
int main(){
    ios::sync_with_stdio(0);
    int n,k,r; cin>>n>>k>>r;
    for(int i=1;i<n;i++){
        int u,v; cin>>u>>v;
        g[u].push_back(v), g[v].push_back(u);
    }
    dfs(1,0);
    vector<int> v(r);
    for(int i=0;i<r;i++) cin>>v[i];
    queue<int> q;
    for(int i: v) q.push(i), col[i] = i, f[i] = i;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v: g[u]){
            if(!col[v]&&d[u]+1<=k/2){
                d[v] = d[u] + 1;
                col[v] = col[u];
                q.push(v);
            }
            else if(d[u]+d[v]<=k){
                unite(col[u],col[v]);
            }
        }
    }
    int m; cin>>m;
    while(m--){
        int x,y; cin>>x>>y;
        if(dis(x,y)<=k) cout<<"YES"<<endl;
        else{
            int u = jump(x,y,(k+1)/2) , v = jump(y,x,k-(k+1)/2);
            if(col[u]&&col[v]&&find(col[u])==find(col[v])) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10, K = 20;
vector<int> g[N];
int par[N][K],dep[N],f[N],d[N],col[N];
void dfs(int u,int p){
    par[u][0] = p;
    for(int i=1;i<K;i++) par[u][i] = par[par[u][i-1]][i-1];
    for(int v: g[u]) if(v!=p) dep[v] = dep[u] + 1, dfs(v,u);
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=0;i<K;i++) if((dep[u]-dep[v])>>i&1) u = par[u][i];
    if(u==v) return u;
    for(int i=K-1;i>=0;i--) if(par[u][i]!=par[v][i]) u = par[u][i], v = par[v][i];
    return par[u][0];
}
int dis(int u,int v){
    return dep[u] + dep[v] - 2 * dep[lca(u,v)];
}
int jump(int u,int k){
    for(int i=0;i<K;i++) if(k>>i&1) u = par[u][i];
    return u;
}
int jump(int u,int v,int k){
    int p = lca(u,v);
    if(k<=dep[u]-dep[p]) return jump(u,k);
    return jump(v,u,dis(u,v)-k);
}
int find(int x){
    if(x==f[x]) return x;
    return f[x] = find(f[x]);
}
void unite(int x,int y){
    f[find(x)] = find(y);
}
int main(){
    ios::sync_with_stdio(0);
    int n,k,r; cin>>n>>k>>r;
    for(int i=1;i<n;i++){
        int u,v; cin>>u>>v;
        g[u].push_back(v), g[v].push_back(u);
    }
    dfs(1,0);
    vector<int> v(r);
    for(int i=0;i<r;i++) cin>>v[i];
    queue<int> q;
    for(int i: v) q.push(i), col[i] = i, f[i] = i;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v: g[u]){
            if(!col[v]&&d[u]+1<=k/2){
                d[v] = d[u] + 1;
                col[v] = col[u];
                q.push(v);
            }
            if(col[v]&&d[u]+d[v]+1<=k){
                unite(col[u],col[v]);
            }
        }
    }
    int m; cin>>m;
    while(m--){
        int x,y; cin>>x>>y;
        if(dis(x,y)<=k) cout<<"YES"<<endl;
        else{
            int u = jump(x,y,(k+1)/2) , v = jump(y,x,(k+1)/2);
            if(col[u]&&col[v]&&find(col[u])==find(col[v])) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10, K = 20;
vector<int> g[N];
int par[N][K],dep[N],f[N],d[N],col[N];
void dfs(int u,int p){
    par[u][0] = p;
    for(int i=1;i<K;i++) par[u][i] = par[par[u][i-1]][i-1];
    for(int v: g[u]) if(v!=p) dep[v] = dep[u] + 1, dfs(v,u);
}
int lca(int u,int v){
    if(dep[u]<dep[v]) swap(u,v);
    for(int i=0;i<K;i++) if((dep[u]-dep[v])>>i&1) u = par[u][i];
    if(u==v) return u;
    for(int i=K-1;i>=0;i--) if(par[u][i]!=par[v][i]) u = par[u][i], v = par[v][i];
    return par[u][0];
}
int dis(int u,int v){
    return dep[u] + dep[v] - 2 * dep[lca(u,v)];
}
int jump(int u,int k){
    for(int i=0;i<K;i++) if(k>>i&1) u = par[u][i];
    return u;
}
int jump(int u,int v,int k){
    int p = lca(u,v);
    if(k<=dep[u]-dep[p]) return jump(u,k);
    return jump(v,u,dis(u,v)-k);
}
int find(int x){
    if(x==f[x]) return x;
    return f[x] = find(f[x]);
}
void unite(int x,int y){
    f[find(x)] = find(y);
}
int main(){
    ios::sync_with_stdio(0);
    int n,k,r; cin>>n>>k>>r;
    for(int i=1;i<n;i++){
        int u,v; cin>>u>>v;
        g[u].push_back(v), g[v].push_back(u);
    }
    dfs(1,0);
    vector<int> v(r);
    for(int i=0;i<r;i++) cin>>v[i];
    queue<int> q;
    for(int i: v) q.push(i), col[i] = i, f[i] = i;
    while(!q.empty()){
        int u = q.front(); q.pop();
        for(int v: g[u]){
            if(!col[v]&&d[u]+1<=k/2){
                d[v] = d[u] + 1;
                col[v] = col[u];
                q.push(v);
            }
            else if(d[u]+d[v]+1<=k){
                unite(col[u],col[v]);
            }
        }
    }
    int m; cin>>m;
    while(m--){
        int x,y; cin>>x>>y;
        if(dis(x,y)<=k) cout<<"YES"<<endl;
        else{
            int u = jump(x,y,(k+1)/2) , v = jump(y,x,(k+1)/2);
            if(col[u]&&col[v]&&find(col[u])==find(col[v])) cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
        }
    }
}


#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=200000+100;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int getinv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	void math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=getinv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;
struct node{int to,nxt;}sq[N<<2];
int all=0,head[N<<1];
int n,k,r,dis[N<<1],dep[N<<1],fa[N<<1][20],Fa[N<<1];
queue<int> q;

void addedge(int u,int v)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

int find(int x)
{
	if (Fa[x]==x) return x;
	Fa[x]=find(Fa[x]);
	return Fa[x];
}

int merge(int x,int y)
{
	int fx=find(x),fy=find(y);
	if (fx!=fy) Fa[fx]=fy;
}

void bfs()
{
	memset(dis,-1,sizeof(dis));
	rep(i,1,r)
	{
		int x=read();
		q.push(x);dis[x]=0;
	}
	rep(i,1,n<<1) Fa[i]=i;
	while (!q.empty())
	{
		int u=q.front();q.pop();
		if (dis[u]>=k) break;
		go(u,i)
		{
			merge(u,v);
			if (dis[v]==-1)
			{
				dis[v]=dis[u]+1;q.push(v);
			}
		}
	}
}

void dfs(int u,int fu)
{
	fa[u][0]=fu;dep[u]=dep[fu]+1;
	rep(i,1,19)
		fa[u][i]=fa[fa[u][i-1]][i-1];
	go(u,i)
	{
		if (v==fu) continue;
		dfs(v,u);
	}
}

int getlca(int u,int v)
{
	if (dep[u]<dep[v]) swap(u,v);
	int tmp=dep[u]-dep[v];
	per(i,19,0)
		if ((tmp>>i)&1) u=fa[u][i];
	if (u==v) return u;
	per(i,19,0)
		if (fa[u][i]!=fa[v][i])
		{
			u=fa[u][i];v=fa[v][i];
		}
	return fa[u][0];
}

int up(int u,int d)
{
	per(i,19,0)
		if ((d>>i)&1) u=fa[u][i];
	return u;
}

int getp(int u,int v,int lca,int k)
{
	if (dep[u]-dep[lca]>=k) return up(u,k);
	else
	{
		int d=k-(dep[u]-dep[lca]);
		return up(v,dep[v]-dep[lca]-d);
	}
}

int query(int u,int v)
{
	int w=getlca(u,v);
	if (dep[u]+dep[v]-dep[w]*2<=k*2) return 1;
	int u1=getp(u,v,w,k),v1=getp(v,u,w,k);
	return (find(u1)==find(v1));
}

int main()
{
	n=read();k=read();r=read();
	rep(i,1,n-1)
	{
		int u=read(),v=read();
		addedge(u,n+i);addedge(n+i,u);
		addedge(v,n+i);addedge(n+i,v);
	}
	bfs();dfs(1,0);
	int q=read();
	while (q--)
	{
		int u=read(),v=read();
		if (query(u,v)) puts("YES");else puts("NO");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+100;

int F[N],fa[N][20];
vector<int>G[N];
int dep[N];

int find(int x)
{
	return x==F[x]?x:F[x]=find(F[x]);
}

void dfs(int x,int F)
{
	for(int i=1;i<=19;i++)  fa[x][i]=fa[fa[x][i-1]][i-1];
	for(auto it:G[x])
	{
		if(it==F) continue;
		dep[it]=dep[x]+1;
		fa[it][0]=x;
		dfs(it,x);
	}
}
int cal(int x,int y)
{
	for(int i=0;i<=19;i++) if((y)>>i&1) x=fa[x][i];
	return x;
}
int LCA(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=19;i>=0;i--) if((dep[x]-dep[y])>>i&1) x=fa[x][i];
	if(x==y) return x;
	for(int i=19;i>=0;i--)
	{
		if(fa[x][i]!=fa[y][i])
		{
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
int d[N],b[N];
int main()
{
	//ios::sync_with_stdio(false);
	int n,k,r;
	cin>>n>>k>>r;
	for(int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		G[x].push_back(i+n);
		G[i+n].push_back(x);
		G[y].push_back(i+n);
		G[i+n].push_back(y);
	}
	for(int i=1;i<=2*n;i++) F[i]=i,d[i]=-1,b[i]=0;
	dfs(1,0);
	queue<int>q;
	while(q.size()) q.pop();
	for(int i=1;i<=r;i++)
	{
		int x;
		scanf("%d",&x);
		d[x]=0;
		b[x]=x;
		q.push(x);
	}
	while(q.size())//预处理
	{
		int t=q.front();
		q.pop();
		if(d[t]==k) break;
		for(auto it:G[t])
		{
			if(d[it]==-1)
			{
				d[it]=d[t]+1;
				b[it]=b[t];
				q.push(it);
			}
			else if(d[t]+1<=k)
			{
				F[find(b[t])]=find(b[it]);//集合中任意两点都可到
			}
		}
	}
	int  m;
	cin>>m;
	while(m--)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		int z=LCA(x,y);
		int dis=dep[x]+dep[y]-2*dep[z];
		if(dis<=2*k)
		{
			puts("YES");
			continue;
		}
		int u=dep[x]-dep[z]>=k?cal(x,k):cal(y,dis-k);
		int v=dep[y]-dep[z]>=k?cal(y,k):cal(x,dis-k);
		if(b[u]&&b[v]&&find(b[v])==find(b[u])) puts("YES");
		else puts("NO");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+100;

int F[N],fa[N][20];
vector<int>G[N];
int dep[N];

int find(int x)
{
	return x==F[x]?x:F[x]=find(F[x]);
}

void dfs(int x,int F)
{
	for(int i=1;i<=19;i++)  fa[x][i]=fa[fa[x][i-1]][i-1];
	for(auto it:G[x])
	{
		if(it==F) continue;
		dep[it]=dep[x]+1;
		fa[it][0]=x;
		dfs(it,x);
	}
}
int cal(int x,int y)
{
	for(int i=0;i<=19;i++) if((y)>>i&1) x=fa[x][i];
	return x;
}
int LCA(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=19;i>=0;i++) if((dep[x]-dep[y])>>i&1) x=fa[x][i];
	if(x==y) return x;
	for(int i=19;i>=0;i--)
	{
		if(fa[x][i]!=fa[y][i])
		{
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
int d[N],b[N];
int main()
{
	int n,k,r;
	cin>>n>>k>>r;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		G[x].push_back(i+n);
		G[i+n].push_back(x);
		G[y].push_back(i+n);
		G[i+n].push_back(y);
	}
	for(int i=1;i<=2*n;i++) F[i]=i,d[i]=-1,b[i]=0;
	dfs(1,0);
	queue<int>q;
	while(q.size()) q.pop();
	for(int i=1;i<=r;i++)
	{
		int x;
		cin>>x;
		d[x]=0;
		b[x]=x;
		q.push(x);
	}
	while(q.size())//预处理
	{
		int t=q.front();
		q.pop();
		if(d[t]==k) break;
		for(auto it:G[t])
		{
			if(d[it]==-1)
			{
				d[it]=d[t]+1;
				b[it]=b[t];
				q.push(it);
			}
			else if(d[t]+1<=k)
			{
				F[find(b[t])]=find(b[it]);//集合中任意两点都可到
			}
		}
	}
	int  m;
	cin>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		int z=LCA(x,y);
		int dis=dep[x]+dep[y]-2*dep[z];
		if(dis<=2*k)
		{
			cout<<"YES"<<endl;
			continue;
		}
		int u=dep[x]-dep[z]>=k?cal(x,k):cal(y,dis-k);
		int v=dep[y]-dep[z]>=k?cal(y,k):cal(x,dis-k);
		if(b[u]&&b[v]&&find(b[v])==find(b[u])) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+100;

int F[N],fa[N][20];
vector<int>G[N];
int dep[N];

int find(int x)
{
	return x==F[x]?x:F[x]=find(F[x]);
}

void dfs(int x,int F)
{
	for(int i=1;i<=19;i++)  fa[x][i]=fa[fa[x][i-1]][i-1];
	for(auto it:G[x])
	{
		if(it==F) continue;
		dep[it]=dep[x]+1;
		fa[it][0]=x;
		dfs(it,x);
	}
}
int cal(int x,int y)
{
	for(int i=0;i<=19;i++) if((y)>>i&1) x=fa[x][i];
	return x;
}
int LCA(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	if(x==y) return x;
	for(int i=0;i<=19;i++) if((dep[x]-dep[y])>>i&1) x=fa[x][i];
	for(int i=19;i>=0;i--)
	{
		if(fa[x][i]!=fa[y][i])
		{
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
int d[N],b[N];
int main()
{
	int n,k,r;
	cin>>n>>k>>r;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		G[x].push_back(i+n);
		G[i+n].push_back(x);
		G[y].push_back(i+n);
		G[i+n].push_back(y);
	}
	for(int i=1;i<=2*n;i++) F[i]=i,d[i]=-1,b[i]=0;
	dfs(1,0);
	queue<int>q;
	while(q.size()) q.pop();
	for(int i=1;i<=r;i++)
	{
		int x;
		cin>>x;
		d[x]=0;
		b[x]=x;
		q.push(x);
	}
	while(q.size())//预处理
	{
		int t=q.front();
		q.pop();
		if(d[t]==k) break;
		for(auto it:G[t])
		{
			if(d[it]==-1)
			{
				d[it]=d[t]+1;
				b[it]=b[t];
				q.push(it);
			}
			else if(d[t]+1<=k)
			{
				F[find(b[t])]=find(b[it]);//集合中任意两点都可到
			}
		}
	}
	int  m;
	cin>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		int z=LCA(x,y);
		int dis=dep[x]+dep[y]-2*dep[z];
		if(dis<=2*k)
		{
			cout<<"YES"<<endl;
			continue;
		}
		int u=dep[x]-dep[z]>=k?cal(x,k):cal(y,dis-k);
		int v=dep[y]-dep[z]>=k?cal(y,k):cal(x,dis-k);
		if(b[u]&&b[v]&&find(b[v])==find(b[u])) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+100;

int F[N],fa[N][20];
vector<int>G[N];
int dep[N];

int find(int x)
{
	return x==F[x]?x:F[x]=find(F[x]);
}

void dfs(int x,int F)
{
	for(int i=1;i<=19;i++)  fa[x][i]=fa[fa[x][i-1]][i-1];
	for(auto it:G[x])
	{
		if(it==F) continue;
		dep[it]=dep[x]+1;
		fa[it][0]=x;
		dfs(it,x);
	}
}
int cal(int x,int y)
{
	for(int i=0;i<=19;i++) if((y)>>i&1) x=fa[x][i];
	return x;
}
int LCA(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=19;i>=0;i--) if((dep[x]-dep[y])>>i&1) x=fa[x][i];
	if(x==y) return x;
	for(int i=19;i>=0;i--)
	{
		if(fa[x][i]!=fa[y][i])
		{
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
int d[N],b[N];
int main()
{
	//ios::sync_with_stdio(false);
	int n,k,r;
	cin>>n>>k>>r;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		G[x].push_back(i+n);
		G[i+n].push_back(x);
		G[y].push_back(i+n);
		G[i+n].push_back(y);
	}
	for(int i=1;i<=2*n;i++) F[i]=i,d[i]=-1,b[i]=0;
	dfs(1,0);
	queue<int>q;
	while(q.size()) q.pop();
	for(int i=1;i<=r;i++)
	{
		int x;
		cin>>x;
		d[x]=0;
		b[x]=x;
		q.push(x);
	}
	while(q.size())//预处理
	{
		int t=q.front();
		q.pop();
		if(d[t]==k) break;
		for(auto it:G[t])
		{
			if(d[it]==-1)
			{
				d[it]=d[t]+1;
				b[it]=b[t];
				q.push(it);
			}
			else if(d[t]+1<=k)
			{
				F[find(b[t])]=find(b[it]);//集合中任意两点都可到
			}
		}
	}
	int  m;
	cin>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		int z=LCA(x,y);
		int dis=dep[x]+dep[y]-2*dep[z];
		if(dis<=2*k)
		{
			puts("YES");
			continue;
		}
		int u=dep[x]-dep[z]>=k?cal(x,k):cal(y,dis-k);
		int v=dep[y]-dep[z]>=k?cal(y,k):cal(x,dis-k);
		if(b[u]&&b[v]&&find(b[v])==find(b[u])) puts("YES");
		else puts("NO");
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
const int N=4e5+100;

int F[N],fa[N][20];
vector<int>G[N];
int dep[N];

int find(int x)
{
	return x==F[x]?x:F[x]=find(F[x]);
}

void dfs(int x,int F)
{
	for(int i=1;i<=19;i++)  fa[x][i]=fa[fa[x][i-1]][i-1];
	for(auto it:G[x])
	{
		if(it==F) continue;
		dep[it]=dep[x]+1;
		fa[it][0]=x;
		dfs(it,x);
	}
}
int cal(int x,int y)
{
	for(int i=0;i<=19;i++) if((y)>>i&1) x=fa[x][i];
	return x;
}
int LCA(int x,int y)
{
	if(dep[x]<dep[y]) swap(x,y);
	for(int i=19;i>=0;i--) if((dep[x]-dep[y])>>i&1) x=fa[x][i];
	if(x==y) return x;
	for(int i=19;i>=0;i--)
	{
		if(fa[x][i]!=fa[y][i])
		{
			x=fa[x][i];
			y=fa[y][i];
		}
	}
	return fa[x][0];
}
int d[N],b[N];
int main()
{
	int n,k,r;
	cin>>n>>k>>r;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		G[x].push_back(i+n);
		G[i+n].push_back(x);
		G[y].push_back(i+n);
		G[i+n].push_back(y);
	}
	for(int i=1;i<=2*n;i++) F[i]=i,d[i]=-1,b[i]=0;
	dfs(1,0);
	queue<int>q;
	while(q.size()) q.pop();
	for(int i=1;i<=r;i++)
	{
		int x;
		cin>>x;
		d[x]=0;
		b[x]=x;
		q.push(x);
	}
	while(q.size())//预处理
	{
		int t=q.front();
		q.pop();
		if(d[t]==k) break;
		for(auto it:G[t])
		{
			if(d[it]==-1)
			{
				d[it]=d[t]+1;
				b[it]=b[t];
				q.push(it);
			}
			else if(d[t]+1<=k)
			{
				F[find(b[t])]=find(b[it]);//集合中任意两点都可到
			}
		}
	}
	int  m;
	cin>>m;
	while(m--)
	{
		int x,y;
		cin>>x>>y;
		int z=LCA(x,y);
		int dis=dep[x]+dep[y]-2*dep[z];
		if(dis<=2*k)
		{
			cout<<"YES"<<endl;
			continue;
		}
		int u=dep[x]-dep[z]>=k?cal(x,k):cal(y,dis-k);
		int v=dep[y]-dep[z]>=k?cal(y,k):cal(x,dis-k);
		if(b[u]&&b[v]&&find(b[v])==find(b[u])) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
	return 0;
}


#include<stdio.h>
#define it register int
#define ct const int
#define il inline
using namespace std;
const int N=1050005;
int h[N],nxt[N],adj[N],n,m,k,u,v,t,fa[N],d[N],q[N],top1,top2,ds[N],dis,top[N],son[N],lc,Fa[N][22],f[N],Q,sz[N];
bool inq[N];
il void add(ct u,ct v){nxt[++t]=h[u],h[u]=t,adj[t]=v,nxt[++t]=h[v],h[v]=t,adj[t]=u;}
il void DFS(ct x){
	d[x]=d[fa[x]]+1,sz[x]=1;
	for(it i=1;i<=20;++i) Fa[x][i]=Fa[Fa[x][i-1]][i-1];
	for(it i=h[x],j;i;i=nxt[i])
		if((j=adj[i])^fa[x]) Fa[j][0]=fa[j]=x,DFS(j),sz[x]+=sz[j],son[x]=(sz[j]>sz[son[x]]?j:son[x]);
}
il void dfs(ct x){
	if(!top[x]) top[x]=x;
	if(!son[x]) return;
	top[son[x]]=top[x],dfs(son[x]);
	for(it i=h[x],j;i;i=nxt[i])
		if((adj[i]^fa[x])&&(adj[i]^son[x])) dfs(adj[i]);
}
il void lca(it p,it q){
	while(top[p]^top[q])
		d[top[p]]<d[top[q]]?q=fa[top[q]]:p=fa[top[p]];
	lc=(d[p]<d[q]?p:q);
}
il int fd(ct x){return f[x]==x?x:f[x]=fd(f[x]);}
il void mer(it u,it v){
	u=fd(u),v=fd(v);
	if(u^v) f[v]=u;
}
il void bfs(){
	it top,i,j;
	while(top1<top2){
		top=q[++top1];
		if(ds[top]>=k) break;
		for(i=h[top];i;i=nxt[i]){
			mer(top,j=adj[i]);
			if(!inq[j]) inq[j]=1,ds[j]=ds[top]+1,q[++top2]=j;
		}
	}
}
il int jump(it u,ct ds){
	for(it i=0;i<=20;++i)
		if(ds&(1<<i)) u=Fa[u][i];
	return u;
}
il int walk(ct u,ct v,ct lc,ct dep){return dep<=d[u]-d[lc]?jump(u,dep):jump(v,dis-dep);}
int main(){
	scanf("%d%d%d",&n,&k,&m);it i;ct k2=k<<1;
	for(i=1;i<n;++i) scanf("%d%d",&u,&v),add(u,n+i),add(v,n+i);
	for(i=1;i<=n;++i) f[i]=i,f[n+i]=n+i;
	for(i=1;i<=m;++i) scanf("%d",&u),q[++top2]=u,inq[u]=1;
	DFS(1),dfs(1),bfs();
	scanf("%d",&Q);
	while(Q--){
		scanf("%d%d",&u,&v),lca(u,v),dis=d[u]+d[v]-(d[lc]<<1);
		if(dis<=k2){puts("YES");continue;}
		fd(walk(u,v,lc,k))^fd(walk(v,u,lc,k))?puts("NO"):puts("YES");
	}
    return 0;
}


    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    #include <math.h>
    #include <time.h>
    #include <iostream>
    #include <algorithm>
    #include <iomanip>
    #include <fstream>
    #include <vector>
    #include <bitset>
    #include <queue>
    #include <stack>
    #include <map>
    #include <set>

    using namespace std;

    const int MAXN = 400005;

    struct Edge
    {
    	int to;
    	int nxt;
    }edge[MAXN << 1];

    int n,m,L,q,a,b,id;
    int first[MAXN];
    int dis[MAXN];
    int pre[MAXN];
    int depth[MAXN];
    int tag[MAXN];
    int fa[MAXN][19];

    queue<pair<int,int> > Q;

    int getroot(int u)
    {
    	return u == pre[u] ? u : pre[u] = getroot(pre[u]);
    }

    void addE(int u,int v)
    {
    	edge[++id] = (Edge){v,first[u]};
    	first[u] = id;
    }

    void merge(int u,int v)
    {
    	pre[getroot(u)] = getroot(v);
    }

    void dfs(int u)
    {
    	for (int i = 1;i <= 18;i++)
    		fa[u][i] = fa[fa[u][i - 1]][i - 1];
    	for (int i = first[u];i;i = edge[i].nxt)
    		if (edge[i].to != fa[u][0])
    		{
    			depth[edge[i].to] = depth[u] + 1;
    			fa[edge[i].to][0] = u;
    			dfs(edge[i].to);
    		}
    }

    int getup(int u,int x)
    {
    	for (int i = 18;i >= 0;i--)
    		if (x >> i & 1)
    			u = fa[u][i];
    	return u;
    }

    int getlca(int u,int v)
    {
    	if (depth[u] < depth[v])
    		swap(u,v);
    	u = getup(u,depth[u] - depth[v]);
    	if (u == v)
    		return u;
    	for (int i = 18;i >= 0;i--)
    		if (fa[u][i] != fa[v][i])
    		{
    			u = fa[u][i];
    			v = fa[v][i];
    		}
    	return fa[u][0];
    }

    int main()
    {
    	scanf("%d%d%d",&n,&L,&m);
    	for (int u,v,i = 1;i < n;i++)
    	{
    		scanf("%d%d",&u,&v);
    		addE(u,i + n);
    		addE(i + n,u);
    		addE(v,i + n);
    		addE(i + n,v);
    	}
    	dfs(1);
    	memset(dis,-1,sizeof(dis));
    	for (int a,i = 1;i <= m;i++)
    	{
    		scanf("%d",&a);
    		dis[a] = 0;
    		pre[a] = a;
    		tag[a] = a;
    		Q.push(make_pair(a,a));
    	}
    	while (!Q.empty())
    	{
    		int u = Q.front().first,ori = Q.front().second;
    		Q.pop();
    		if (dis[u] == L)
    			break;
    		for (int i = first[u];i;i = edge[i].nxt)
    		{
    			if (tag[edge[i].to])
    			{
    				merge(ori,tag[edge[i].to]);
    				continue;
    			}
    			tag[edge[i].to] = ori;
    			dis[edge[i].to] = dis[u] + 1;
    			Q.push(make_pair(edge[i].to,ori));
    		}
    	}
    	scanf("%d",&q);
    	while (q--)
    	{
    		scanf("%d%d",&a,&b);
    		int lca = getlca(a,b),ds = depth[a] + depth[b] - 2 * depth[lca];
    		if (ds <= 2 * L)
    		{
    			puts("YES");
    			continue;
    		}
    		int A,B;
    		if (depth[a] - depth[lca] >= L)
    			A = getup(a,L);
    		else
    			A = getup(b,ds - L);
    		if (depth[b] - depth[lca] >= L)
    			B = getup(b,L);
    		else
    			B = getup(a,ds - L);
    		if (tag[A] && tag[B] && getroot(tag[A]) == getroot(tag[B]))
    			puts("YES");
    		else
    			puts("NO");
    	}
    	return 0;
    }


#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define ri register int
using namespace std;
#define y2 cyktxdy
typedef long long ll;
typedef vector<int> poly;
typedef vector<ll> Poly;
typedef pair<int,int> pii;
#define pb push_back
#define fi first
#define se second
const int rlen=1<<18|1,inf=0x3f3f3f3f;
const ll Inf=1e18;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline ll readl() {
  ll ans=0;
  bool f=1;
  char ch=gc();
  while(!isdigit(ch)) f^=ch=='-',ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return f?ans:-ans;
}
inline int Read(char*s) {
  int top=0;
  char ch=gc();
  while(!isalpha(ch)&&!isdigit(ch)) ch=gc();
  while(isalpha(ch)||isdigit(ch)) s[++top]=ch,ch=gc();
  return top;
}
namespace modular {
  const int mod=1e9+7;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
}
using namespace modular;
template<typename T>inline void ckmax(T&a,T b) { a<b?a=b:0; }
template<typename T>inline void ckmin(T&a,T b) { a>b?a=b:0; }
template<typename T>inline T gcd(T a,T b) { T t;while(b) t=a,a=b,b=t-t/a*a;return a; }
const int N=4e5+5;
vector<int>e[N];
int n,m,r,st[N][20],dep[N];
void dfs(int p) {
  for(ri i=1;i<20;++i) st[p][i]=st[st[p][i-1]][i-1];
  for(ri i=0,v;i<(int)e[p].size();++i) {
    if((v=e[p][i])==st[p][0]) continue;
    st[v][0]=p,dep[v]=dep[p]+1,dfs(v);
  }
}
inline int getanc(int x,int d) {
  for(ri i=19;~i;--i) if(d>>i&1) x=st[x][i];
  return x;
}
inline int lca(int x,int y) {
  if(dep[x]<dep[y]) swap(x,y);
  x=getanc(x,dep[x]-dep[y]);
  if(x==y) return x;
  for(ri i=19;~i;--i) if(st[x][i]!=st[y][i]) x=st[x][i],y=st[y][i];
  return st[x][0];
}
int ft[N],col[N],dis[N];
inline int find(int x) { return x^ft[x]?ft[x]=find(ft[x]):x; }
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  n=read(),r=read(),m=read();
  for(ri ct=n,i=1,u,v;i<n;++i) {
    u=read(),v=read(),++ct;
    e[u].pb(ct),e[v].pb(ct);
    e[ct].pb(u),e[ct].pb(v);
  }
  dfs(1);
  queue<int>q;
  memset(dis,-1,sizeof(dis));
  for(ri i=1,x;i<=m;++i) x=read(),ft[x]=x,q.push(x),dis[x]=0;
  while(q.size()) {
    int x=q.front();
    q.pop();
    if(dis[x]==r) break;
    for(ri i=0,v,fx,fy;i<(int)e[x].size();++i) {
      if(dis[v=e[x][i]]==-1) {
        dis[v]=dis[x]+1,ft[v]=find(ft[x]);
        q.push(v);
      }
      else {
        fx=find(ft[x]),fy=find(ft[v]);
        if(fx^fy) ft[fy]=fx;
      }
    }
  }
  for(ri l,x,y,d,_x,_y,tt=read();tt;--tt) {
    x=read(),y=read(),l=lca(x,y),d=dep[x]+dep[y]-2*dep[l];
    if(d<=r*2) { puts("YES");continue; }
    _x=dep[x]-dep[l]>=r?getanc(x,r):getanc(y,d-r);
    _y=dep[y]-dep[l]>=r?getanc(y,r):getanc(x,d-r);
    puts(ft[_x]&&ft[_y]&&find(ft[_x])==find(ft[_y])?"YES":"NO");
  }
  return 0;
}


#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
#define y1 ysghysgsygsh
using namespace std;
const int N=400005;
vector<int> e[N];
int n,k,R,nd,Q;
int f[N][19],dep[N];
int fa[N],dis[N],co[N];
int q[N],a[N];
int get(int x){
	return x==fa[x]?x:fa[x]=get(fa[x]);
}
void dfs(int x){
	for (auto i:e[x])
		if (i!=f[x][0]){
			f[i][0]=x;
			dep[i]=dep[x]+1;
			dfs(i);
		}
}
int jump(int x,int k){
	Rep(i,18,0)
		if (k&(1<<i))
			x=f[x][i];
	return x;
}
int LCA(int x,int y){
	if (dep[x]<dep[y]) swap(x,y);
	x=jump(x,dep[x]-dep[y]);
	Rep(i,18,0)
		if (f[x][i]!=f[y][i])
			x=f[x][i],y=f[y][i];
	return x==y?x:f[x][0];
}
void SSSP(){
	int h=0,t=0;
	For(i,1,nd) dis[i]=-1;
	For(i,1,R) dis[a[i]]=0,co[a[i]]=i,q[++t]=a[i];
	while (h!=t){
		int x=q[++h];
		if (dis[x]==k) continue;
		for (auto i:e[x])
			if (dis[i]==-1){
				dis[i]=dis[x]+1;
				co[i]=co[x];
				q[++t]=i;
			}
			else
				fa[get(co[i])]=get(co[x]);
	}
}
int main(){
	scanf("%d%d%d",&n,&k,&R);
	nd=n;
	For(i,1,n-1){
		int x,y; ++nd;
		scanf("%d%d",&x,&y);
		e[x].PB(nd); e[nd].PB(x);
		e[y].PB(nd); e[nd].PB(y);
	}
	dfs(1);
	For(i,1,18) For(j,1,nd)
		f[j][i]=f[f[j][i-1]][i-1];
	For(i,1,R){
		scanf("%d",&a[i]);
		fa[i]=i;
	}
	SSSP();
	scanf("%d",&Q);
	while (Q--){
		int x,y;
		scanf("%d%d",&x,&y);
		int L=LCA(x,y),d=dep[x]+dep[y]-2*dep[L];
		if (d<=2*k) puts("YES");
		else{
			int nx=(dep[x]-dep[L]>=k?jump(x,k):jump(y,d-k));
			int ny=(dep[y]-dep[L]>=k?jump(y,k):jump(x,d-k));
			if (!co[nx]||!co[ny]) puts("NO");
			else puts(get(co[nx])==get(co[ny])?"YES":"NO");
		}
	}
}


#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;

const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const int maxn=100111;

int head[maxn],nxt[maxn<<1],to[maxn<<1],etot=1;
void addedge(int u,int v)
{
	nxt[++etot]=head[u];head[u]=etot;to[etot]=v;
	nxt[++etot]=head[v];head[v]=etot;to[etot]=u;
}

int n,m,X,q[maxn],fa[maxn],bfn[maxn];
bool mark[maxn];
void bfs()
{
	int fr=1,rr=1;q[rr++]=1;
	for(;fr<rr;fr++)
	{
		int x=q[fr];
		bfn[x]=fr;
		for(int i=head[x];i;i=nxt[i])if(to[i]!=fa[x])
		{
			fa[to[i]]=x;
			q[rr++]=to[i];
		}
	}
}
namespace centroid
{
	bool use[maxn];int sz[maxn];
	int seq[maxn],tot;
	void dfs1(int x,int f=0)
	{
		seq[++tot]=x;sz[x]=1;
		for(int i=head[x];i;i=nxt[i])if(to[i]!=f&&!use[to[i]])
		{
			dfs1(to[i],x);
			sz[x]+=sz[to[i]];
		}
	}
	int getroot(int x)
	{
		tot=0;dfs1(x);
		x=0;for(int i=1;i<=tot;i++)if(sz[seq[i]]*2>=tot&&(x==0||sz[x]>sz[seq[i]]))x=seq[i];
		return x;
	}

	int dep[maxn];
	bool cmp(int x,int y){return dep[x]<dep[y];}
	void dfs(int x,int f=0,int d=0)
	{
		dep[x]=d;
		for(int i=head[x];i;i=nxt[i])if(to[i]!=f&&!use[to[i]])dfs(to[i],x,d+1);
	}

	int fa[20][maxn], d[20][maxn], lv[maxn];
	std::vector<pii> all[maxn];
	void solve(int rt, int lvl)
	{
		rt=getroot(rt);
		lv[rt] = lvl;
		dfs(rt);
		for(int i=1; i<=tot; i++)
		{
			fa[lvl][seq[i]] = rt;
			d[lvl][seq[i]] = dep[seq[i]];
			if(mark[seq[i]]) all[rt].pb(mp(dep[seq[i]], bfn[seq[i]]));
		}
		sort(all[rt].begin(),all[rt].end());
		for(int i=1;i<all[rt].size();i++) all[rt][i].ss = min(all[rt][i].ss, all[rt][i-1].ss);
		use[rt]=1;
		for(int i=head[rt];i;i=nxt[i])if(!use[to[i]])solve(to[i], lvl+1);
	}
	int query(int x)
	{
		int ret = inf;
		for(int i = lv[x]; i>=0; i--)
		{
			int rt = fa[i][x], dep = d[i][x];
			int pos = lower_bound(all[rt].begin(), all[rt].end(), mp(X - dep, inf)) - all[rt].begin() - 1;
			if(pos >= 0) ret=min(ret, all[rt][pos].ss);
		}
		return ret;
	}
	int query_dist(int x, int y)
	{
		for(int i=lv[x]; i>=0; i--)
		{
			if(fa[i][x] == fa[i][y]) return d[i][x] + d[i][y];
		}
	}
	void decomp()
	{
		memset(use,0,sizeof(use));
		solve(1, 0);
	}
}

int f[maxn], up[maxn];
int gf(int x) { return x == f[x] ? x : f[x] = gf(f[x]); }

int query(int a, int b)
{
	if(centroid::query_dist(a,b) <= X) return true;
	int k1 = centroid::query(a), k2 = centroid::query(b);
	if(k1 <= n && k2 <= n && gf(q[k1]) == gf(q[k2])) return true;
	if(k1 <= n && centroid::query_dist(gf(q[k1]), b) <= X) return true;
	if(k2 <= n && centroid::query_dist(gf(q[k2]), a) <= X) return true;
	return false;
}

int main()
{
	scanf("%d%d%d",&n,&X,&m);
	for(int i=1, u,v; i<n; i++)
	{
		scanf("%d%d",&u,&v);
		addedge(u,v);
	}
	bfs();
	for(int i=1, x; i<=m; i++)
	{
		scanf("%d", &x);
		mark[x] = 1;
	}
	centroid::decomp();
	for(int i=1; i<=n; i++) f[i] = i;
	for(int i=1; i<=n; i++) if(mark[i])
	{
		int qq = centroid::query(i);
		if(qq<=n)
		{
			qq = q[qq];
			f[gf(i)] = gf(qq);
		}
	}
	int qv;
	scanf("%d", &qv);
	for(int i=1, a, b; i<=qv; i++)
	{
		scanf("%d%d",&a,&b);
		if(query(a,b)) puts("YES");
		else puts("NO");
	}
	return 0;
}