#include #include //小数点出力用 //cout << fixed << setprecision(10) << ans; #include #include #include #include #include #include #include #include using ll = long long; using namespace std; #define modPHash (ll)((1LL<<61)-1) #define modP (ll)998244353 bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); } int clk4(int num) { return (num - 2) * (num % 2); } void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vectorL(N), R(N); for (int i = 0;i < N;i++) { cin >> L[i] >> R[i]; } vectorV(N); for (int i = 0;i < N;i++)V[i] = i; int ans = 0; do { bool ok = 1; for (int i = 0;i < N - 1;i++) { for (int j = i + 1;j < N;j++) { if (R[V[j]] < L[V[i]]) { ok = 0; } } } if (ok) { ans++; } } while (next_permutation(V.begin(), V.end())); cout << ans; return 0; }