#include<bits/stdc++.h> using namespace std; int n,t,m; int main() { } int read() { int ans=0,flg=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')flg=-1;ch=getchar();} while(ch>='0'&&ch<='9'){ans=ans*10+ch-'0';ch=getchar();} return ans*flg; } int find(int x){if(f[x]==x)return x;else return f[x]=find(f[x]);} int ne,head[bow]; struct node{int nxt,to,dis;}eg[bow<<1]; void node(int u,int v,int val){eg[++ne].nxt=head[u];eg[ne].to=v;eg[ne].dis=val;head[u]=ne;} int dfs(int u,int fa) { for(int i=head[u];i;i=eg[i].nxt)if(eg[i].to!=fa)dfs(eg[i].to,u); } void spfa(){ queue<int> q; for(int i=1; i<=n; i++) dis[i]=INF; q.push(s); dis[s]=0; vist[s]=1; while(!q.empty()){ int u=q.front(); q.pop();vist[u]=0; for(int i=head[u];i;i=edge[i].next) if(dis[edge[i].to]>dis[u]+edge[i].dis){ dis[edge[i].to]=dis[u]+edge[i].dis; if(vist[edge[i].to]==0){vist[edge[i].to]=1;q.push(edge[i].to);} } } }