#include #define MAXN 2000005 #define INF INT_MAX using namespace std; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-48; ch=getchar(); } return x*f; } int n,m,Q; map e[MAXN]; int ans[MAXN]; bool vis[MAXN]; signed main(){ n=read();m=read();Q=read(); for(int i=0;i> q; ans[1]=INF; q.push(make_pair(INF,1)); while(!q.empty()){ auto v=q.top(); q.pop(); int i=v.second; if(vis[i]) continue; vis[i]=1; for(auto v:e[i]){ int j=v.first; int u=v.second; if(ans[j]