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;
vector<vector<long long>> exm;
vector<vector<long long>> mult(vector<vector<long long>> a,
                               vector<vector<long long>> b) {
  vector<vector<long long>> x = a;
  int m1, m2, m3;
  for (m1 = 0; m1 < x.size(); m1++)
    for (m2 = 0; m2 < x.size(); m2++) x[m1][m2] = 0;
  for (m1 = 0; m1 < x.size(); m1++)
    for (m2 = 0; m2 < x.size(); m2++)
      for (m3 = 0; m3 < x.size(); m3++) {
        x[m1][m2] += (a[m1][m3] * b[m3][m2]) % 1000000007ll;
        x[m1][m2] %= 1000000007ll;
      }
  return x;
}
vector<vector<long long>> binpow(vector<vector<long long>> a, int n) {
  vector<vector<long long>> res = a;
  n--;
  while (n > 0)
    if (n & 1) {
      res = mult(res, a);
      --n;
    } else {
      a = mult(a, a);
      n /= 2;
    }
  return res;
}
int n = 7;
long long a[10], best, dp[10][(1 << 8) + 5];
vector<vector<long long>> nxt, now;
vector<pair<long long, int>> v;
long long comb(int m1, int m2, int n) {
  vector<long long> c(2);
  c[1] = 1;
  for (int i = 1; i <= n; i++) {
    int bit = 1 << (i - 1);
    if ((bit & m1) && (bit & m2)) {
      c[0] = c[1] + c[0];
      c[1] = c[0] - c[1];
    } else {
      c[0] = c[0] + c[1];
      c[1] = c[0];
    }
  }
  return c[1] % 1000000007ll;
}
int main() {
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    if (a[i] && v.empty()) v.push_back(make_pair(0, i));
    if (a[i]) v.push_back(make_pair(a[i], i));
  }
  exm.resize((1 << 7));
  for (int m1 = 0; m1 < (1 << 7); m1++) exm[m1].resize((1 << 7));
  dp[0][(1 << (v[0].second)) - 1] = 1;
  for (int i = 1; i < v.size(); i++) {
    nxt.resize(1 << v[i].second);
    for (int m1 = 0; m1 < (1 << v[i].second); m1++) {
      nxt[m1].resize(1 << v[i].second);
      for (int m2 = 0; m2 < (1 << v[i].second); m2++)
        nxt[m1][m2] = comb(m1, m2, v[i].second);
    }
    vector<vector<long long>> upd = binpow(nxt, v[i].first);
    vector<long long> res((1 << 7) + 2);
    for (int j = 0; j < (1 << v[i - 1].second); j++) {
      int m1 =
          (((1 << (v[i].second - v[i - 1].second)) - 1) << v[i - 1].second) + j;
      res[m1] += dp[i - 1][j] % 1000000007ll;
      res[m1] %= 1000000007ll;
    }
    for (int m1 = 0; m1 < (1 << v[i].second); m1++)
      for (int m2 = 0; m2 < (1 << v[i].second); m2++) {
        dp[i][m2] += (res[m1] * upd[m1][m2]) % 1000000007ll;
        dp[i][m2] %= 1000000007ll;
      }
  }
  cout << dp[v.size() - 1][(1 << v.back().second) - 1] << endl;
  return 0;
}