/* Things to notice: 1. do not calculate useless values 2. do not use similar names Things to check: 1. submit the correct file 2. time (it is log^2 or log) 3. memory 4. prove your naive thoughts 5. long long 6. corner case like n=0,1,inf or n=m 7. check if there is a mistake in the ds or other tools you use 8. fileio in some oi-contest 9. module on time 10. the number of a same divisor in a math problem 11. multi-information and queries for dp and ds problems */ #include using namespace std; #define int long long #define fi first #define se second #define pii pair #define mp make_pair #define pb push_back const int mod=998244353; const int inf=0x3f3f3f3f; const int INF=1e18; struct DSU { int fa[10005]; void init() { for(int i=1;i<=10000;i++) fa[i]=i; } int find(int x) { if(fa[x]==x) return x; return fa[x]=find(fa[x]); } void merge(int x,int y) { int xx=find(x),yy=find(y); if(xx!=yy) fa[xx]=yy; } }dsu[1<<10]; int n,m; int U[10005],V[10005]; int col[10005],sum[1<<10]; int W[10]; void solve() { cin>>n>>m; for(int i=1;i<=m;i++) cin>>U[i]>>V[i]; for(int i=1;i<=n;i++) cin>>col[i],col[i]--; for(int i=0;i<10;i++) cin>>W[i]; for(int mask=0;mask<(1<<10);mask++) { for(int j=0;j<10;j++) if(mask&(1<>Q; while(Q--) { int u,v; cin>>u>>v; int ans=INF; for(int mask=0;mask<(1<<10);mask++) if((mask&(1<>_; while(_--) solve(); return 0; }