# Sample Input

9 10 2
1 2 1
1 4 1
3 4 1
2 3 1
3 7 1
7 8 2
7 9 2
1 5 3
1 6 4
5 6 1
1 9
5 7


# Sample Output

5
6


# Solution

#include<bits/stdc++.h>
#define ui unsigned int
#define ll long long
#define db double
#define ld long double
#define ull unsigned long long
const int MAXN=10000+10,MAXM=1000000+10,inf=0x3f3f3f3f;
int n,m,Q,e,to[MAXM<<1],nex[MAXM<<1],beg[MAXN],DFN[MAXN],LOW[MAXN],d[MAXN],dep[MAXN],Jie[20][MAXN],Visit_Num,sum[MAXN],len[MAXN],cnt,out[MAXM<<1],Be[MAXN],was[MAXM<<1],p[MAXN];
std::stack<int> s;
std::queue<int> q;
template<typename T> inline void read(T &x)
{
T data=0,w=1;
char ch=0;
while(ch!='-'&&(ch<'0'||ch>'9'))ch=getchar();
if(ch=='-')w=-1,ch=getchar();
while(ch>='0'&&ch<='9')data=((T)data<<3)+((T)data<<1)+(ch^'0'),ch=getchar();
x=data*w;
}
template<typename T> inline void write(T x,char ch='\0')
{
if(x<0)putchar('-'),x=-x;
if(x>9)write(x/10);
putchar(x%10+'0');
if(ch!='\0')putchar(ch);
}
template<typename T> inline void chkmin(T &x,T y){x=(y<x?y:x);}
template<typename T> inline void chkmax(T &x,T y){x=(y>x?y:x);}
template<typename T> inline T min(T x,T y){return x<y?x:y;}
template<typename T> inline T max(T x,T y){return x>y?x:y;}
inline void insert(int x,int y,int z=0)
{
to[++e]=y;
nex[e]=beg[x];
out[e]=x;
beg[x]=e;
was[e]=z;
}
inline void SPFA(int s)
{
for(register int i=1;i<=n;++i)d[i]=inf;
d[s]=0;
p[s]=1;
q.push(s);
while(!q.empty())
{
int x=q.front();
q.pop();
p[x]=0;
for(register int i=beg[x];i;i=nex[i])
if(d[to[i]]>d[x]+was[i])
{
d[to[i]]=d[x]+was[i];
if(!p[to[i]])p[to[i]]=1,q.push(to[i]);
}
}
}
inline void Tarjan(int x,int f)
{
DFN[x]=LOW[x]=++Visit_Num;
for(register int i=beg[x];i;i=nex[i])
if(to[i]==f)continue;
else if(!DFN[to[i]])
{
s.push(i);
Tarjan(to[i],x);
chkmin(LOW[x],LOW[to[i]]);
if(LOW[to[i]]>=DFN[x])
{
int temp;++cnt;
do{
temp=s.top();
s.pop();
len[cnt]+=was[temp];
if(out[temp]!=x||to[temp]!=to[i])sum[out[temp]]=0;
sum[out[temp]]+=sum[to[temp]]+was[temp];
if(out[temp]!=x)
{
Jie[0][out[temp]]=x;
Be[out[temp]]=cnt;
}
if(to[temp]!=x)
{
Jie[0][to[temp]]=x;
if(to[temp]!=to[i])Be[to[temp]]=cnt;
}
}while(out[temp]!=x||to[temp]!=to[i]);
}
}
else if(DFN[to[i]]<DFN[x])s.push(i),chkmin(LOW[x],DFN[to[i]]);
}
inline void dfs(int x,int f)
{
dep[x]=dep[f]+1;
for(register int i=beg[x];i;i=nex[i])
if(to[i]!=f)dfs(to[i],x);
}
inline int LCA(int u,int v,int &iu,int &iv)
{
if(dep[u]<dep[v])std::swap(u,v);
iu=iv=v;
int tmp=dep[u]-dep[v];
if(dep[u]>dep[v])
for(register int i=19;i>=0;--i)
if(tmp>>i&1)u=Jie[i][u];
if(u==v)return u;
for(register int i=19;i>=0;--i)
if(Jie[i][u]^Jie[i][v])u=Jie[i][u],v=Jie[i][v];
iu=u,iv=v;
return Jie[0][u];
}
int main()
{
for(register int i=1;i<=m;++i)
{
insert(u,v,w);insert(v,u,w);
}
SPFA(1);Tarjan(1,0);
e=0;memset(beg,0,sizeof(beg));
for(register int i=2;i<=n;++i)insert(i,Jie[0][i]),insert(Jie[0][i],i);
dfs(1,0);
for(register int j=1;j<=19;++j)
for(register int i=1;i<=n;++i)Jie[j][i]=Jie[j-1][Jie[j-1][i]];
while(Q--)
{