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 p = 1e9 + 7;
long long heights[7], ct = 1, mat[150][150], dp[150], dp2[150];
long long binary[8][3];
long long matt[150][150];
long long iden[150][150];
long long matt1[150][150];
void computemat(int mask1, int mask2) {
  mat[mask1][mask2] = 0;
  binary[0][0] = 1;
  binary[ct][0] = 1;
  int x1 = mask1, x2 = mask2;
  for (int i = 0; i < ct; ++i) {
    binary[i][1] = x1 % 2;
    binary[i][2] = x2 % 2;
    x1 /= 2;
    x2 /= 2;
  }
  for (int i = 0; i < 1 << (ct - 1); ++i) {
    int x = i;
    for (int j = 0; j < ct - 1; ++j) {
      binary[j + 1][0] = x % 2;
      x /= 2;
    }
    bool y1 = true;
    for (int i = 0; i < ct; ++i) {
      if (binary[i][0] && binary[i + 1][0] && binary[i][1] && binary[i][2])
        y1 = false;
    }
    mat[mask1][mask2] += y1;
  }
}
void times(long long mat1[150][150], long long mat2[150][150]) {
  for (int i = 0; i < 1 << ct; ++i)
    for (int j = 0; j < 1 << ct; ++j) matt1[i][j] = 0;
  for (int i = 0; i < 1 << ct; ++i)
    for (int j = 0; j < 1 << ct; ++j)
      for (int k = 0; k < 1 << ct; ++k)
        matt1[i][j] = (mat1[i][k] * mat2[k][j] + matt1[i][j]) % p;
  for (int i = 0; i < 1 << ct; ++i)
    for (int j = 0; j < 1 << ct; ++j) matt[i][j] = matt1[i][j];
}
void expt(int x) {
  if (x == 0) {
    for (int i = 0; i < 1 << ct; ++i)
      for (int j = 0; j < 1 << ct; ++j) {
        matt[i][j] = (i == j);
      }
    return;
  }
  int k = x / 2;
  expt(k);
  if (x % 2 == 0) {
    times(matt, matt);
  } else {
    times(matt, matt);
    times(matt, mat);
  }
}
int main() {
  for (int i = 0; i < 7; ++i) cin >> heights[i];
  for (int i = 0; i < 150; ++i) dp[i] = (i == 0) ? 1 : 0;
  for (int i = 0; i < 150; ++i)
    for (int j = 0; j < 150; ++j) iden[i][j] = mat[i][j] = (i == j);
  for (int i = 1; i <= 7; ++i) {
    ct = i;
    for (int j = 0; j < 1 << ct; ++j)
      for (int k = 0; k < 1 << ct; ++k) computemat(j, k);
    for (int i = 0; i < 1 << (ct - 1); ++i) {
      dp[i + (1 << (ct - 1))] = dp[i];
      dp[i] = 0;
    }
    expt(heights[i - 1]);
    for (int i = 0; i < 1 << ct; ++i) {
      dp2[i] = 0;
      for (int j = 0; j < 1 << ct; ++j)
        dp2[i] = (dp2[i] + dp[j] * matt[j][i]) % p;
    }
    for (int i = 0; i < 1 << ct; ++i) dp[i] = dp2[i];
  }
  cout << dp[127] << endl;
}