#include using namespace std; using ll = long long; map mp; vector ans; vector vst; vector> E; template map compress(vector &A){ map comp; int N = A.size(), i=0; for (int i=0; i> N; vector X(N), A(N), v; for (int i=0; i> X[i]; for (int i=0; i> A[i]; for (int i=0; i mp = compress(v), rev; for (auto [x, y] : mp) rev[y] = x; M = mp.size(); E.resize(M); ans.resize(M, -2e9); vst.resize(M); for (int i=0; i=0; i--){ if (!vst[i]) dfs(i); } for (int i=0; i