#include <stdio.h>
#include <vector>
#include <algorithm>
#define pb push_back
#define nmax 15005
#define lmax 12
using namespace std;
typedef pair<int,int> ii;
typedef pair< int,pair<int,int> > iii;
vector <iii> a;
vector <ii> e[nmax];
int n,m,k,i,card[nmax],dad[nmax],niv[nmax],Tata[nmax],cost_tata[nmax],n1,n2;
ii l[nmax][lmax];
char v[nmax];
inline int max(int a,int b) {
if(a > b) return a;
else return b;
}
void unite(int x,int y) {
if(card[x] < card[y]) dad[x] = y;
else {
dad[y] = x;
if(card[x] == card[y]) card[x]++;
}
}
int tata(int x) {
if(dad[x] != x) dad[x] = tata(dad[x]);
return dad[x];
}
void dfs(int x,int lev) {
v[x] = 1;
niv[x] = lev;
if(Tata[x] != 0) {
l[x][0] = ii(cost_tata[x],Tata[x]);
for(int i = 1; i <= lmax; i++)
l[x][i] = ii(max(l[x][i - 1].first,l[l[x][i - 1].second][i - 1].first),l[l[x][i - 1].second][i - 1].second);
}
for(int i = 0; i < (int)e[x].size(); i++)
if(!v[e[x][i].first]) {
Tata[e[x][i].first] = x;
cost_tata[e[x][i].first] = e[x][i].second;
dfs(e[x][i].first,lev + 1);
}
}
int query(int x,int y) {
if(niv[x] < niv[y]) x ^= y ^= x ^= y;
int ll = lmax - 1,sol = 0;
while(niv[x] > niv[y]) {
if(l[x][ll].second != 0 && niv[l[x][ll].second] >= y) {
sol = max(sol,l[x][ll].first);
x = l[x][ll].second;
}
else ll--;
}
ll = lmax - 1;
while(x != y) {
if(l[x][ll].second != 0 && l[x][ll].second != l[y][ll].second) {
sol = max(sol,max(l[x][ll].first,l[y][ll].first));
x = l[x][ll].second;
y = l[y][ll].second;
}
else ll--;
}
return sol;
}
int main() {
freopen("radiatie.in","r",stdin);
freopen("radiatie.out","w",stdout);
scanf("%d%d%d",&n,&m,&k);
a.resize(m);
for(i = 0; i < m; i++)
scanf("%d%d%d",&a[i].second.first,&a[i].second.second,&a[i].first);
sort(a.begin(),a.end());
for(i = 1; i <= n; i++) dad[i] = i;
for(i = 0; i < m; i++)
if(tata(a[i].second.first) != tata(a[i].second.second)) {
unite(tata(a[i].second.first),tata(a[i].second.second));
e[a[i].second.first].pb(ii(a[i].second.second,a[i].first));
e[a[i].second.second].pb(ii(a[i].second.first,a[i].first));
}
return 0;
dfs(1,1);
for(int i = 1; i <= k; i++) {
scanf("%d%d",&n1,&n2);
printf("%d\n",query(n1,n2));
}
return 0;
}