Problem: You are given a figure on a grid representing stairs consisting of 7 steps. The width of the stair on height i is wi squares. Formally, the figure is created by consecutively joining rectangles of size wi × i so that the wi sides lie on one straight line. Thus, for example, if all wi = 1, the figure will look like that (different colors represent different rectangles):

<image>

And if w = {5, 1, 0, 3, 0, 0, 1}, then it looks like that:

<image>

Find the number of ways to color some borders of the figure's inner squares so that no square had all four borders colored. The borders of the squares lying on the border of the figure should be considered painted. The ways that differ with the figure's rotation should be considered distinct. 

Input

The single line of the input contains 7 numbers w1, w2, ..., w7 (0 ≤ wi ≤ 105). It is guaranteed that at least one of the wi's isn't equal to zero.

Output

In the single line of the output display a single number — the answer to the problem modulo 109 + 7.

Examples

Input

0 1 0 0 0 0 0


Output

1


Input

0 2 0 0 0 0 0


Output

7


Input

1 1 1 0 0 0 0


Output

9


Input

5 1 0 3 0 0 1


Output

411199181

Note

All the possible ways of painting the third sample are given below:

<image>

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int OO = 1e9;
const long long INF = 1e18;
const int irand(int lo, int hi) {
  return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;
}
const long long lrand(long long lo, long long hi) {
  return ((double)rand() / (RAND_MAX + 1.0)) * (hi - lo + 1) + lo;
}
template <typename T>
T getnum() {
  int sign = 1;
  T ret = 0;
  char c;
  do {
    c = getchar();
  } while (c == ' ' || c == '\n');
  if (c == '-')
    sign = -1;
  else
    ret = c - '0';
  while (1) {
    c = getchar();
    if (c < '0' || c > '9') break;
    ret = 10 * ret + c - '0';
  }
  return sign * ret;
}
inline void ini(int& x) { x = getnum<int>(); }
inline void scani(int& x) { scanf("%d", &x); }
const long long MOD = 1e9 + 7;
inline long long addmod(long long a, long long b) {
  if (a + b < MOD) return a + b;
  return a + b - MOD;
}
inline long long mulmod(long long a, long long b) { return (a * b) % MOD; }
const int N = 132;
struct mat {
  int n, m;
  int x[N][N];
  mat() {
    n = m = 0;
    memset(x, 0, sizeof x);
  }
} base[9];
mat operator*(const mat& a, const mat& b) {
  assert(a.m == b.n);
  mat ret;
  ret.n = a.n;
  ret.m = b.m;
  for (int i = 0; i < a.n; i++) {
    for (int j = 0; j < b.m; j++) {
      for (int k = 0; k < a.m; k++) {
        ret.x[i][j] = addmod(ret.x[i][j], mulmod(a.x[i][k], b.x[k][j]));
      }
    }
  }
  return ret;
}
inline void prec() {
  base[1].n = base[1].m = 2;
  base[1].x[0][0] = base[1].x[0][1] = base[1].x[1][0] = 1;
  base[1].x[1][1] = 0;
  for (int i = 2; i <= 7; i += 1) {
    base[i].n = base[i].m = 1 << i;
    for (int lmask = (1 << i) - 1; lmask >= 0; lmask--) {
      for (int midmask = (1 << (i - 1)) - 1; midmask >= 0; midmask--) {
        for (int rmask = (1 << i) - 1; rmask >= 0; rmask--) {
          bool fail = false;
          for (int j = 1, mm = 1; j <= i; j++, mm <<= 1) {
            bool yes = false;
            if (!(lmask & mm)) yes = true;
            if (!(rmask & mm)) yes = true;
            if (j < i && !(midmask & mm)) yes = true;
            if (j > 1 && !(midmask & (mm >> 1))) yes = true;
            if (!yes) {
              fail = true;
              break;
            }
          }
          if (!fail) base[i].x[lmask][rmask]++;
        }
      }
    }
  }
}
mat pow(mat a, int e) {
  assert(a.n == a.m);
  mat ret;
  ret.n = ret.m = a.n;
  for (int i = 0; i < ret.n; i++) ret.x[i][i] = 1;
  while (e) {
    if (e & 1) ret = ret * a;
    a = a * a;
    e >>= 1;
  }
  return ret;
}
int w[9];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout.setf(ios::fixed);
  cout.setf(ios::showpoint);
  cout.precision(10);
  prec();
  for (int i = 1; i <= 7; i += 1) cin >> w[i];
  mat ans;
  ans.n = 1;
  ans.m = 2;
  ans.x[0][1] = 1;
  for (int i = 1; i <= 7; i += 1) {
    ans = ans * pow(base[i], w[i]);
    if (i < 7) {
      for (int i = 0; i < ans.m; i++) {
        ans.x[0][ans.m + i] = ans.x[0][i];
        ans.x[0][i] = 0;
      }
      ans.m = ans.m << 1;
    }
  }
  cout << ans.x[0][ans.m - 1] << '\n';
  return 0;
}