#include <bits/stdc++.h>
using namespace std;
const int Nmax = 15005;
const int LG = 13;
struct triple
{
int x,y,cost;
triple(int x, int y, int cost) : x(x), y(y), cost(cost) {}
};
vector< triple > v;
vector< pair<int,int> > edge[Nmax];
int n, i, m, k, boss[Nmax], T[Nmax][LG+2], V[Nmax][LG+2], level[Nmax], X, Y, Cost;
int sef(int x)
{
if(boss[x]==x) return x;
return boss[x] = sef(boss[x]);
}
void unite(int x, int y)
{
boss[boss[x]] = boss[y];
}
bool cmp(triple a, triple b)
{
return a.cost < b.cost;
}
void dfs(int node)
{
int i;
for(i=1; i<=LG; ++i)
{
T[node][i] = T[T[node][i-1]][i-1];
V[node][i] = max(V[node][i-1], V[T[node][i-1]][i-1]);
}
for(auto it : edge[node])
if(!level[it.first])
{
level[it.first] = level[node]+1;
T[it.first][0] = node;
V[it.first][0] = it.second;
dfs(it.first);
}
}
int solve(int x, int y)
{
if(level[x]<level[y]) swap(x,y);
int urc = level[x] - level[y], i, ans=0;
for(i=0; urc && i<=LG; ++i)
if(urc&(1<<i))
{
ans = max(ans, V[x][i]);
x = T[x][i];
urc ^= (1<<i);
}
if(x==y) return ans;
for(i=LG; i>=0; --i)
if(T[x][i]!=T[y][i])
{
ans = max(ans, V[x][i]);
ans = max(ans, V[y][i]);
x = T[x][i];
y = T[y][i];
}
ans = max(ans, V[x][0]);
ans = max(ans, V[y][0]);
return ans;
}
int main()
{
freopen("radiatie.in", "r", stdin);
freopen("radiatie.out", "w", stdout);
scanf("%d%d%d", &n, &m, &k);
for(i=1; i<=n; ++i) boss[i] = i;
for(i=1; i<=m; ++i)
{
scanf("%d%d%d", &X, &Y, &Cost);
v.push_back(triple(X,Y,Cost));
}
sort(v.begin(), v.end(), cmp);
for(auto w : v)
if(sef(w.x)!=sef(w.y))
{
unite(w.x, w.y);
edge[w.x].push_back({ w.y, w.cost });
edge[w.y].push_back({ w.x, w.cost });
}
level[1]=1;
dfs(1);
while(k--)
{
scanf("%d%d", &X, &Y);
printf("%d\n", solve(X,Y));
}
return 0;
}