#include <bits/stdc++.h>
using namespace std;
int n, e; //nodes, edges
vector<vector<pair<int, int> > > adj; //first is adjecent node, second is edge cost
struct node {
int x, cst;
node(int x, int cst) :
x(x), cst(cst) {
}
bool operator<(const node &a) const {
return a.cst < cst;
}
};
int dijk(int src, int des) {
vector<int> cost(n + 1, 1e9);
priority_queue<node> que;
que.push(node(src, 0));
cost[src] = 0;
while (que.size()) {
int x = que.top().x, cst = que.top().cst;
que.pop();
if (x == des) {
return cst;
}
for (int i = 0, ln = adj[x].size(); i < ln; ++i) {
int y = adj[x][i].first, _cst = adj[x][i].second;
if (cst + _cst < cost[y]) {
cost[y] = cst + _cst;
que.push(node(y, cost[y]));
}
}
}
}
int main() {
#ifndef ONLINE_JUDGE
freopen("a.in", "r", stdin);
#endif
int q;
cin >> n >> e >> q; // qeuery
adj.clear();
adj.resize(n + 1);
while (e--) {
int x, y, z; //pair of nodes, cost
cin >> x >> y >> z;
adj[x].push_back(make_pair(y, z));
}
while (q--) {
int src, des;
cin >> src >> des;
cout << dijk(src, des) << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBuLCBlOyAvL25vZGVzLCBlZGdlcwp2ZWN0b3I8dmVjdG9yPHBhaXI8aW50LCBpbnQ+ID4gPiBhZGo7IC8vZmlyc3QgaXMgYWRqZWNlbnQgbm9kZSwgc2Vjb25kIGlzIGVkZ2UgY29zdApzdHJ1Y3Qgbm9kZSB7CglpbnQgeCwgY3N0OwoJbm9kZShpbnQgeCwgaW50IGNzdCkgOgoJCQl4KHgpLCBjc3QoY3N0KSB7Cgl9Cglib29sIG9wZXJhdG9yPChjb25zdCBub2RlICZhKSBjb25zdCB7CgkJcmV0dXJuIGEuY3N0IDwgY3N0OwoJfQp9OwppbnQgZGlqayhpbnQgc3JjLCBpbnQgZGVzKSB7Cgl2ZWN0b3I8aW50PiBjb3N0KG4gKyAxLCAxZTkpOwoJcHJpb3JpdH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