#include<iostream>
using namespace std;
const int oo = 1e9;
int a[1000][1000];
int d[1000][1000];
int n,m,q, u,v,w;
int th[1000][1000];
void khoitao(){
for(int i=1;i<=n;i++)
for(int j=1;j<=n;j++) {
a[i][j] = oo;
d[i][j] = oo;
th[i][j] = oo;
}
}
main(){
cin >> n >> m >> q;
khoitao();
for (int i = 1; i <= m; i++) {
cin >> u >> v >> w;
a[u][v] = min(w, a[u][v]);
a[v][u] = a[u][v];
th[u][v] = u;
th[v][u] = v;
}
for (int k = 1; k <= n; k++)
for (int i = 1; i <= n; i++)
for (int j = 1; j <= n; j++) {
if (d[i][k] + d[k][j] < d[i][j]) {
d[i][j] = d[i][k] + d[k][j];
th[i][j] = th[i][k];
cout << " " << d[i][j] << endl;
}
}
for (int i = 1; i <= q; i++) {
cin >> u >> v;
cout << d[u][v] << endl;
}
}
I2luY2x1ZGU8aW9zdHJlYW0+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY29uc3QgaW50IG9vID0gMWU5OwoKaW50IGFbMTAwMF1bMTAwMF07CmludCBkWzEwMDBdWzEwMDBdOwppbnQgbixtLHEsIHUsdix3OwppbnQgdGhbMTAwMF1bMTAwMF07Cgp2b2lkIGtob2l0YW8oKXsKCWZvcihpbnQgaT0xO2k8PW47aSsrKQoJZm9yKGludCBqPTE7ajw9bjtqKyspIHsKCQlhW2ldW2pdID0gb287CgkJZFtpXVtqXSA9IG9vOwoJCXRoW2ldW2pdID0gb287Cgl9Cn0KCm1haW4oKXsKCWNpbiA+PiBuID4+IG0gPj4gcTsKCWtob2l0YW8oKTsKCWZvciAoaW50IGkgPSAxOyBpIDw9IG07IGkrKykgewoJCWNpbiA+PiB1ID4+IHYgPj4gdzsKCQlhW3VdW3ZdID0gbWluKHcsIGFbdV1bdl0pOwoJCWFbdl1bdV0gPSBhW3VdW3ZdOwoJCXRoW3VdW3ZdID0gdTsKCQl0aFt2XVt1XSA9IHY7Cgl9CgkKCWZvciAoaW50IGsgPSAxOyBrIDw9I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