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>
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("avx,tune=native")
using namespace std;
const long long mod = 1e9 + 7;
long long w[11];
vector<vector<long long> > mul(vector<vector<long long> >& a,
                               vector<vector<long long> >& b) {
  vector<vector<long long> > ret(a.size(), vector<long long>(a.size(), 0));
  for (long long i = 0; i < a.size(); i++)
    for (long long j = 0; j < a.size(); j++) ret[i][j] = 0;
  for (long long i = 0; i < a.size(); i++) {
    for (long long j = 0; j < a.size(); j++) {
      for (long long k = 0; k < a.size(); k++) {
        ret[i][j] += a[i][k] * b[k][j];
        ret[i][j] %= mod;
      }
    }
  }
  return ret;
}
vector<vector<long long> > Pow(vector<vector<long long> > a, long long k) {
  vector<vector<long long> > ret = a, m = a;
  k--;
  do {
    if (k & 1) ret = mul(ret, m);
    m = mul(m, m);
  } while (k >>= 1);
  return ret;
}
long long dp[1 << 7], tdp[1 << 7], pre;
void solve(long long x, long long times) {
  vector<vector<long long> > mat((1 << x), vector<long long>((1 << x), 0));
  for (long long st = 0; st < (1 << x); st++) {
    for (long long ed = 0; ed < (1 << x); ed++) {
      for (long long bt = 0; bt < (1 << (x - 1)); bt++) {
        long long add = 1;
        for (long long j = 0; j < x; j++) {
          long long cnt = 0;
          if (bt & (1 << j) || j == x - 1) cnt++;
          if (j == 0 || (bt & (1 << (j - 1)))) cnt++;
          if (st & (1 << j)) cnt++;
          if (ed & (1 << j)) cnt++;
          if (cnt == 4) add = 0;
        }
        if (add) mat[st][ed]++;
        if (mat[st][ed] >= mod) mat[st][ed] -= mod;
      }
    }
  }
  mat = Pow(mat, times);
  memset(tdp, 0, sizeof tdp);
  long long or_mask = 0;
  for (long long i = pre; i < x; i++) or_mask |= (1 << i);
  for (long long i = 0; i < (1 << x); i++) {
    for (long long j = 0; j < (1 << x); j++) {
      tdp[j] += dp[i] * mat[i | or_mask][j];
      tdp[j] %= mod;
    }
  }
  memcpy(dp, tdp, sizeof tdp);
  pre = x;
}
signed main() {
  for (long long i = 1; i <= 7; i++) cin >> w[i];
  for (long long i = 1; i <= 7; i++) {
    if (w[i]) {
      dp[(1 << i) - 1] = 1;
      break;
    }
  }
  for (long long i = 1; i <= 7; i++) {
    if (w[i]) {
      solve(i, w[i]);
    }
  }
  for (long long i = 7; i >= 1; i--) {
    if (w[i]) {
      cout << dp[(1 << i) - 1] << endl;
      return 0;
    }
  }
  return 0;
}