#include <bits/stdc++.h>
using namespace std;
void setup()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const int block = 320;
int n, m, q, a, b, cur, highest;
int depth[100000], sp[20][100000], num[100000], c[100000], head[100000], tail[100000], res[100000];
vector<int> g[100000];
array<int, 3> query[100000];
set<pair<int, int>> s;
inline void DFS(int node, int par)
{
head[node] = a++;
sp[0][node] = par;
for (int i = 1; i < 20; ++i)
{
sp[i][node] = sp[i - 1][sp[i - 1][node]];
}
for (auto &i : g[node])
{
if (i != par)
{
depth[i] = depth[node] + 1;
DFS(i, node);
}
}
tail[node] = a - 1;
}
inline int LCA(int ina, int inb)
{
if (depth[ina] < depth[inb])
{
swap(ina, inb);
}
for (int i = 19; i >= 0; --i)
{
if (depth[sp[i][ina]] >= depth[inb])
{
ina = sp[i][ina];
}
}
if (ina == inb)
{
return ina;
}
for (int i = 19; i >= 0; --i)
{
if (sp[i][ina] != sp[i][inb])
{
ina = sp[i][ina];
inb = sp[i][inb];
}
}
return sp[0][ina];
}
inline int Dist(int ina, int inb)
{
return depth[inb] - depth[ina];
}
inline bool Comp(const array<int, 3> &ina, const array<int, 3> &inb)
{
return (ina[0] / block == inb[0] / block ? ina[1] < inb[1] : ina[0] < inb[0]);
}
inline void Add(int node)
{
set<pair<int, int>>::iterator it;
s.insert({head[node], node});
// cout << "+ " << node << " " << cur << "\n";
if (s.size() == 1)
{
cur++;
highest = node;
return;
}
if (head[highest] <= head[node] && tail[node] <= tail[highest])
{
a = 0;
it = s.lower_bound({head[node], node});
if (it != s.begin())
{
b = LCA((*prev(it)).second, node);
a = (depth[b] > depth[a] ? b : a);
}
if (it != prev(s.end()))
{
b = LCA((*next(it)).second, node);
a = (depth[b] > depth[a] ? b : a);
}
cur += Dist(a, node);
}
else
{
a = LCA(highest, node);
cur += Dist(a, highest) + Dist(a, node);
highest = a;
}
}
inline void Remove(int node)
{
// cout << "- " << node << " " << cur << "\n";
set<pair<int, int>>::iterator it;
a = 0;
it = s.lower_bound({head[node], node});
if (it != s.begin())
{
b = LCA((*prev(it)).second, node);
a = (depth[b] > depth[a] ? b : a);
}
if (it != prev(s.end()))
{
b = LCA((*next(it)).second, node);
a = (depth[b] > depth[a] ? b : a);
}
s.erase(it);
highest = LCA((*s.begin()).second, (*s.rbegin()).second);
if (head[highest] <= head[node] && head[node] <= tail[highest])
{
cur -= Dist(a, node);
}
else
{
a = LCA(highest, node);
cur -= Dist(a, highest) + Dist(a, node);
}
}
int main()
{
setup();
cin >> n >> m >> q;
for (int i = 0; i < n - 1; ++i)
{
cin >> a >> b;
g[a - 1].push_back(b - 1);
g[b - 1].push_back(a - 1);
}
for (int i = 0; i < m; ++i)
{
cin >> c[i];
c[i]--;
}
for (int i = 0; i < q; ++i)
{
cin >> query[i][0] >> query[i][1];
query[i][2] = i;
query[i][0]--;
query[i][1]--;
}
sort(query, query + q, Comp);
a = 0;
DFS(0, 0);
for (int i = 0, l = 0, r = -1; i < q; ++i)
{
while (r < query[i][1])
{
r++;
num[c[r]]++;
if (num[c[r]] == 1)
{
Add(c[r]);
}
}
while (query[i][0] < l)
{
l--;
num[c[l]]++;
if (num[c[l]] == 1)
{
Add(c[l]);
}
}
while (query[i][1] < r)
{
if (num[c[r]] == 1)
{
Remove(c[r]);
}
num[c[r]]--;
r--;
}
while (l < query[i][0])
{
if (num[c[l]] == 1)
{
Remove(c[l]);
}
num[c[l]]--;
l++;
}
// cout << "--- " << l << " " << r << " " << cur << "\n";
res[query[i][2]] = cur;
}
for (int i = 0; i < q; ++i)
{
cout << res[i] << "\n";
}
return 0;
}