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 <typename T>
inline bool maxit(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool minit(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
inline long long gint() {
  char c = getchar();
  int f = 1;
  while (c < '0' || c > '9') {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  long long a = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') {
    a = a * 10 + c - '0';
  }
  return a * f;
}
const int MOD = int(1e9 + 7);
typedef long long Mat[1 << 7][1 << 7];
typedef long long Vec[1 << 7];
int n;
void mat_mul(Mat A, Mat B, Mat res) {
  static Mat C;
  for (int i = 0, _end_ = (n); i < _end_; i++)
    for (int j = 0, _end_ = (n); j < _end_; j++) C[i][j] = 0;
  for (int i = 0, _end_ = (n); i < _end_; i++)
    for (int k = 0, _end_ = (n); k < _end_; k++)
      for (int j = 0, _end_ = (n); j < _end_; j++) {
        C[i][j] += A[i][k] * B[k][j] % MOD;
        if (C[i][j] >= MOD) {
          C[i][j] -= MOD;
        }
      }
  for (int i = 0, _end_ = (n); i < _end_; i++)
    for (int j = 0, _end_ = (n); j < _end_; j++) res[i][j] = C[i][j];
}
void mat_pow(Mat A, long long k, Mat res) {
  static Mat a, r;
  for (int i = 0, _end_ = (n); i < _end_; i++)
    for (int j = 0, _end_ = (n); j < _end_; j++) {
      a[i][j] = A[i][j];
      r[i][j] = i == j;
    }
  while (k) {
    if (k & 1) {
      mat_mul(r, a, r);
    }
    if (!(k >>= 1)) {
      break;
    }
    mat_mul(a, a, a);
  }
  for (int i = 0, _end_ = (n); i < _end_; i++)
    for (int j = 0, _end_ = (n); j < _end_; j++) res[i][j] = r[i][j];
}
void transform(Mat A, Vec v, Vec res) {
  static Vec r;
  for (int i = 0, _end_ = (n); i < _end_; i++) r[i] = 0;
  for (int i = 0, _end_ = (n); i < _end_; i++)
    for (int j = 0, _end_ = (n); j < _end_; j++) {
      r[i] += A[i][j] * v[j] % MOD;
      if (r[i] >= MOD) {
        r[i] -= MOD;
      }
    }
  for (int i = 0, _end_ = (n); i < _end_; i++) res[i] = r[i];
}
Mat A;
Vec v;
int w[7];
int m;
int code[7], mask;
int _down[7], _left[8];
inline void decode(int key, int* code) {
  for (int i = m - 1; i >= 0; i--) {
    code[i] = key & 1;
    key >>= 1;
  }
}
inline int encode(int* code) {
  int key = 0;
  for (int i = 0; i < m; i++) {
    key = key << 1 | code[i];
  }
  return key;
}
inline bool covered(int x) {
  return code[x] && _down[x] && _left[x] && _left[x + 1];
}
void dfs(int cur, int tmp) {
  if (tmp == 2) {
    cur++;
    tmp = 0;
  }
  if (cur > 0 && tmp == 1) {
    if (covered(cur - 1)) {
      return;
    }
  }
  if (cur == m && tmp == 0) {
    if (covered(cur - 1)) {
      return;
    }
    A[mask][encode(_down)]++;
    return;
  }
  if (tmp) {
    _down[cur] = true;
    dfs(cur, tmp + 1);
    _down[cur] = false;
    dfs(cur, tmp + 1);
  } else {
    _left[cur] = true;
    dfs(cur, tmp + 1);
    _left[cur] = false;
    dfs(cur, tmp + 1);
  }
}
void print(Mat A) {
  for (int i = 0, _end_ = (n); i < _end_; i++) {
    for (int j = 0, _end_ = (n); j < _end_; j++) {
      cerr << A[i][j] << " ";
    }
    cout << endl;
  }
}
int main() {
  for (int i = 0, _end_ = (7); i < _end_; i++) {
    w[i] = gint();
  }
  v[0] = 1;
  for (m = 1; m <= 7; m++) {
    for (int i = 0, _end_ = ((1 << (m - 1))); i < _end_; i++) {
      v[i | (1 << (m - 1))] = v[i];
      v[i] = 0;
    }
    if (w[m - 1] == 0) {
      continue;
    }
    n = 1 << m;
    memset((A), 0, sizeof((A)));
    _left[0] = _left[m] = true;
    for (mask = 0; mask < n; mask++) {
      decode(mask, code);
      dfs(0, 1);
    }
    _left[0] = _left[m] = false;
    mat_pow(A, w[m - 1], A);
    transform(A, v, v);
  }
  printf("%d\n", int(v[(1 << 7) - 1]));
  return 0;
}