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;
const int INF = 1e9 + 19;
const int MOD = 1e9 + 7;
const int n = 7;
const int sz = 1 << n;
void add(int& a, int b) {
  a = (a + b);
  if (a >= MOD) a -= MOD;
}
int tmp[sz];
struct Matrix {
  vector<vector<int> > data;
  int size;
  Matrix(int size) : size(size) { data.assign(size, vector<int>(size, 0)); }
  Matrix operator*(const Matrix& other) {
    assert(other.size == size);
    Matrix res(size);
    for (int j = 0; j < size; j++) {
      for (int i = 0; i < size; i++) tmp[i] = other.data[i][j];
      for (int i = 0; i < size; i++) {
        long long sum = 0;
        for (int k = 0; k < size; k++) sum += (data[i][k] * 1ll * tmp[k]) % MOD;
        res.data[i][j] = sum % MOD;
      }
    }
    return res;
  }
  void print(int sz) {
    cerr << "matrix =====================\n";
    for (int i = 0; i < sz; i++, cerr << endl)
      for (int j = 0; j < sz; j++) cerr << data[i][j] << " ";
  }
};
int w[N];
int use[n];
int cur;
void read() {
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
}
Matrix binPow(Matrix a, long long b) {
  Matrix res(a.size);
  for (int i = 0; i < a.size; i++) res.data[i][i] = 1;
  for (; b > 0; b /= 2) {
    if (b % 2 == 1) res = res * a;
    a = a * a;
  }
  return res;
}
void solve() {
  Matrix st(1);
  st.data[0][0] = 1;
  for (int step = 1; step <= n; step++) {
    Matrix go(1 << step);
    for (int mask = 0; mask < (1 << (step * 3 - 1)); mask++) {
      cur++;
      int mask1 = mask & ((1 << step) - 1);
      int mask2 = (mask >> step) & ((1 << (step - 1)) - 1);
      int mask3 = (mask >> (step * 2 - 1)) & ((1 << step) - 1);
      for (int i = 0; i < step; i++) {
        if ((mask1 >> i) & 1) use[i] = cur;
        if ((mask3 >> i) & 1) use[i] = cur;
      }
      for (int i = 0; i < step - 1; i++)
        if ((mask2 >> i) & 1) use[i] = use[i + 1] = cur;
      bool flag = 1;
      for (int i = 0; i < step; i++) flag &= use[i] == cur;
      if (flag) {
        go.data[mask1][mask3]++;
      }
    }
    Matrix res = binPow(go, w[step - 1]);
    Matrix tmp(1 << step);
    for (int i = 0; i < st.size; i++)
      for (int j = 0; j < st.size; j++) tmp.data[i][j] = st.data[i][j];
    st = tmp * res;
  }
  printf("%d\n", st.data[0][0]);
}
void printAns() {}
void stress() {}
int main() {
  if (1) {
    int k = 1;
    for (int tt = 0; tt < k; tt++) {
      read();
      solve();
      printAns();
    }
  } else {
    stress();
  }
  return 0;
}