#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,vector(3)); rep(i,n){ cin>>A[i][0]>>A[i][1]; A[i][2]=i; } sort(all(A)); ll ans=0; do{ ll base=0; bool f=true; for(auto I:A){ if(base>I[1]){ f=false; break; }else{ base=max(base,I[0]); } } ans+=f; }while(next_permutation(all(A))); cout<