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 GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N;
int A[8];
array<array<long long, 128>, 128> trans;
array<array<long long, 128>, 128> ex[17];
array<long long, 128> stor;
int ans;
array<long long, 128> mul(array<long long, 128> a,
                          array<array<long long, 128>, 128> b) {
  array<long long, 128> res;
  for (auto i = (0); i < (128); i++) res[i] = 0;
  for (auto i = (0); i < (128); i++) {
    for (auto j = (0); j < (128); j++) {
      res[j] += a[i] * b[i][j];
      res[j] %= 1000000007;
    }
  }
  return res;
}
array<long long, 128> fix(array<long long, 128> a, int m) {
  array<long long, 128> res;
  for (auto i = (0); i < (128); i++) res[i] = 0;
  for (auto i = (0); i < (128); i++) {
    if (i & m) continue;
    res[i + m] = a[i];
  }
  return res;
}
void work(int x) {
  ex[0] = trans;
  int p = min(12, 32 - __builtin_clz(x));
  for (auto e = (1); e < (p); e++) {
    for (auto i = (0); i < (128); i++) {
      for (auto j = (0); j < (128); j++) {
        ex[e][i][j] = 0;
        for (auto k = (0); k < (128); k++) {
          ex[e][i][j] += ex[e - 1][i][k] * ex[e - 1][k][j];
          ex[e][i][j] %= 1000000007;
        }
      }
    }
  }
  for (auto i = (p)-1; i >= (0); i--) {
    while (x >= (1 << i)) {
      x -= (1 << i);
      stor = mul(stor, ex[i]);
    }
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  stor[0] = 1;
  int rt = 0;
  for (auto i = (1); i < (8); i++) {
    int x;
    cin >> x;
    if (x == 0) continue;
    int extra = 0;
    for (auto k = (rt); k < (i); k++) extra += (1 << k);
    stor = fix(stor, extra);
    rt = i;
    for (auto j = (0); j < (128); j++)
      for (auto k = (0); k < (128); k++) trans[j][k] = 0;
    for (auto k = (0); k < (16384); k++) {
      if (!(k & (64 << i))) continue;
      bool bad = false;
      for (auto m = (i); m < (7); m++) {
        if (k & (1 << m)) bad = true;
        if (k & (128 << m)) bad = true;
      }
      if (bad) continue;
      for (auto j = (0); j < ((1 << i)); j++) {
        bad = false;
        if (((k & 129) == 129) && ((j & 1) == 1)) bad = true;
        for (auto m = (1); m < (7); m++) {
          if (((k & (193 << m)) == (193 << m)) && ((j & (1 << m)) == (1 << m)))
            bad = true;
        }
        if (bad) continue;
        trans[j][(k & 127)]++;
      }
    }
    work(x);
  }
  ans = stor[(1 << rt) - 1];
  cout << ans << '\n';
  return 0;
}