#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector> LR(N); int idx = 0; for(auto &[l,r,p] : LR) cin >> l >> r,p = idx++; sort(LR.begin(),LR.end()); int answer = 0; do{ int low = 0; for(auto [l,r,ign] : LR){ if(r < low){low = -1; break;} low = max(l,low); } answer += low != -1; }while(next_permutation(LR.begin(),LR.end())); cout << answer << endl; }