#include #include #include #include using namespace std; using namespace atcoder; using namespace __gnu_pbds; using ll=long long; using ld=long double; using vll=vector; using vvll=vector; using pll=pair; // using mint=modint; // template // using ordered_map=tree,rb_tree_tag,tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N; cin>>N; vectorevent; vll win(N,0); for(int i=0;i>s; for(int j=i+1;jseen(N,false); ll before=0; for(int i=1;iwin[0]&&!seen[win[i]])seen[win[i]]=true,before++; } ans=min(ans,before+1); return; } auto [a,b]=event[p]; win[a]++; self(self,p+1); win[a]--; win[b]++; self(self,p+1); win[b]--; }; dfs(dfs,0); cout<