CSES - Shared codeLink to this code: https://cses.fi/paste/9c3c182bbb844d049ffe32/
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
#define IOS ios_base::sync_with_stdio(0);  cin.tie(0); cout.tie(0);


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>order_set;
typedef pair<int, int>pr;
#define all(i)     i.begin() , i.end()
#define ft     first
#define sn     second
#define pb push_back


#define en "\n"
#define dbg cout<<"rony\n";

#define MAXN 200010
#define inf 1e18
const ll mod = 1e9 + 7;

void solve()
{
    ll n, m, q;
    cin >> n >> m >> q;

    vector<vector<ll>> dist( n, vector<ll>(n, inf));

    for (ll i = 0; i < m; i++) {
        ll x, y, c;
        cin >> x >> y >> c;
        x--, y--;

        dist[x][x] = dist[y][y] = 0;

        dist[x][y] = min(dist[x][y], c);
        dist[y][x] = min(dist[y][x], c);
    }



    for (ll k = 0; k < n; k++) {
        for (ll i = 0; i < n; i++) {
            for (ll j = 0; j < n; j++) {
                if (dist[i][j] > dist[i][k] + dist[k][j]) {
                    dist[i][j] = dist[i][k] + dist[k][j];
                }
            }
        }
    }

    while (q--)
    {
        ll x, y;
        cin >> x >> y; x--, y--;
        if (x == y) {
            cout << 0 << en; continue;
        }

        if (dist[x][y] == inf) cout << -1 << en;
        else cout << dist[x][y] << en;
    }
}
int main()
{
    IOS;
    int t;
    t = 1;

    // cin >> t;
    int c = 0;
    while ( t-- )
    {
        //cout<<"Case "<<++c<<": ";
        solve();
    }
    return 0;
}