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;
vector<vector<long long> > mat_prod(vector<vector<long long> > &A,
                                    vector<vector<long long> > &B) {
  int N = A.size(), i, j, k;
  vector<vector<long long> > C(N, vector<long long>(N, 0));
  for ((i) = 0; (i) < (int)(N); (i)++)
    for ((j) = 0; (j) < (int)(N); (j)++) {
      long long tmp = 0;
      for ((k) = 0; (k) < (int)(N); (k)++) {
        tmp += A[i][k] * B[k][j];
        if (k % 8 == 7) tmp %= 1000000007ll;
      }
      C[i][j] = tmp % 1000000007ll;
    }
  return C;
}
vector<vector<long long> > mat_power(vector<vector<long long> > &A,
                                     long long K) {
  int N = A.size(), i, j;
  vector<vector<long long> > ans(N, vector<long long>(N, 0));
  for ((i) = 0; (i) < (int)(N); (i)++) ans[i][i] = 1;
  for (i = 16; i >= 0; i--)
    if (K & (1ll << i)) break;
  for (; i >= 0; i--) {
    ans = mat_prod(ans, ans);
    if (K & (1ll << i)) ans = mat_prod(ans, A);
  }
  return ans;
}
int w[10];
long long dp[(1 << 7)];
long long dp2[(1 << 7)];
vector<vector<long long> > get_matrix(int K) {
  vector<vector<long long> > A((1 << K), vector<long long>((1 << K), 0));
  int i, j, k, k2;
  for ((i) = 0; (i) < (int)((1 << K)); (i)++)
    for ((j) = 0; (j) < (int)((1 << K)); (j)++)
      for ((k2) = 0; (k2) < (int)((1 << (K - 1))); (k2)++) {
        int k = k2 * 2 + 1 + (1 << K);
        if ((i & j & k & (k >> 1)) != 0) continue;
        A[i][j]++;
      }
  return A;
}
int main(void) {
  int i, j, k;
  for ((i) = 0; (i) < (int)(7); (i)++) cin >> w[i];
  vector<pair<int, int> > v;
  for ((i) = 0; (i) < (int)(7); (i)++)
    if (w[i] > 0) v.push_back(make_pair(i + 1, w[i]));
  int sz = v.size();
  int from = v[0].first;
  int to = v[sz - 1].first;
  dp[(1 << from) - 1] = 1;
  for ((i) = 0; (i) < (int)(sz); (i)++) {
    int K = v[i].first;
    vector<vector<long long> > A = get_matrix(K);
    vector<vector<long long> > B = mat_power(A, v[i].second);
    for ((j) = 0; (j) < (int)((1 << K)); (j)++) dp2[j] = 0;
    for ((j) = 0; (j) < (int)((1 << K)); (j)++)
      for ((k) = 0; (k) < (int)((1 << K)); (k)++)
        dp2[k] = (dp2[k] + dp[j] * B[j][k]) % 1000000007ll;
    if (i != sz - 1) {
      int mask = 0;
      for (j = v[i].first; j < v[i + 1].first; j++) mask |= (1 << j);
      for ((j) = 0; (j) < (int)(128); (j)++) dp[j] = 0;
      for ((j) = 0; (j) < (int)((1 << K)); (j)++) dp[j | mask] = dp2[j];
    }
  }
  cout << dp2[(1 << to) - 1] << endl;
  return 0;
}