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;
template <class T>
string ToString(T t) {
  stringstream s;
  s << t;
  return s.str();
}
template <class T>
void ToOther(T& t, string a) {
  stringstream s(a);
  s >> t;
}
int n = 130;
int A[130][130];
int R[130][130];
int temp[130][130];
void Get(int x) {
  memset(A, 0, sizeof(A));
  int d[130][2];
  for (int i = 0; i < (1 << x); i++)
    for (int k = 0; k < (1 << x); k++) {
      d[0][1] = 1;
      d[0][0] = 0;
      for (int t = 0; t < x; t++) {
        if ((i >> t & 1) && (k >> t & 1)) {
          d[t + 1][0] = (d[t][0] + d[t][1]) % 1000000007;
          d[t + 1][1] = d[t][0];
        } else {
          d[t + 1][0] = (d[t][0] + d[t][1]) % 1000000007;
          d[t + 1][1] = (d[t][0] + d[t][1]) % 1000000007;
        }
      }
      A[i][k] = d[x][1];
    }
}
void Mul(int a[130][130], int b[130][130]) {
  int r[130][130] = {0};
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++)
        r[i][j] = (r[i][j] + (long long)a[i][k] * b[k][j]) % 1000000007;
    }
  memcpy(a, r, sizeof(r));
}
void Pow(int a[130][130], int y) {
  int r[130][130] = {0};
  memcpy(r, temp, sizeof(temp));
  while (y) {
    if (y % 2) Mul(r, a);
    Mul(a, a);
    y /= 2;
  }
  memcpy(R, r, sizeof(r));
}
int main() {
  vector<pair<int, int> > v;
  for (int i = 0; i < 7; i++) {
    int t;
    scanf("%d", &t);
    if (t) v.push_back(pair<int, int>(i, t));
  }
  int r = -1;
  for (int i = 0; i < v.size(); i++) {
    int h = v[i].first + 1;
    int y = v[i].second;
    if (i == 0) {
      temp[0][(1 << h) - 1] = 1;
    }
    n = 1 << h;
    Get(h);
    Pow(A, y);
    if (i + 1 == v.size()) {
      r = R[0][(1 << h) - 1];
    } else {
      int h2 = v[i + 1].first + 1;
      int st = 0;
      for (int k = h; k < h2; k++) st |= (1 << k);
      memset(temp, 0, sizeof(temp));
      for (int k = 0; k < (1 << h); k++) temp[0][k | st] = R[0][k];
    }
  }
  cout << r << endl;
}