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;
int mod = 1e9 + 7;
struct matrix {
  int A[200][200];
  int n;
  matrix(int x = 0, int _n = 0) {
    n = _n;
    memset(A, 0, sizeof A);
    for (int i = (0); i < (n); ++i) A[i][i] = x;
  }
  friend matrix operator*(const matrix &a, const matrix &b) {
    long long int mod2 = mod * 1LL * mod;
    matrix res(0, a.n);
    for (int i = (0); i < (a.n); ++i)
      for (int j = (0); j < (a.n); ++j) {
        long long int act = 0;
        for (int k = (0); k < (a.n); ++k) {
          act += a.A[i][k] * 1LL * b.A[k][j];
          if (act >= mod2) act -= mod2;
        }
        res.A[i][j] = act % mod;
      }
    return res;
  }
  friend vector<int> operator*(const matrix &a, const vector<int> &v) {
    vector<int> res;
    for (int i = (0); i < (a.n); ++i) {
      long long int act = 0;
      for (int k = (0); k < (a.n); ++k) {
        act += a.A[i][k] * 1LL * v[k];
        act %= mod;
      }
      res.push_back(act);
    }
    return res;
  }
};
matrix power(matrix a, int b) {
  matrix res(1, a.n);
  for (; b; b >>= 1, a = a * a)
    if (b & 1) res = res * a;
  return res;
}
int dp[200][200][10][3];
int ile(int m1, int m2, int l, int jest) {
  if (l == 1) {
    if (m1 == 1 && m2 == 1 && jest == 1)
      return 0;
    else
      return 1;
  }
  if (dp[m1][m2][l][jest] != -1) return dp[m1][m2][l][jest];
  int x1 = m1 % 2, x2 = m2 % 2;
  dp[m1][m2][l][jest] = ile(m1 / 2, m2 / 2, l - 1, 0);
  if (x1 != 1 || x2 != 1 || jest != 1) {
    dp[m1][m2][l][jest] += ile(m1 / 2, m2 / 2, l - 1, 1);
    dp[m1][m2][l][jest] %= mod;
  }
  return dp[m1][m2][l][jest];
}
matrix t[10];
int main() {
  for (int i = (0); i < (1 << 7); ++i)
    for (int j = (0); j < (1 << 7); ++j)
      for (int k = (0); k < (9); ++k)
        for (int l = (0); l < (3); ++l) dp[i][j][k][l] = -1;
  for (int k = (0); k < (7); ++k) {
    for (int i = (0); i < (1 << (k + 1)); ++i)
      for (int j = (0); j < (1 << (k + 1)); ++j)
        for (int l = (0); l < (2); ++l)
          dp[i][j][k + 1][l] = ile(i, j, k + 1, l);
  }
  vector<int> v;
  v.push_back(0);
  v.push_back(1);
  for (int i = (1); i < (8); ++i) {
    for (int j = (0); j < (1 << i); ++j)
      for (int k = (0); k < (1 << i); ++k) {
        t[i].n = (1 << i);
        t[i].A[j][k] = dp[j][k][i][1];
      }
  }
  for (int i = (1); i < (8); ++i) {
    int(w);
    scanf("%d", &(w));
    ;
    vector<int> v2 = power(t[i], w) * v;
    for (int k = (0); k < ((1 << i)); ++k) v[k] = 0;
    for (int k = (0); k < ((1 << i)); ++k) v.push_back(v2[k]);
  }
  printf("%d\n", v.back());
  return 0;
}