#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define all(x) (x).begin(), (x).end() using ll = long long; const ll MOD = 998244353; #include using namespace atcoder; using mint = modint998244353; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll n;cin>>n; vector> A(n); rep(i,n){ cin>>A[i].first>>A[i].second; } sort(all(A)); ll ans=0; do{ ll base=0; bool f=true; for(auto I:A){ if(base>I.second){ f=false; break; }else{ base=max(base,I.first); } } ans+=f; }while(next_permutation(all(A))); cout<