Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<bits/stdc++.h>#define IO ios::sync_with_stdio(false);\cin.tie(0);\cout.tie(0);using namespace std;typedef long long LL;const int maxn = 1e6+10;struct node{int from;int to;int next;} edge[maxn<<1];int head[maxn],tot;LL xx[maxn];LL nb[maxn];int n,q;void init(){memset(xx,0,sizeof xx);memset(nb,0,sizeof nb);memset(head,-1,sizeof(head));tot = 0;}void addedge(int u,int v){