import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools import numpy as np MOD = 10 ** 9 + 7 m = map(int, read().split()) L, R = zip(*zip(m, m)) def solve(perm): U = 2 * 10 ** 4 + 10 dp = np.zeros(U, np.int64) dp[0] = 1 for i in range(7): j = perm.index(i) lo = L[j] hi = R[j] newdp = np.empty(U, np.int64) newdp[1:] = np.cumsum(dp[:-1]) dp = newdp dp[:lo] = 0 dp[hi + 1:] = 0 dp %= MOD return dp.sum() % MOD answer = 0 for p in itertools.permutations(range(7)): if min(p[1::2]) > max(p[::2]) or min(p[::2]) > max(p[1::2]): answer += solve(p) print(answer % MOD)