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 target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T>
ostream &operator<<(ostream &os, pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
void YES(bool t = true) { cout << (t ? "YES" : "NO") << endl; }
void Yes(bool t = true) { cout << (t ? "Yes" : "No") << endl; }
void yes(bool t = true) { cout << (t ? "yes" : "no") << endl; }
void NO(bool t = true) { cout << (t ? "NO" : "YES") << endl; }
void No(bool t = true) { cout << (t ? "No" : "Yes") << endl; }
void no(bool t = true) { cout << (t ? "no" : "yes") << endl; }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1000000001;
const long long INF = (long long)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
vector<int> dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
const long long MOD = 1000000007;
vector<vector<long long> > mul(vector<vector<long long> > &A,
                               vector<vector<long long> > &B) {
  vector<vector<long long> > C(A.size(), vector<long long>(B[0].size()));
  for (int i = 0; i < A.size(); i++) {
    for (int k = 0; k < B.size(); k++) {
      for (int j = 0; j < B[0].size(); j++) {
        C[i][j] = (C[i][j] + A[i][k] * B[k][j] % MOD) % MOD;
      }
    }
  }
  return C;
}
vector<long long> mul(vector<vector<long long> > &A, vector<long long> &B) {
  vector<long long> C(A.size());
  for (int i = 0; i < A.size(); i++) {
    for (int j = 0; j < B.size(); j++) {
      (C[i] += A[i][j] * B[j] % MOD) %= MOD;
    }
  }
  return C;
}
vector<vector<long long> > pow(vector<vector<long long> > A, long long n) {
  vector<vector<long long> > B(A.size(), vector<long long>(A.size()));
  for (int i = 0; i < A.size(); i++) {
    B[i][i] = 1;
  }
  while (n > 0) {
    if (n & 1) B = mul(B, A);
    A = mul(A, A);
    n >>= 1;
  }
  return B;
}
vector<vector<long long> > trans(int n) {
  int m = 1 << n;
  vector<vector<long long> > A(m, vector<long long>(m));
  for (int i = 0; i < (int)(1 << n); i++) {
    for (int j = 0; j < (int)(1 << n); j++) {
      for (int k = 0; k < (int)(1 << (n - 1)); k++) {
        bool ok = true;
        for (int l = 0; l < (int)(n); l++) {
          bool left = false, right = false, up = false, down = false;
          if (i & (1 << l)) left = true;
          if (j & (1 << l)) right = true;
          if (l == 0)
            down = true;
          else {
            if (k & (1 << (l - 1))) down = true;
          }
          if (l == n - 1)
            up = true;
          else {
            if (k & (1 << l)) up = true;
          }
          if (left and right and up and down) {
            ok = false;
            break;
          }
        }
        if (ok) A[j][i]++;
      }
    }
  }
  return A;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ;
  int n = 7;
  vector<int> w(n);
  for (int i = 0; i < (int)(n); i++) cin >> w[i];
  vector<long long> dp(1, 1);
  for (int i = 0; i < (int)(n); i++) {
    vector<long long> dp2;
    for (int i = 0; i < (int)(dp.size()); i++) dp2.push_back(0);
    for (int i = 0; i < (int)(dp.size()); i++) dp2.push_back(dp[i]);
    swap(dp, dp2);
    if (w[i] == 0) continue;
    vector<vector<long long> > A = trans(i + 1);
    vector<vector<long long> > An = pow(A, w[i]);
    dp = mul(An, dp);
  }
  cout << dp.back() << endl;
}