#include <stdio.h>
#include <algorithm>
using namespace std;
#define MAX_N 15005
#define MAX_M 30005
#define FIN "radiatie.in"
#define FOUT "radiatie.out"
#define FOR(i, a, b) for (i = (a); i < (b); i++)
#define mp make_pair
#define f first
#define s second
int N, M, K, up[MAX_N], cost[MAX_N], lev[MAX_N];
pair <int, pair<int, int> > E[MAX_M];
inline int find(int n)
{
for (; n != up[n]; n = up[n]);
return n;
}
int main(void)
{
int i, j, a, b, c, res;
freopen(FIN, "r", stdin);
freopen(FOUT, "w", stdout);
scanf("%d %d %d", &N, &M, &K);
FOR (i, 0, M)
{
scanf("%d %d %d", &a, &b, &c);
E[i] = mp(c, mp(a-1, b-1));
}
FOR (i, 0, N) up[i] = i;
sort(E, E+M);
FOR (i, 0, M)
{
a = find(E[i].s.f); b = find(E[i].s.s), c = E[i].f;
if (a == b) continue;
if (rand()&1)
up[a] = b, cost[a] = c;
else
up[b] = a, cost[b] = c;
}
FOR (i, 0, N)
for (j = i; j != up[j]; j = up[j]) lev[i]++;
FOR (i, 0, K)
{
scanf("%d %d", &a, &b); a--, b--;
res = 0;
for (; lev[a] > lev[b]; a = up[a])
res = max(res, cost[a]);
for (; lev[a] < lev[b]; b = up[b])
res = max(res, cost[b]);
for (; a != b; a = up[a], b = up[b])
res = max(res, max(cost[a], cost[b]));
printf("%d\n", res);
}
return 0;
}