import core.thread; import std.conv, std.stdio, std.string; import std.algorithm, std.array, std.bigint, std.container, std.math, std.range, std.regex; // Input class EOFException : Throwable { this() { super("EOF"); } } string[] tokens; string readToken() { for (; tokens.empty; ) { tokens = readln.split; if (stdin.eof) throw new EOFException; } auto token = tokens[0]; tokens.popFront; return token; } int readInt() { return to!int(readToken); } long readLong() { return to!long(readToken); } real readReal() { return to!real(readToken); } // chmin/chmax void chmin(T)(ref T t, in T f) { if (t > f) t = f; } void chmax(T)(ref T t, in T f) { if (t < f) t = f; } // Pair struct Pair(S, T) { S x; T y; int opCmp( const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; } int opCmp(ref const Pair p) const { return (x < p.x) ? -1 : (x > p.x) ? +1 : (y < p.y) ? -1 : (y > p.y) ? +1 : 0; } string toString() const { return "(" ~ to!string(x) ~ ", " ~ to!string(y) ~ ")"; } } auto pair(S, T)(inout(S) x, inout(T) y) { return Pair!(S, T)(x, y); } // Array int binarySearch(T)(in T[] as, in bool delegate(T) test) { int low = -1, upp = as.length; for (; low + 1 < upp; ) { int mid = (low + upp) >> 1; (test(as[mid]) ? low : upp) = mid; } return upp; } int lowerBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a < val); }); } int upperBound(T)(in T[] as, in T val) { return as.binarySearch((T a) { return (a <= val); }); } T[] unique(T)(in T[] as) { T[] bs; foreach (a; as) if (bs.empty || bs[$ - 1] != a) bs ~= a; return bs; } int root(int[] uf, int u) { return (uf[u] < 0) ? u : (uf[u] = uf.root(uf[u])); } bool conn(int[] uf, int u, int v) { u = uf.root(u); v = uf.root(v); if (u == v) return false; if (uf[u] > uf[v]) swap(u, v); uf[u] += uf[v]; uf[v] = u; return true; } immutable long MO = 10^^9 + 7; immutable long LIM = 20005; long calc(long[] a, long[] b) { int n = cast(int)(a.length); foreach (u; 0 .. n) { if (a[u] > b[u]) { return 0; } } debug{ // writeln("calc ",a," ",b); } long ret; foreach (h; 0 .. 1 << (n * (n - 1) / 2)) { auto uf = new int[n]; uf[] = -1; int pos; long s = +1; foreach (u; 0 .. n) foreach (v; u + 1 .. n) { if (h & 1 << pos++) { uf.conn(u, v); s *= -1; } } auto lbs = new long[n]; auto ubs = new long[n]; lbs[] = long.min; ubs[] = long.max; foreach (u; 0 .. n) { const r = uf.root(u); chmax(lbs[r], a[u]); chmin(ubs[r], b[u]); } long tmp = 1; foreach (r; 0 .. n) if (uf[r] < 0) { (tmp *= max(ubs[r] - lbs[r] + 1, 0)) %= MO; } (ret += s * tmp) %= MO; } return ret; } long[7] A, B; void main(string[] args) { try { for (; ; ) { foreach (i; 0 .. 7) { A[i] = readLong; B[i] = readLong; } long ans; foreach (phase; 0 .. 2) { foreach (x; -LIM .. +LIM) { // max(0,2,4,6) = x // 1,3,5 >= x + 1 const res0 = calc( [ A[0], A[2], A[4], A[6] ], [ min(B[0], x), min(B[2], x), min(B[4], x), min(B[6], x) ] ); const res1 = calc( [ A[0], A[2], A[4], A[6] ], [ min(B[0], x - 1), min(B[2], x - 1), min(B[4], x - 1), min(B[6], x - 1) ] ); const res2 = calc( [ max(A[1], x + 1), max(A[3], x + 1), max(A[5], x + 1) ], [ B[1], B[3], B[5] ] ); (ans += (res0 - res1) * res2) %= MO; } A[] *= -1; B[] *= -1; swap(A, B); } ans = (ans % MO + MO) % MO; writeln(ans); // break; } } catch (EOFException) {} }