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 int N = 7;
struct B {
  int L, R, M;
  int n;
  bool check() {
    for (int i = 0; i < n; ++i) {
      if ((L >> i & 1) && (R >> i & 1) && (M >> i & 1) && (M >> i + 1 & 1))
        return 0;
    }
    return 1;
  }
} b;
const long long Mod = 1e9 + 7;
struct Mat {
  static int n;
  long long a[1 << N][1 << N];
  void clear(bool e) {
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) a[i][j] = 0;
    if (e)
      for (int i = 0; i < n; ++i) a[i][i] = 1;
  }
  Mat operator*(const Mat &o) {
    Mat r;
    r.clear(0);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        for (int k = 0; k < n; ++k) {
          r.a[i][j] += a[i][k] * o.a[k][j];
          r.a[i][j] %= Mod;
        }
      }
    }
    return r;
  }
  Mat operator^(int b) {
    Mat r, c(*this);
    r.clear(1);
    while (b) {
      if (b & 1) r = r * c;
      c = c * c;
      b >>= 1;
    }
    return r;
  }
} mt;
int Mat::n = 0;
long long dp[1 << N], tdp[1 << N];
int main() {
  int pre = -1;
  for (int i = 1; i <= N; ++i) {
    int w;
    scanf("%d", &w);
    if (!w) continue;
    if (pre == -1) {
      for (int R = 0; R < 1 << i; ++R) {
        for (int M = 0; M < 1 << i - 1; ++M) {
          b.L = (1 << i) - 1;
          b.R = R;
          b.M = 1 << 0 | M << 1 | 1 << i;
          b.n = i;
          dp[R] += b.check();
        }
      }
    } else {
      for (int s = 0; s < 1 << pre; ++s) tdp[s] = dp[s];
      int tL = 0;
      for (int j = pre; j < i; ++j) tL |= 1 << j;
      for (int R = 0; R < 1 << i; ++R) {
        dp[R] = 0;
        for (int L = 0; L < 1 << pre; ++L) {
          long long nu = 0;
          for (int M = 0; M < 1 << i - 1; ++M) {
            b.R = R;
            b.L = L | tL;
            b.M = 1 << 0 | M << 1 | 1 << i;
            b.n = i;
            nu += b.check();
          }
          dp[R] += tdp[L] * nu;
          dp[R] %= Mod;
        }
      }
    }
    mt.n = 1 << i;
    mt.clear(0);
    for (int R = 0; R < 1 << i; ++R) {
      for (int L = 0; L < 1 << i; ++L) {
        int nu = 0;
        for (int M = 0; M < 1 << i - 1; ++M) {
          b.R = R;
          b.L = L;
          b.M = 1 << 0 | M << 1 | 1 << i;
          b.n = i;
          nu += b.check();
        }
        mt.a[R][L] = nu;
      }
    }
    mt = mt ^ (w - 1);
    for (int s = 0; s < 1 << i; ++s) tdp[s] = dp[s];
    for (int R = 0; R < 1 << i; ++R) {
      dp[R] = 0;
      for (int L = 0; L < 1 << i; ++L) {
        dp[R] += tdp[L] * mt.a[R][L];
        dp[R] %= Mod;
      }
    }
    pre = i;
  }
  int ans = int(dp[(1 << pre) - 1]);
  printf("%d\n", ans);
  return 0;
}