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>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int a, b, c, d, n, m, k;
int dp[2][1 << 7], ndp[2][1 << 7];
int mas[1 << 7][1 << 7], ans[1 << 7][1 << 7];
inline void add(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
int tmp[1 << 7][1 << 7], tt[1 << 7][1 << 7];
const long long modll = (long long)1000000007 << 31;
inline void mul(int a[][1 << 7], int b[][1 << 7], int n) {
  for (int _n((n)-1), i(0); i <= _n; i++) {
    for (int _n((n)-1), j(0); j <= _n; j++) {
      tt[i][j] = b[j][i];
    }
  }
  for (int _n((n)-1), i(0); i <= _n; i++) {
    for (int _n((n)-1), j(0); j <= _n; j++) {
      long long t = 0;
      for (int _n((n)-1), z(0); z <= _n; z++) {
        t += (long long)a[i][z] * tt[j][z];
        if (t >= modll) t -= modll;
      }
      tmp[i][j] = t % 1000000007;
    }
  }
  for (int _n((n)-1), i(0); i <= _n; i++)
    for (int _n((n)-1), j(0); j <= _n; j++) a[i][j] = tmp[i][j];
}
inline void step(int cnt, int j, int wi, int wi1, int dp[][1 << 7], int &now,
                 int &nx) {
  for (int _n((wi)-1), h(0); h <= _n; h++) {
    swap(now, nx);
    memset((dp[nx]), 0, sizeof(dp[nx]));
    int need = 0;
    if (!j && h >= wi1) need |= 1 << 0;
    if (!h) need |= 1 << 1;
    for (int _n((1 << wi) - 1), mask(0); mask <= _n; mask++) {
      if (!dp[now][mask]) continue;
      int cd = dp[now][mask];
      for (int _n((4) - 1), cm(0); cm <= _n; cm++) {
        if ((cm & need) != need) continue;
        if ((cm & 1 << 0) && (mask & 1 << h)) continue;
        int nmask = mask;
        if (h) {
          if (mask & 1 << (h - 1)) {
            if (~cm & 1 << 1) nmask ^= 1 << (h - 1);
          }
        }
        if (nmask & 1 << h) nmask ^= 1 << h;
        if (cm == 3) nmask |= 1 << h;
        add(dp[nx][nmask], cd);
      }
    }
  }
}
int main() {
  vector<pair<int, int> > w;
  for (int _n((7) - 1), i(0); i <= _n; i++) {
    scanf("%d", &a);
    if (a) w.push_back(make_pair(i + 1, a));
  }
  int now, nx;
  now = 1;
  nx = 0;
  dp[nx][0] = 1;
  int tot = 0;
  for (int _n(((int)((w).size())) - 1), i(0); i <= _n; i++) {
    if (w[i].second <= 1) {
      for (int _n((w[i].second) - 1), j(0); j <= _n; j++) {
        step(1, j, w[i].first, i == 0 ? 0 : w[i - 1].first, dp, now, nx);
      }
    } else {
      step(1, 0, w[i].first, i == 0 ? 0 : w[i - 1].first, dp, now, nx);
      memset((mas), 0, sizeof(mas));
      for (int _n((1 << w[i].first) - 1), m1(0); m1 <= _n; m1++) {
        memset((ndp), 0, sizeof(ndp));
        int cnow = 1, cnx = 0;
        ndp[cnx][m1] = 1;
        step(1, 1, w[i].first, i == 0 ? 0 : w[i - 1].first, ndp, cnow, cnx);
        for (int _n((1 << w[i].first) - 1), j(0); j <= _n; j++) {
          mas[m1][j] = ndp[cnx][j];
        }
      }
      int t = w[i].second - 1;
      memset((ans), 0, sizeof(ans));
      for (int _n((1 << w[i].first) - 1), j(0); j <= _n; j++) ans[j][j] = 1;
      while (t) {
        if (t % 2) mul(ans, mas, 1 << w[i].first);
        mul(mas, mas, 1 << w[i].first);
        t /= 2;
      }
      memset((dp[now]), 0, sizeof(dp[now]));
      for (int _n((1 << w[i].first) - 1), mask(0); mask <= _n; mask++) {
        for (int _n((1 << w[i].first) - 1), m2(0); m2 <= _n; m2++) {
          dp[now][mask] =
              (dp[now][mask] + (long long)ans[m2][mask] * dp[nx][m2]) %
              1000000007;
        }
      }
      swap(now, nx);
    }
  }
  printf("%d\n", dp[nx][0]);
}