#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
const int maxn=1e5+7;
int i,j,k,l,n,m,q,u,v,shu,r;
int fa[107],o[maxn];
struct node{
int sum;
int a[101];
}t[maxn*4],ans;
struct nod{
int x,y,z;
}a[maxn];
int gf(int x){
if(fa[x]==x)return x;
return fa[x]=gf(fa[x]);
}
node merge(node y,node z){
node x;
int i=1,j=1,k=0,op=0;
memset(x.a,0,sizeof(x.a));x.sum=0;
while(a[y.a[i]].z&&a[z.a[j]].z){
if(a[y.a[i]].z<a[z.a[j]].z)o[++k]=y.a[i++];
else o[++k]=z.a[j++];
}
while(a[y.a[i]].z)o[++k]=y.a[i++];
while(a[z.a[j]].z)o[++k]=z.a[j++];
if(k>200){
u=u;
}
fo(i,1,n)fa[i]=i;shu=0;
fo(i,1,k){
u=gf(a[o[i]].x),v=gf(a[o[i]].y);
if(u!=v)fa[u]=v,x.sum+=a[o[i]].z,x.a[++op]=o[i];
}
return x;
}
void build(int x,int l,int r){
if(l==r){
t[x].sum=a[l].z;
t[x].a[1]=l;
return;
}
int mid=(l+r)/2;
build(x*2,l,mid),build(x*2+1,mid+1,r);
t[x]=merge(t[x*2],t[x*2+1]);
if(r-l>194){
u=u;
}
}
node find(int x,int l,int r,int y,int z){
if(l==y&&r==z)return t[x];
int mid=(l+r)/2;
if(z<=mid)return find(x*2,l,mid,y,z);
else if(y>mid)return find(x*2+1,mid+1,r,y,z);
else return merge(find(x*2,l,mid,y,mid),find(x*2+1,mid+1,r,mid+1,z));
}
int main(){
freopen("highway.in","r",stdin);
freopen("highway.out","w",stdout);
scanf("%d%d%d",&n,&m,&q);
fo(i,1,m){
scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
}
build(1,1,m);
while(q--){
scanf("%d%d",&l,&r);
ans=find(1,1,m,l,r);
printf("%d\n",ans.sum);
}
}