/***********************
[Offer收割]编程练习赛15 【B分数调查】
Author:herongwei
Time:2017/4/23 14:00
language:C++
***********************/
#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <set>
#include <stack>
#include <math.h>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 1e5+10;
const LL MOD = 999999997;
const int inf= 0x3f3f3f3f;
int dir4[4][2]= {{1,0},{0,1},{-1,0},{0,-1}};
int dir8[8][2]= {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
/*Super waigua */
#define INLINE __attribute__((optimize("O3"))) inline
INLINE char NC(void)
{
static char buf[100000], *p1 = buf, *p2 = buf;
if (p1 == p2)
{
p2 = (p1 = buf) + fread(buf, 1, 100000, stdin);
if (p1 == p2) return EOF;
}
return *p1++;
}
INLINE void read(int &x)
{
static char c;
c = NC();
int b = 1;
for (x = 0; !(c >= '0' && c <= '9'); c = NC()) if(c == '-') b = -b;
for (; c >= '0' && c <= '9'; x = x * 10 + c - '0', c = NC());
x *= b;
}
int fa[maxn],fen[maxn],vis[maxn];
void init()
{
for(int i=1; i<=maxn; ++i)
fa[i]=i, fen[i]=0;
}
/*find the father!!!!!*/
int find(int x)
{
if(x==fa[x]) return x;
else
{
int root = find( fa[x] );
fen[x] += fen[fa[x]];
return fa[x] = root;
}
}
/*Union!!!!!!!*/
int Union(int x,int y,int s)
{
int fx=find(x);
int fy=find(y);
if(fx!=fy)
{
fen[fy]=fen[x]+s-fen[y];
fa[fy]=fx;
}
}
int main()
{
//freopen("in.txt","r",stdin);
int n,m,l;
while(~scanf("%d %d %d",&n,&m,&l))
{
init();
int x,y,s;
for(int i=1; i<=m; ++i)
{
read(x);
read(y);
read(s);
Union(x,y,s);
}
for(int i=1; i<=l; ++i)
{
read(x);
read(y);
if(find(x)!=find(y))puts("-1");
else printf("%d\n",fen[y]-fen[x]);
}
}
return 0;
}