#include<bits/stdc++.h>
#ifdef xay5421
#define D(...) fprintf(stderr,__VA_ARGS__)
#else
#define D(...) ((void)0)
#endif
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)
#define each(x,v) for(auto&x:v)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
using namespace std;
template<class T>void rd(T&x){
	int f=0,c;
	while(c=getchar(),!isdigit(c))f^=!(c^45);
	x=c&15;
	while(c=getchar(),isdigit(c))x=x*10+(c&15);
	if(f)x=-x;
}
const int N=500005,K=20,P=998244353,M=640000;
inline int ad(int x,int y){return x+y>=P?x+y-P:x+y;}
inline void uad(int&x,int y){(x+=y)>=P&&(x-=P);}
inline int su(int x,int y){return x-y<0?x-y+P:x-y;}
inline void usu(int&x,int y){(x-=y)<0&&(x+=P);}
inline int mu(int x,int y){return 1ULL*x*y%P;}
int n,m,Q,dfn[N],low[N],ind,cnt,st[N],st_[N],top,tmp[N];
int pp,lnk[N],nxt[M*2],to[M*2],we[M*2];
vector<int>e[N*2];
vector<int>sum[N];
int fa[N*2][K],dep[N*2];
struct node{
	int x,y;
}F[N*2][K];
node unite(const node&lhs,const node&rhs){
	return (node){mu(lhs.x,rhs.x),ad(mu(lhs.x,rhs.y),mu(lhs.y,rhs.x))};
}
void ae(int k1,int k2,int k3){to[++pp]=k2,we[pp]=k3,nxt[pp]=lnk[k1],lnk[k1]=pp;}
void tarjan(int k1,int k2){
	dfn[k1]=low[k1]=++ind,st[++top]=k1,st_[top]=k2;
	for(int i=lnk[k1];i;i=nxt[i]){
		if(!dfn[to[i]]){
			tarjan(to[i],we[i]),low[k1]=min(low[k1],low[to[i]]);
			if(low[to[i]]>=dfn[k1]){
				++cnt;
				F[cnt+n][0]=(node){1,0};
				sum[cnt].pb(tmp[st[top]]);
				vector<int>nds;
				do{
					nds.pb(st[top]);
					sum[cnt].pb(st_[top]);
					e[cnt+n].pb(st[top]);
					// D("ae %d %d\n",cnt+n,st[top]);
					// e[st[top]].pb(cnt+n);
				}while(st[top--]!=to[i]);
				// e[cnt+n].pb(k1);
				e[k1].pb(cnt+n);
				// D("ae %d %d\n",k1,cnt+n);
				rep(i,1,SZ(sum[cnt])-1)uad(sum[cnt][i],sum[cnt][i-1]);
				if(SZ(nds)==1){
					each(x,nds)F[x][0]=(node){1,sum[cnt][0]};
				}else{
					each(x,nds)F[x][0]=(node){2,sum[cnt].back()};
				}
			}
		}
		else{
			if(dfn[to[i]]<low[k1]){
				low[k1]=dfn[to[i]];
				tmp[k1]=we[i];
			}
		}
	}
}
void dfs1(int k1,int k2){
	dep[k1]=dep[k2]+1;
	fa[k1][0]=k2;
	rep(i,1,K-1)fa[k1][i]=fa[fa[k1][i-1]][i-1],F[k1][i]=unite(F[k1][i-1],F[fa[k1][i-1]][i-1]);
	each(x,e[k1])dfs1(x,k1);
}
int LCA(int k1,int k2){
	if(dep[k1]<dep[k2])swap(k1,k2);
	int dt=dep[k1]-dep[k2];
	per(i,K-1,0)if(dt>>i&1)k1=fa[k1][i];
	if(k1==k2)return k1;
	per(i,K-1,0)if(fa[k1][i]!=fa[k2][i])k1=fa[k1][i],k2=fa[k2][i];
	return fa[k1][0];
}
node calc(int k1,int k2){
	node ret=(node){1,0};
	per(i,K-1,0)if(k2>>i&1)ret=unite(ret,F[k1][i]),k1=fa[k1][i];
	return ret;
}
int main(){
	freopen("simple.in","r",stdin);
	freopen("simple.out","w",stdout);
	rd(n),rd(m),rd(Q);
	rep(i,1,m){
		int u,v,w;
		rd(u),rd(v),rd(w);
		ae(u,v,w),ae(v,u,w);
	}
	tarjan(1,0);
	dfs1(1,0);
	while(Q--){
		int u,v;
		rd(u),rd(v);
		int lca=LCA(u,v);
		if(lca<=n){
			printf("%d\n",unite(calc(u,dep[u]-dep[lca]),calc(v,dep[v]-dep[lca])).y);
		}else{
			printf("%d\n",unite(calc(u,dep[u]-dep[lca]),calc(v,dep[v]-dep[lca]-1)).y);
		}
	}
	return 0;
}
