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;
static const int n = 8;
static const int mod = 1000000007;
inline int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
inline int sub(int x, int y) { return add(x, mod - y); }
inline void inc(int &x, int y) { (x += y) >= mod && (x -= mod); }
inline void dec(int &x, int y) { (x -= y) < 0 && (x += mod); }
inline int mul(int x, int y) { return 1LL * x * y - 1LL * x * y / mod * mod; }
int a[n];
struct matrix {
  int mat[1 << n][1 << n];
  int row, col;
  matrix() { row = col = 0; }
  matrix(int r, int c) {
    row = r, col = c;
    for (int i = 0; i < row; ++i)
      for (int j = 0; j < col; ++j) mat[i][j] = 0;
  }
  matrix(int r, int c, int val) {
    if (r != c) assert(false);
    *this = matrix(r, c);
    for (int i = 0; i < row; ++i) mat[i][i] = val;
  }
  friend matrix operator*(const matrix &a, const matrix &b) {
    if (a.col != b.row) assert(false);
    matrix c(a.row, b.col);
    for (int i = 0; i < a.row; ++i)
      for (int j = 0; j < b.col; ++j)
        for (int k = 0; k < a.col; ++k)
          inc(c.mat[i][j], mul(a.mat[i][k], b.mat[k][j]));
    return c;
  }
  friend matrix operator^(matrix a, long long b) {
    if (a.row != a.col) assert(false);
    matrix ans(a.row, a.col, 1);
    while (b) {
      if (b & 1) ans = ans * a;
      a = a * a;
      b >>= 1;
    }
    return ans;
  }
};
inline bool valid(int num, int maskl, int maskr, int mask) {
  for (int i = 0; i < num; ++i) {
    if (~maskl & (1 << i)) continue;
    if (~maskr & (1 << i)) continue;
    if (i > 0 && (~mask & (1 << i - 1))) continue;
    if (i < num - 1 && (~mask & (1 << i))) continue;
    return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL), cout.tie(NULL);
  cout << fixed << setprecision(12);
  for (int i = 1; i < n; ++i) cin >> a[i];
  matrix ans(1 << 1, 1);
  ans.mat[1][0] = 1;
  for (int i = 1; i < n; ++i) {
    matrix trans(1 << i, 1 << i);
    for (int maskl = 0; maskl < (1 << i); ++maskl)
      for (int maskr = 0; maskr < (1 << i); ++maskr)
        for (int mask = 0; mask < (1 << i - 1); ++mask)
          if (valid(i, maskl, maskr, mask)) trans.mat[maskl][maskr]++;
    ans = (trans ^ a[i]) * ans;
    if (i < n - 1) {
      matrix nmat(1 << i + 1, 1 << i);
      for (int mask = 1 << i; mask < (1 << i + 1); ++mask)
        nmat.mat[mask][mask ^ (1 << i)] = 1;
      ans = nmat * ans;
    }
  }
  cout << ans.mat[(1 << n - 1) - 1][0] << endl;
  return 0;
}