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;
void solve();
void precalc();
clock_t start;
bool doing = true;
int main() {
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  precalc();
  cout.precision(10);
  cout << fixed;
  start = clock();
  int testNum = 1;
  while (t--) {
    solve();
  }
  return 0;
}
void precalc() {}
long long binpow(long long q, long long w, long long mod) {
  if (!w) return 1;
  if (w & 1) return q * binpow(q, w - 1, mod) % mod;
  return binpow(q * q % mod, w / 2, mod);
}
long long gcd(long long q, long long w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
long long mod = 1000000007;
vector<vector<long long>> mult(const vector<vector<long long>>& q,
                               const vector<vector<long long>>& w) {
  vector<vector<long long>> res(q.size(), vector<long long>(q[0].size(), 0));
  for (long long i = 0; i < q.size(); ++i) {
    for (long long k = 0; k < q.size(); ++k) {
      for (long long j = 0; j < q.size(); ++j) {
        res[i][j] += q[i][k] * w[k][j];
        res[i][j] %= mod;
      }
    }
  }
  return res;
}
void solve() {
  vector<long long> a(7);
  for (long long i = 0; i < 7; ++i) cin >> a[i];
  vector<long long> dp(2);
  dp[0] = 0;
  dp[1] = 1;
  for (long long n = 1; n <= 7; ++n) {
    long long sz = 1 << n;
    vector<vector<long long>> trans(sz, vector<long long>(sz, 0));
    vector<long long> cur(n + 1);
    for (long long mask1 = 0; mask1 < sz; ++mask1) {
      for (long long mask2 = 0; mask2 < sz; ++mask2) {
        cur.assign(n + 1, 0);
        cur[0] = 1;
        for (long long i = 0; i < n; ++i) {
          cur[i + 1] = cur[i];
          if ((mask1 & (1 << i)) && (mask2 & (1 << i)) ||
              (i == n - 2 && (mask1 & (1 << (i + 1))) &&
               (mask2 & (1 << (i + 1))))) {
            if (!(i == n - 2 && (mask1 & (1 << (i + 1))) &&
                  (mask2 & (1 << (i + 1)))))
              if (i > 0) {
                cur[i + 1] += cur[i - 1];
              }
          } else {
            cur[i + 1] += cur[i];
          }
          cur[i + 1] %= mod;
        }
        trans[mask1][mask2] = cur[n - 1];
      }
    }
    if (n == 1) {
      trans[1][1] = 0;
    }
    vector<vector<vector<long long>>> powers(20);
    powers[0] = trans;
    for (long long i = 1; i < 20; ++i) {
      powers[i] = mult(powers[i - 1], powers[i - 1]);
    }
    vector<vector<long long>> now(sz, vector<long long>(sz, 0));
    for (long long i = 0; i < sz; ++i) {
      now[i][i] = 1;
    }
    long long step = a[n - 1];
    for (long long i = 0; i < 30 && step > 0; ++i) {
      if (step & 1) {
        now = mult(now, powers[i]);
      }
      step >>= 1;
    }
    vector<long long> dp1(sz);
    for (long long i = 0; i < sz; ++i) {
      for (long long j = 0; j < sz; ++j) {
        dp1[i] += now[i][j] * dp[j];
        dp1[i] %= mod;
      }
    }
    dp.assign(sz * 2, 0);
    for (long long mask = 0; mask < sz; ++mask) {
      dp[mask + sz] = dp1[mask];
    }
  }
  long long ans = dp[(1 << 8) - 1] % mod;
  cout << ans << "\n";
}