#include<stdio.h>
#include<stdlib.h>
#define N 15005
#define M 30005
typedef struct{int x, y, c;} muchii;
muchii mu[M];
int tata[N], L[N], level[N], h[N], cost[N], n, m, k;
void citire(), apm(), rezolva();
int cmp(const void *a, const void *b){
return (mu[*(int*)a].c - mu[*(int*)b].c);}
inline int max(int a, int b){ if (a > b) return a; else return b;}
int main (){
freopen("radiatie.in","r",stdin);
freopen("radiatie.out","w",stdout);
citire();
apm();
rezolva();
return 0;
}
void citire(){
int i;
scanf("%d %d %d", &n, &m, &k);
for (i = 1; i <= m; i++){
h[i] = i;
scanf("%d %d %d", &mu[i].x, &mu[i].y, &mu[i].c);
}
}
void apm(){
int i, cur, u, v;
qsort(h+1, m, sizeof(int), cmp);
for (i = 1; i <= n; i++) tata[i] = i;
for (i = 1; i <= m; ++i){
cur = h[i];
for (u = mu[cur].x; tata[u] != u; u = tata[u]);
for (v = mu[cur].y; tata[v] != v; v = tata[v]);
if (u != v){
if (level[u] > level[v]){
tata[v] = u;
cost[v] = mu[cur].c;
}
else{
tata[u] = v;
cost[u] = mu[cur].c;
if (level[u] == level[v])
++level[v];
}
}
}
}
void rezolva(){
int Sol, i, j, xx, yy;
for (i = 1; i <= n; i++)
for (j = i; tata[j] != j; j = tata[j])
L[i]++;
for ( ; k; --k){
scanf("%d %d", &xx, &yy);
Sol = 0;
for ( ;L[xx] > L[yy]; xx = tata[xx])
Sol = max(cost[xx],Sol);
for ( ;L[yy] > L[xx]; yy = tata[yy])
Sol = max(cost[yy],Sol);
for ( ; xx != yy; xx = tata[xx], yy = tata[yy])
Sol = max(cost[xx], max(cost[yy], Sol));
printf("%d\n", Sol);
}
}