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 long long MOD = 1000000007;
struct Matrix {
  int m, n;
  long long x[130][130];
} _transform, I;
Matrix operator*(const Matrix& a, const Matrix& b) {
  Matrix c;
  c.m = a.m;
  c.n = b.n;
  for (int i = 0, _a = (c.m); i < _a; i++)
    for (int j = 0, _a = (c.n); j < _a; j++) {
      c.x[i][j] = 0;
      for (int k = 0, _a = (a.n); k < _a; k++)
        c.x[i][j] = (c.x[i][j] + a.x[i][k] * b.x[k][j]) % MOD;
    }
  return c;
}
void init(int n) {
  I.m = I.n = (1 << (n));
  for (int i = 0, _a = (I.m); i < _a; i++)
    for (int j = 0, _a = (I.n); j < _a; j++) I.x[i][j] = (i == j) ? 1 : 0;
  _transform.m = _transform.n = (1 << (n));
  for (int cur = 0, _a = ((1 << (n))); cur < _a; cur++) {
    for (int next = 0, _a = ((1 << (n))); next < _a; next++) {
      _transform.x[cur][next] = 0;
      for (int add = 0, _a = ((1 << (n - 1))); add < _a; add++) {
        bool ok = true;
        for (int i = (1), _b = (n); i <= _b; i++) {
          int left = (cur & (1 << (i - 1)));
          int right = (next & (1 << (i - 1)));
          int up = (i == 1) ? 1 : (add & (1 << (i - 2)));
          int down = (i == n) ? 1 : (add & (1 << (i - 1)));
          if (left && right && up && down) {
            ok = false;
            break;
          }
        }
        if (ok) _transform.x[cur][next]++;
      }
    }
  }
}
int a[10];
vector<int> result[10];
Matrix p[30];
int main() {
  ios ::sync_with_stdio(false);
  cout << (fixed) << setprecision(9);
  while (cin >> a[1]) {
    for (int i = (2), _b = (7); i <= _b; i++) cin >> a[i];
    for (int i = (1), _b = (7); i <= _b; i++) {
      init(i);
      p[0] = _transform;
      for (int i = (1), _b = (29); i <= _b; i++) p[i] = p[i - 1] * p[i - 1];
      Matrix start;
      start.m = 1;
      start.n = (1 << (i));
      memset(start.x, 0, sizeof start.x);
      if (i == 1) {
        start.x[0][1] = 1;
      } else {
        for (int mask = 0, _a = ((1 << (i - 1))); mask < _a; mask++)
          start.x[0][mask * 2 + 1] = result[i - 1][mask];
      }
      Matrix target = start;
      for (int bit = 0, _a = (30); bit < _a; bit++)
        if ((a[i] & (1 << (bit)))) target = target * p[bit];
      result[i].resize((1 << (i)));
      for (int mask = 0, _a = (result[i].size()); mask < _a; mask++)
        result[i][mask] = target.x[0][mask];
    }
    cout << result[7][(1 << (7)) - 1] << endl;
  }
  return 0;
}