#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; namespace my_io{ template istream& operator >> (istream& is, vector& vec){for(T& val: vec) is >> val; return is;} template istream& operator , (istream& is, T& val){ return is >> val;} template ostream& operator << (ostream& os, const vector& vec){for(int i=0; i ostream& operator , (ostream& os, const T& val){ return os << " " << val;} template ostream& operator >> (ostream& os, const T& val){ return os << " " << val;} template void println(const H& head){ cout << head << endl; } template void println(const H& head, const T& ... tail){ cout << head << " "; println(tail...); } } using namespace my_io; namespace Montgomery{ template constexpr long long PRE_COMP(long long r, long long res=0, long long t=0, long long i = 1){ return (r>1) ? ( PRE_COMP(r/2, res + (t%2==0?i:0), (t%2==0?(t+MOD):t) / 2, i*2) ):( res ); } template class Values{ public: static constexpr long long R = 1LL<<30; // R>MOD && gcd(R,MOD)==1 static constexpr long long mask = (1LL<<30)-1; static constexpr long long R2 = (R*R)%MOD; static constexpr long long Ninv = PRE_COMP(1<<30); // N*Ninv = R-1 mod R static long long Reduction(long long x){ long long s = ((x & mask) * Ninv) & mask; long long ret = (x + s*MOD ) >> 30; if(ret>=MOD) ret -= MOD; return ret; } }; template struct M_Int{ long long value; M_Int() : value(0) {} M_Int(long long val, bool convert=true) : value(convert ? Values::Reduction(val * Values::R2) : val){} //convert==true : int -> M_Int, false : M_Int::value -> M_Int M_Int(const M_Int& x) : value( x.value ){} //M_Int -> M_Int M_Int& operator = (const M_Int& x){ value = x.value; return *this; } M_Int& operator = (const long long& x){ value = Values::Reduction(x * Values::R2); return *this; } M_Int operator * (const M_Int& x) { return M_Int( Values::Reduction(value * x.value) , false ); } M_Int operator * (const long long& x){ return (*this) * M_Int(x); } template M_Int& operator *= (const T& x){ return (*this) = (*this)*x; } M_Int operator + (const M_Int& x) { long long tmp = value + x.value; if(tmp >= MOD) tmp -= MOD; return M_Int(tmp, false); } M_Int operator + (const long long& x){ return (*this)+M_Int(x); } template M_Int& operator += (const T& x) { return (*this) = (*this) + x; } M_Int operator - (const M_Int& x) { long long tmp = value - x.value; if(tmp < 0 ) tmp += MOD; return M_Int(tmp, false); } M_Int operator - (const long long& x){ return (*this)-M_Int(x); } template M_Int& operator -= (const T& x) { return (*this) = (*this) - x; } bool operator == (const M_Int& x){ return value == x.value; } bool operator == (const long long& x){ M_Int tmp(x); return (*this)==tmp; } long long to_i () { // M_int -> int return Values::Reduction(value); } operator long long () { // M_int -> int return Values::Reduction(value); } }; template istream& operator>>(istream& is, M_Int& v){ long long tmp; is >> tmp; v=tmp; return is; } template ostream& operator<<(ostream& os, M_Int v){ return os << v.to_i(); } } using mint = Montgomery::M_Int<1000000007>; int main(){ vector> v(7, vector(2)); cin >> v; int low = 1; int high = 20000; vector A = {0,2,4,6}; vector B = {1,3,5}; mint ans = 0; {//A < B vector> dp_A(1<<4, vector(20005,0)); vector> dp_A_ok(1<<4, vector(20005,0)); vector> dp_B(1<<3, vector(20005,0)); vector> dp_B_ok(1<<3, vector(20005,0)); for(int a=low; a<=high; a++){ for(int k=0; k<(1<<4)-1; k++){ dp_A[k][a] += dp_A[k][a-1]; for(int x=0; x<4; x++){ if((k>>x)&1) continue; if(a < v[A[x]][0] || v[A[x]][1] < a) continue; dp_A[k|(1<=low; a--){ for(int k=0; k<(1<<3); k++){ dp_B[k][a] += dp_B[k][a+1]; for(int x=0; x<3; x++){ if((k>>x)&1) continue; if(a < v[B[x]][0] || v[B[x]][1] < a) continue; dp_B[k|(1< B vector> dp_A(1<<4, vector(20005,0)); vector> dp_A_ok(1<<4, vector(20005,0)); vector> dp_B(1<<3, vector(20005,0)); vector> dp_B_ok(1<<3, vector(20005,0)); for(int a=high; a>=low; a--){ for(int k=0; k<(1<<4); k++){ dp_A[k][a] += dp_A[k][a+1]; for(int x=0; x<4; x++){ if((k>>x)&1) continue; if(a < v[A[x]][0] || v[A[x]][1] < a) continue; dp_A[k|(1<>x)&1) continue; if(a < v[B[x]][0] || v[B[x]][1] < a) continue; dp_B[k|(1<