#include<fstream>
#include<vector>
#include<algorithm>
#include<stack>
#define infile "radiatie.in"
#define outfile "radiatie.out"
#define n_max 15005
#define m_max 30005
#define log_max 14
#define pb push_back
#define mkp make_pair
#define pii pair <int, int>
#define it_int vector < pii > ::iterator
#define nxt (*it).first
#define cost (*it).second
#define FOR(g) \
for(it_int it=g.begin(); it!=g.end(); ++it)
using namespace std;
struct muchie {
int x, y, c;};
muchie a[m_max];
vector < pii > v[n_max];
int T[n_max], R[n_max], L[n_max];
int log[n_max];
int P[n_max][log_max], C[n_max][log_max];
int N, M, K;
int find(int x)
{
int r, y;
for(r = x; T[r] != r; r = T[r]);
while(T[x] != x)
{
y = T[x];
T[x] = r;
x = y;
}
return r;
}
void uneste(int x, int y)
{
if(R[x] < R[y])
T[x] = y;
else
T[y] = x;
if(R[x] == R[y])
R[x]++;
}
inline bool cmp(const muchie &a, const muchie &b){
return a.c < b.c; }
void Kruskal()
{
sort(a+1, a+M+1, cmp);
for(int i=1; i<=N; ++i)
T[i] = i, R[i] = 1;
for(int i=1; i<=M; ++i)
{
int m1 = find(a[i].x);
int m2 = find(a[i].y);
if(m1!=m2)
{
uneste(m1, m2);
v[a[i].x].pb(mkp(a[i].y, a[i].c));
v[a[i].y].pb(mkp(a[i].x, a[i].c));
}
}
}
void DFS(int x, int tx, int h)
{
L[x] = h;
FOR(v[x])
if(nxt != tx){
DFS(nxt, x, h+1);
P[nxt][0] = x;
C[nxt][0] = cost;
}
}
void Make_LCA()
{
for(int i=1; i<=N; ++i)
if(find(i) == i)
DFS(i, 0, 0);
for(int i=2; i<=N; ++i)
log[i] = log[i>>1] + 1;
for(int i=1; i<=N; ++i)
for(int j=1; j <= log[N]; ++j){
P[i][j] = P[ P[i][j-1] ][j-1];
C[i][j] = max(C[i][j-1], C[ P[i][j-1] ][j-1]);
}
}
int LCA(int x, int y)
{
int rez = 0;
if(L[x] < L[y])
swap(x, y);
for(int i=log[L[x]]; i>=0; --i)
if(L[x] - (1<<i) >= L[y]){
rez = max(rez, C[x][i]);
x = P[x][i];
}
for(int i=log[L[x]]; i>=0; --i)
if(P[x][i] != P[y][i]){
rez = max(rez, max(C[x][i], C[y][i]));
x = P[x][i];
y = P[y][i];
}
if(x!=y)
rez = max(rez, max( C[x][0], C[y][0]));
return rez;
}
int main()
{
freopen(infile, "r", stdin);
freopen(outfile, "w", stdout);
scanf("%d %d %d", &N, &M, &K);
for(int i=1; i<=M; ++i)
scanf("%d %d %d",&a[i].x, &a[i].y, &a[i].c);
Kruskal();
Make_LCA();
int x, y;
for(int i=1; i<=K; ++i){
scanf("%d %d", &x, &y);
printf("%d\n", LCA(x,y));
}
fclose(stdin);
fclose(stdout);
return 0;
}