#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <unordered_set>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <stack>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>

using namespace std;

#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-parameter"

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define hashmap unordered_map
#define hashset unordered_set
#define pb push_back
#define ff first
#define ss second
#define en "\n"

const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll linf = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

void __print(int x) { cerr << x; }
void __print(ll x) { cerr << x; }
void __print(ull x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(ld x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const string &x) { cerr << '"' << x << '"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

#ifdef LOCAL
#define debug(...) \
{ \
        cerr << "[" << #__VA_ARGS__ << "] = ["; \
        _print(__VA_ARGS__); \
}
#else
#define debug(...)
#endif

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rnd(ll l, ll r)
{
        return uniform_int_distribution<ll>(l, r)(rng);
}

template<typename T, typename V>
void __print(const pair<T, V> &x);

template<typename T>
void __print(const T &x);

template<typename T, size_t N>
void __print(const array<T, N> &x);

template<typename... T>
void __print(const tuple<T...> &x);

template<class T>
bool maximize(T &a, const T &b)
{
        if(a < b)
        {
                a = b;

                return true;
        }

        return false;
}

template<class T>
bool minimize(T &a, const T &b)
{
        if(a > b)
        {
                a = b;

                return true;
        }

        return false;
}

template<typename T, typename V>
void __print(const pair<T, V> &x)
{
        cerr << '{';
        __print(x.ff);
        cerr << ", ";
        __print(x.ss);
        cerr << '}';
}

template<typename T>
void __print(const T &x)
{
        int f = 0;
        cerr << '{';
        for(auto &i : x) cerr << (f++ ? ", " : ""), __print(i);
        cerr << "}";
}

template<typename T, size_t N>
void __print(const array<T, N> &x)
{
        cerr << '{';
        int f = 0;
        for(auto &i : x) cerr << (f++ ? ", " : ""), __print(i);
        cerr << '}';
}

template<typename... T>
void __print(const tuple<T...> &x)
{
        cerr << '(';
        apply([&](const auto&... args)
        {
                int f = 0;
                ((cerr << (f++ ? ", " : ""), __print(args)), ...);
        }, x);
        cerr << ')';
}

void _print()
{
        cerr << "]" << en;
}

template<typename T, typename... V>
void _print(T t, V... v)
{
        __print(t);
        if(sizeof...(v)) cerr << ", ";
        _print(v...);
}

namespace brute_force
{
        void progress()
        {

        }
}

struct Edge
{
        int v;
        ll w;
};

int n, m, q;
vector<vector<Edge>> adj;

namespace accepted_solution
{
        vector<vector<ll>> dijktra()
        {
                vector<vector<ll>> dist(n + 1, vector<ll>(n + 1, linf));
                for(int st = 1 ; st <= n ; st++)
                {
                        dist[st][st] = 0;
                        priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
                        pq.push({0, st});

                        while(!pq.empty())
                        {
                                ll d = pq.top().ff;
                                int u = pq.top().ss;
                                pq.pop();

                                if(d != dist[st][u]) continue;
                                for(const Edge &e : adj[u])
                                {
                                        if(minimize(dist[st][e.v], d + e.w)) pq.push({dist[st][e.v], e.v});
                                }
                        }
                }

                return dist;
        }

        void solve()
        {
                vector<vector<ll>> dist = dijktra();

                while(q--)
                {
                        int x, y;
                        cin >> x >> y;

                        if(dist[x][y] >= linf >> 1) cout << -1 << en;
                        else cout << dist[x][y] << en;
                }
        }
}

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);

        #define task "STAREDU"
        if(fopen(task ".inp", "r"))
        {
                freopen(task ".inp", "r", stdin);
                freopen(task ".out", "w", stdout);
        }

        cin >> n >> m >> q;
        adj.resize(n + 1);
        for(int i = 0 ; i < m ; i++)
        {
                int u, v;
                ll w;
                cin >> u >> v >> w;

                adj[u].pb({v, w});
                adj[v].pb({u, w});
        }

        accepted_solution::solve();

        return 0;
}

/*
Compile in terminal: 
g++ -std=c++17 -O2 -Wall -Wextra -Wshadow -Wconversion main.cpp -o main.exe
main.exe

Debugging:
g++ -std=c++17 -O0 -g -DLOCAL main.cpp -o main
*/