#include <fstream>
#include <utility>
#define x first
#define y second
#include <vector>
#include <algorithm>
using namespace std;
ifstream in("radiatie.in");
ofstream out("radiatie.out");
typedef pair <int, int> pii;
const int nmax = 15000, mmax = 30000;
int n, m, nrq, a, b;
vector <pii> muchii[nmax + 2];
struct edge{
int a, b, costt;
bool operator < (const edge &obj) const {
return costt < obj.costt;
}
} edges[mmax + 2];
struct disjointset{
int father[nmax + 2];
int compsz[nmax + 2];
int getfather(int node){
if(node == father[node])
return node;
father[node] = getfather(father[node]);
return father[node];
}
void setmerge(int a, int b){
a = getfather(a);
b = getfather(b);
if(a == b){ return; }
if(compsz[a] < compsz[b])
swap(a, b);
compsz[a] += compsz[b];
father[b] = a;
}
} dsu;
int dpmax[nmax + 2];
void dfs(int node, int father){
for(auto nxt : muchii[node]){
if(nxt.x != father){
dpmax[nxt.x] = max(dpmax[node], nxt.y);
dfs(nxt.x, node);
}
}
}
int main(){
in>>n>>m>>nrq;
for(int i = 1; i <= m; i++)
in>>edges[i].a>>edges[i].b>>edges[i].costt;
for(int i = 1; i <= n; i++){
dsu.father[i] = i;
dsu.compsz[i] = 1;
}
sort(edges + 1, edges + 1 + m);
for(int i = 1; i <= m; i++){
edge edgenw = edges[i];
if(dsu.getfather(edges[i].a) != dsu.getfather(edges[i].b)){
dsu.setmerge(edges[i].a, edges[i].b);
muchii[edges[i].a].push_back(make_pair(edges[i].b, edges[i].costt));
muchii[edges[i].b].push_back(make_pair(edges[i].a, edges[i].costt));
}
}
for(int itq = 1; itq <= nrq; itq++){
in>>a>>b;
for(int i = 1; i <= n; i++)
dpmax[i] = 0;
dfs(a, 0);
out<<dpmax[b]<<"\n";;
}
return 0;
}