#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int N=1000010,mod=998244353;
int ksm(int a,int b=mod-2)
{
	int r=1;
	for(;b;b>>=1,a=1ll*a*a%mod) if(b&1) r=1ll*r*a%mod;
	return r;
}
int nxt[N<<1],to[N<<1],w[N<<1],head[N],cnt,n,m,q;
void add(int u,int v,int w0){nxt[++cnt]=head[u];w[cnt]=w0;to[cnt]=v;head[u]=cnt;}
typedef long long ll;
namespace simple{
	int dfn[N],low[N],idx;
	int ton[N],tp;
	int sc[N],id[N],ct;
	int dis[N];
	vector<int>g[N];
	struct node{
		int v,c;
		node(int v=0,int c=0):v(v),c(c){}
	}s[N][20];
	node operator +(node a,node b){return node((1ll*a.v*b.c+1ll*a.c*b.v)%mod,1ll*a.c*b.c%mod);}
	int fa[N],f[N][20],dep[N];
	void dfs(int u,int p)
	{
		dfn[u]=low[u]=++idx;
		ton[++tp]=u;
		for(int i=head[u];i;i=nxt[i])
		{
			int v=to[i];if(v==p) continue;
			if(!dfn[v])
			{
				dfs(v,u);
				low[u]=min(low[u],low[v]);
				if(low[v]>=dfn[u])
				{
					++ct;g[ct].push_back(u),g[u].push_back(ct);
					int x=ton[tp--];
					if(v==x)
					{
						g[v].push_back(ct),g[ct].push_back(v),dis[v]=dis[ct]=w[i];
						continue;
					}
					int pre=u,dpre=0;
					for(;low[x]>=dfn[u] && x!=u;x=ton[tp--])
					{
						g[ct].push_back(x),g[x].push_back(ct),sc[x]=ct;
						for(int i=head[x];i;i=nxt[i]) if(to[i]==pre){dpre=(dpre+w[i])%mod;break;}
						dis[x]=dpre,pre=x;
					}
					dis[ct]=(dpre+w[i])%mod;
					ton[++tp]=x;
				}
			}
			else low[u]=min(low[u],dfn[v]);
		}
	}
	void dfs2(int u,int p)
	{
		fa[u]=p,dep[u]=dep[p]+1;
		for(int v:g[u]) if(v!=p) dfs2(v,u);
	}
	int calc(int x,int y)
	{
		if(dep[x]<dep[y]) swap(x,y);
		node w(0,1);
		for(int i=19;i>=0;i--) if(dep[f[x][i]]>=dep[y]) w=w+s[x][i],x=f[x][i];
		if(x==y) return w.v;
		for(int i=19;i>=0;i--) if(f[x][i]!=f[y][i]) w=w+s[x][i]+s[y][i],x=f[x][i],y=f[y][i];
		w=w+s[x][0];
		return w.v;
	}
	void solve()
	{
		ct=n;dfs(1,0);
		dfs2(1,0);
		for(int i=2;i<=ct;i++)
		{
			f[i][0]=fa[i];
			if(i<=n)
			{
				if(g[fa[i]].size()==2) s[i][0]=node(dis[fa[i]],1);
				else s[i][0]=node(dis[fa[i]],2);
			}
			else s[i][0]=node(0,1);
		}
		for(int d=1;1<<d<=ct;d++)
			for(int i=1;i<=ct;i++)
			{
				f[i][d]=f[f[i][d-1]][d-1];
				if(f[i][d]) s[i][d]=s[i][d-1]+s[f[i][d-1]][d-1];
			}
		while(q --> 0)
		{
			int x,y;scanf("%d%d",&x,&y);
			printf("%d\n",calc(x,y));
		}
	}
}
int main()
{
	freopen("simple.in","r",stdin);
	freopen("simple.out","w",stdout);
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1,x,y,z;i<=m;i++) scanf("%d%d%d",&x,&y,&z),add(x,y,z),add(y,x,z);
	simple::solve();
	return 0;
}
