//パラレル3本以上あり // #include using namespace std; using ll=long long int; //T: 距離 S: ラベル(群) U: 群の演算 template struct ShortestNonzeroPath{ struct edge{ int from; int to; T cost; S label; int idx; //edge(){} bool operator<(edge e)const{ return from q; //shortest unorthodox path distance vector parent; S identity; int s; //始点 vector dist; vector depth; vector psi; vector> G; vector pred; priority_queue,vector>,greater<>> F; vector h; vector ans; int E; //辺数 U f; void add_edge(int from,int to,T cost,S label){ G[from].push_back({from,to,cost,label,E}); E++; } bool is_consistent(edge e){ if(f(psi[e.from],e.label)==psi[e.to]) return true; return false; } ShortestNonzeroPath(int V,int identity,int s,U f):V(V),inf(numeric_limits< T >::max()),q(V,inf), identity(identity),s(s),dist(V,inf),depth(V,inf),psi(V,identity), G(V),pred(V),ans(V),E(0),f(f){ } void build(){ h.resize(E,inf); Dijkstra(); Step1(); Step2(); while(F.size()) Step3(); ans.resize(V); for(int i=0;i; priority_queue,greater> que; dist[s]=0; psi[s]=identity; depth[s]=0; que.emplace(dist[s],s); while(!que.empty()){ T cost; int idx; tie(cost,idx)=que.top(); que.pop(); if(dist[idx] w; w[0]=root(e.from); w[1]=root(e.to); vector B; //3_1 end while(w[0]!=w[1]){ if(depth[w[0]]cost){ h[e.idx]=cost; F.emplace(cost,e); } } } } }; signed main(){ int N,M,K; cin>>N>>M>>K; auto f=[](int a,int b){return a^b;}; ShortestNonzeroPath S(N,0,N-1,f); while(M--){ int A,B,C; string X; cin>>A>>B>>C>>X; A--; B--; int x=0,x_=0; for(int i=0;i