import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } final long MOD = 1_000_000_000 + 7; long[] karamatsu_prob = new long[200]; long[] fac = new long[200]; long[] ifac = new long[200]; long pow(long a, long n) { long ret = 1; for (; n > 0; n >>= 1, a = a * a % MOD) { if (n % 2 == 1) { ret = ret * a % MOD; } } return ret; } long inv(long a) { return pow(a, MOD - 2); } { fac[0] = fac[1] = 1; ifac[0] = ifac[1] = 1; for (int i = 2; i < fac.length; ++i) fac[i] = fac[i - 1] * i % MOD; for (int i = 2; i < ifac.length; ++i) { ifac[i] = inv(fac[i]); } } long comb(int n, int k) { return fac[n] * ifac[k] % MOD * ifac[n - k] % MOD; } { karamatsu_prob[0] = 1; karamatsu_prob[1] = 1; for (int i = 2; i < karamatsu_prob.length; ++i) { for (int j = 0; j <= i - 1; j += 2) { karamatsu_prob[i] += karamatsu_prob[j] * karamatsu_prob[i - j - 1] % MOD * comb(i - 1, j) % MOD; karamatsu_prob[i] %= MOD; } } for (int i = 0; i < karamatsu_prob.length; ++i) { karamatsu_prob[i] = karamatsu_prob[i] * ifac[i] % MOD; } } void run() { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); ++N; long[] l = new long[N]; long[] r = new long[N]; HashSet set = new HashSet<>(); for (int i = 1; i < N; ++i) { l[i] = sc.nextLong(); r[i] = sc.nextLong(); set.add(l[i]); set.add(r[i]); // [l[i],r[i]) } set.add((long) 1e9); set.add((long) 1e9 + 1); l[0] = (long) 1e9; r[0] = (long) 1e9 + 1; long[] a = new long[set.size()]; int sz = 0; for (long v : set) { a[sz] = v; ++sz; } Arrays.sort(a); // [a[i],a[i+1]] long[][] p = new long[N][sz]; for (int i = 0; i < N; ++i) { for (int j = 0; j + 1 < sz; ++j) { if (!(l[i] <= a[j] && a[j + 1] <= r[i])) continue; p[i][j] = (a[j + 1] - a[j]) * inv(r[i] - l[i]) % MOD; } } long[][] prob = new long[N][sz]; prob[0][sz - 2] = 1; for (int t = 0; t + 1 < N; ++t) { for (int src = 0; src + 1 < sz; ++src) { for (int dst = 0; dst + 1 < sz; ++dst) { if ((t % 2 == 1 && src >= dst) || (t % 2 == 0 && src <= dst)) continue; long prob_cur = prob[t][src]; for (int i = 1; t + i < N; ++i) { prob_cur = prob_cur * p[t + i][dst] % MOD; if (prob_cur == 0) break; prob[t + i][dst] += prob_cur * karamatsu_prob[i] % MOD; prob[t + i][dst] %= MOD; } } } } long ans = 0; for (int i = 0; i < prob[N - 1].length; ++i) ans = (ans + prob[N - 1][i]) % MOD; System.out.println(ans); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }