#include <bits/stdc++.h> using namespace std; const int maxm = 64, maxn = 32004; int N, m; struct Stuff { int v, p, q; vector<Stuff> son; } stuff[maxm]; struct Node { int c, w; Node(int c, int w) : c(c), w(w) { } }; void dfs(vector<Node> &g, const St...