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;
#pragma GCC optimize("Ofast")
const long long int maxn = (1 << 7) + 16, md = 1e9 + 7, inf = 2e18;
long long int tav(long long int n, long long int k) {
  long long int res = 1;
  while (k > 0) {
    if (k & 1) {
      res *= n;
      res %= md;
    }
    n *= n;
    n %= md;
    k >>= 1;
  }
  return res;
}
struct matrix {
  long long int n, m;
  long long int a[maxn][maxn];
  void init(long long int x, long long int y) {
    n = x;
    m = y;
    return;
  }
  void build(vector<vector<long long int>> &z) {
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        a[i][j] = z[i][j];
      }
    }
    return;
  }
  void def(bool k) {
    memset(a, 0, sizeof(a));
    if (k)
      for (long long int i = 0; i < n; i++) a[i][i] = 1;
    return;
  }
  friend matrix operator*(matrix a, matrix b) {
    matrix res;
    res.init(a.n, b.m);
    res.def(0);
    long long int n = a.n;
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < n; j++) {
        for (long long int k = 0; k < n; k++) {
          res.a[i][j] += 1ll * a.a[i][k] * b.a[k][j] % md;
          if (res.a[i][j] >= md) res.a[i][j] -= md;
        }
      }
    }
    return res;
  }
  friend void operator*=(matrix &a, matrix b) {
    a = a * b;
    return;
  }
  friend matrix operator^(matrix a, long long int k) {
    matrix res;
    res.init(a.n, a.n);
    res.def(1);
    long long int n = a.n;
    while (k > 0) {
      if (k & 1) {
        res *= a;
      }
      a *= a;
      k >>= 1;
    }
    return res;
  }
  friend void operator^=(matrix &a, long long int k) {
    a = a ^ k;
    return;
  }
};
vector<vector<long long int>> z[7], h;
matrix a[7], x;
matrix ans, tmp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  for (long long int e = 0; e < 7; e++) {
    long long int lm = 1 << (e + 1);
    z[e].resize(lm);
    for (long long int mask = 0; mask < lm; mask++) {
      z[e][mask].resize(lm);
      for (long long int ksam = 0; ksam < lm; ksam++) {
        long long int f = 0, g = 1;
        for (long long int j = e; j >= 0; j--) {
          long long int a = f, b = g;
          f = g + f;
          g = f;
          if (!(mask & (1 << j)) & !(ksam & (1 << j))) g = a;
        }
        z[e][mask][ksam] = g;
      }
    }
    a[e].init(lm, lm);
    a[e].build(z[e]);
  }
  for (long long int i = 0; i < 7; i++) {
    long long int k;
    cin >> k;
    a[i] ^= k;
  }
  long long int lm = 1 << 7;
  ans.init(lm, lm);
  ans.def(1);
  h.resize(lm);
  for (long long int i = 0; i < lm; i++) h[i].assign(lm, 0);
  for (long long int i = 0; i < 7; i++) {
    long long int q = 1 << (i + 1);
    for (long long int j = 0; j < q; j++) {
      for (long long int k = 0; k < q; k++) {
        h[j][k] = a[i].a[j][k];
      }
    }
    tmp.init(lm, lm);
    tmp.build(h);
    ans *= tmp;
  }
  cout << ans.a[0][0] << '\n';
  return 0;
}