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 int N = 100000 + 77, NN = 100 + 77, Mod = 1000000007;
struct Matrix {
  int n, m, M[NN][NN];
  Matrix(int n1, int m1) {
    n = n1;
    m = m1;
    Clear();
  }
  void Clear() {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        M[i][j] = 0;
      }
    }
  }
  void Identity() {
    Clear();
    if (n != m) {
      cerr << "Cannot Make Identity Matrix Not Compatible\n";
      return;
    }
    for (int i = 0; i < n; i++) {
      M[i][i] = 1;
    }
  }
  void Print() {
    cerr << "***\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cerr << M[i][j] << ' ';
      }
      cerr << '\n';
    }
    cerr << "***\n";
  }
  void Fill(int t) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        M[i][j] = t;
      }
    }
  }
  Matrix operator*(const Matrix &T) {
    Matrix R = Matrix(n, T.m);
    R.Clear();
    if (m != T.n) {
      cerr << "Matrices not Compatible for multiplying\n";
      return R;
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < T.m; j++) {
        for (int k = 0; k < m; k++) {
          R.M[i][j] = (R.M[i][j] + M[i][k] * 1ll * T.M[k][j]) % Mod;
        }
      }
    }
    return R;
  }
  Matrix operator+(const Matrix &T) {
    Matrix R = Matrix(n, m);
    R.Clear();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        R.M[i][j] = (M[i][j] + T.M[i][j]) % Mod;
      }
    }
    return R;
  }
  Matrix operator^(const long long t) {
    Matrix res = Matrix(n, m);
    res.Identity();
    if (t == 0) return res;
    Matrix T = Matrix(n, m);
    T.Clear();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        T.M[i][j] = M[i][j];
      }
    }
    long long p = t;
    while (p) {
      if (p & 1) {
        res = res * T;
      }
      p >>= 1;
      T = T * T;
    }
    return res;
  }
};
int n = 7, A, f[10][NN][NN], W[10], dp[10][NN];
int main() {
  for (int t = 1; t <= 7; ++t)
    for (int m1 = 0; m1 < (1 << t); ++m1)
      for (int m2 = 0; m2 < (1 << t); ++m2)
        for (int m3 = 0; m3 < (1 << (t - 1)); ++m3) {
          bool inc = 1;
          for (int p = 1; p <= t; ++p) {
            bool top = (p == 1) ? 1 : ((m3 & (1 << (p - 2))) > 0);
            bool bot = (p == t) ? 1 : ((m3 & (1 << (p - 1))) > 0);
            bool f1 = (m1 & (1 << (p - 1))) > 0;
            bool f2 = (m2 & (1 << (p - 1))) > 0;
            inc &= !(top & bot & f1 & f2);
          }
          f[t][m1][m2] += inc;
        }
  dp[0][0] = 1;
  for (int i = 1; i <= n; ++i) cin >> W[i];
  for (int i = 1; i <= n; ++i) {
    int sz = (1 << i);
    Matrix M = Matrix(sz, sz);
    for (int m1 = 0; m1 < sz; ++m1)
      for (int m2 = 0; m2 < sz; ++m2) M.M[m1][m2] = f[i][m1][m2];
    M = M ^ W[i];
    for (int m2 = 0; m2 < sz; ++m2)
      for (int m1 = 0; m1 < (sz >> 1); ++m1) {
        dp[i][m2] =
            (dp[i][m2] + dp[i - 1][m1] * 1ll * M.M[m1 + (1 << (i - 1))][m2]) %
            Mod;
      }
  }
  cout << dp[7][(1 << 7) - 1];
  return 0;
}