#include <bits/stdc++.h>
using namespace std;
int n, s, q, e;
int const N = 100005;
vector<pair<int, int>> g[N];
vector <int> et;
pair<int, int> eti[N];
vector<int> shops;
pair<int, int> roads[N];
void fet(int u, int p)
{
et.push_back(u);
eti[u]={et.size()-1, 0};
for(auto i: g[u])
{
if(i.first == p)continue;
fet(i.first, u);
}
et.push_back(u);
eti[u]={eti[u].first, et.size()-1};
}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> s >> q >> e;
for(int i = 0; i < n-1; i++)
{
int a, b, w; cin >> a >> b >> w;
g[a].push_back({b, w});
g[b].push_back({a, w});
roads[i+1]={a, b};
}
for(int i =0; i < s; i++)
{
int x; cin >> x;
shops.push_back(x);
}
fet(e, 0);
while(q--)
{
int i, r; cin >> i >> r;
if(eti[roads[i].first].first <= eti[r].first && eti[roads[i].second].first <= eti[r].first && eti[roads[i].first].second >= eti[r].second && eti[roads[i].second].second >= eti[r].second)
{
cout << "0\n";
}
else
{
cout << "escaped\n";
}
}
return 0;
}