#include using namespace std; using ll = long long; #define rep(i, s, n) for(int i=(0+s); i < (n+s); i++) //pair-> P template using P = pair; template struct item {T A, B, C;}; //secondとfirstが交わらないかチェック vector> canditates; vector visited; int N; void dfs(int depth, vector p){ if(depth==N){ canditates.push_back(p); return; } for(int i=0; i> N; visited.resize(N, false); vector> myvec(N); rep(i, 0, N) cin >> myvec[i].first >> myvec[i].second; dfs(0, {}); ll cnt=0; for(vector p: canditates){ bool ok=true; ll min_value=0; //最低限超えていてほしい値 for(int i=0; imyvec[p[i+1]].second || myvec[p[i+1]].second