#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
#define f first
#define s second
#define nmax 15010
vector <pair <int, pair <int, int> > > v;
vector <pair <int, int> > g[nmax];
int n, m, k, t[nmax], lev[nmax], h, rmq[20][nmax], rmqv[20][nmax], sol;
int tata (int nod)
{
if (t[nod] != nod) t[nod] = tata(t[nod]);
return t[nod];
}
void apm ()
{
int i, x, y;
for (i=1; i<=n; i++) t[i] = i;
for (i=0; i<m; i++)
{
x = tata (v[i].s.f);
y = tata (v[i].s.s);
if (x != y)
{
t[x] = y;
g[v[i].s.f].push_back (make_pair (v[i].s.s, v[i].f));
g[v[i].s.s].push_back (make_pair (v[i].s.f, v[i].f));
}
}
}
void df(int nod)
{
int i, v;
for (i = 0; i < g[nod].size(); i++)
{
v = g[nod][i].f;
if (!lev[v])
{
lev[v] = lev[nod] + 1;
rmq[0][v] = nod;
rmqv[0][v] = g[nod][i].s;
df (v);
}
}
}
void lca (int x, int y)
{
int aux, step, niv;
if (lev [x] > lev[y])
{
aux = x;
x = y;
y = aux;
}
niv = lev[y];
for (step = 1; (1<<step) <= lev[y]-lev[x]; step++);
for (; step >= 0; step--)
{
if (niv - (1<<step) >= lev[x])
{
niv -= (1<<step);
sol = max (sol, rmqv[step][y]);
y = rmq[step][y];
}
}
for (step = 1; (1<<step) <= lev[x]; step++);
for (; step >= 0; step --)
{
if (rmq[step][x] != rmq[step][y])
{
sol = max (sol, rmqv[step][x]);
sol = max (sol, rmqv[step][y]);
x = rmq[step][x];
y = rmq[step][y];
}
}
if (x!=y)
{
sol = max (sol, rmqv[0][x]);
sol = max (sol, rmqv[0][y]);
}
}
int main()
{
freopen ("radiatie.in","r",stdin);
freopen ("radiatie.out","w",stdout);
scanf ("%d %d %d", &n, &m, &k);
int i, x, y, z, step;
for (i=1; i<=m; i++)
{
scanf ("%d %d %d", &x, &y, &z);
v. push_back (make_pair (z, make_pair (x,y)));
}
sort (v.begin(), v.end());
apm();
lev[1] = 1;
df(1);
for (i=1; i<=n; i++)
if (lev[i] > h) h = i;
for (step = 1; (1 << step) <= h; step++)
for (i=1; i<=n; i++)
{
rmq[step][i] = rmq[step-1][rmq[step-1][i]];
rmqv[step][i] = max (rmqv[step-1][i], rmqv[step-1][rmq[step-1][i]]);
}
while (k--)
{
scanf ("%d %d", &x, &y);
sol = 0;
lca (x, y);
printf("%d\n", sol);
}
}