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 = 1e9 + 7;
bool dzn(char k) {
  if (k == 'a' || k == 'o' || k == 'i' || k == 'u' || k == 'e') return true;
  return false;
}
const int N = 128;
struct matrix {
  int n, m;
  long long a[N + 5][N + 5];
  matrix(int _n, int _m) : n(_n), m(_m) {}
  matrix operator*(matrix other) {
    matrix ans(n, other.m);
    for (int i = 0; i < (ans.n); ++i) {
      for (int j = 0; j < (ans.m); ++j) {
        ans.a[i][j] = 0;
        for (int k = 0; k < (m); ++k) {
          ans.a[i][j] += (a[i][k] * other.a[k][j]) % MOD;
          ans.a[i][j] %= MOD;
        }
      }
    }
    return ans;
  }
  void print() {
    cout << "[";
    for (int i = 0; i < (n); ++i) {
      cout << "[";
      for (int j = 0; j < (m); ++j) {
        cout << a[i][j];
        if (j != m - 1) {
          cout << ",";
        }
      }
      cout << "]";
      if (i != n - 1) cout << endl;
    }
    cout << "]" << endl;
  }
};
long long dp[8][2];
long long solve(int h, int m1, int m2) {
  dp[0][0] = 0;
  dp[0][1] = 1;
  for (long long i = (1); i <= (h); ++i) {
    dp[i][0] = dp[i - 1][0] + dp[i - 1][1];
    dp[i][1] = dp[i - 1][0];
    if (!(m1 & (1 << (i - 1)) && m2 & (1 << (i - 1)))) {
      dp[i][1] = dp[i][0];
    }
  }
  return dp[h][1];
}
int main() {
  ios_base::sync_with_stdio(false);
  matrix ans(1, 2);
  ans.a[0][1] = 1;
  for (int i = 0; i < (7); ++i) {
    matrix tv((1 << (i + 1)), (1 << (i + 1)));
    int w;
    cin >> w;
    for (long long m1 = (N - (1 << (i + 1))); m1 <= (N - 1); ++m1) {
      for (long long m2 = (N - (1 << (i + 1))); m2 <= (N - 1); ++m2) {
        tv.a[m1 - N + (1 << (i + 1))][m2 - N + (1 << (i + 1))] =
            solve(i + 1, m1, m2);
      }
    }
    for (int as = 0; as < (17); ++as) {
      if (w & (1 << as)) ans = ans * tv;
      tv = tv * tv;
    }
    matrix nw(1, (1 << (i + 2)));
    for (int in = 0; in < ((1 << (i + 2))); ++in) {
      if (in < (1 << (i + 1)))
        nw.a[0][in] = 0;
      else
        nw.a[0][in] = ans.a[0][in - (1 << (i + 1))];
    }
    ans = nw;
  }
  cout << ans.a[0][ans.m - 1] << endl;
  return 0;
}