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>
int faster_in() {
  int r = 0, c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') return -faster_in();
  for (; c > 32; r = (r << 1) + (r << 3) + c - '0', c = getchar())
    ;
  return r;
}
using namespace std;
const int INF = int(1e9 + 7);
const double PI = acos(-1);
const int MOD = 1e9 + 7;
int vmat[19][1 << 8][1 << 8];
int cant[19];
void init(int limit) {
  for (int middle = (int)0; middle < (int)(1 << (limit + 1)); middle++) {
    if ((middle & 1) == 0 || (middle & (1 << limit)) == 0) continue;
    for (int maski = (int)0; maski < (int)(1 << limit); maski++) {
      for (int maskj = (int)0; maskj < (int)1 << limit; maskj++) {
        bool no = 0;
        for (int pos = (int)0; pos < (int)limit; pos++) {
          if (((1 << pos) & maski) && ((1 << pos) & maskj) &&
              (middle & (1 << pos)) && (middle & (1 << (pos + 1))))
            no = 1;
        }
        if (!no) vmat[limit][maski][maskj]++;
      }
    }
  }
}
vector<int> transform(vector<int> act, int antlim, int limit) {
  int agregar = 0;
  for (int i = (int)antlim; i < (int)limit; i++) agregar += 1 << i;
  vector<int> nuevo(1 << limit, 0);
  for (int i = (int)0; i < (int)act.size(); i++) nuevo[i + agregar] = act[i];
  return nuevo;
}
vector<vector<int> > ans;
void mult(vector<vector<int> > &m1, vector<vector<int> > &m2) {
  if (m1[0].size() != m2.size()) assert(false);
  ans.clear();
  long long answer = 0;
  for (int i = (int)0; i < (int)m1.size(); i++) {
    vector<int> fila;
    for (int j = (int)0; j < (int)m2[0].size(); j++) {
      answer = 0;
      for (int k = (int)0; k < (int)m2.size(); k++) {
        answer += ((long long)(m1[i][k] % MOD) * (m2[k][j] % MOD)) % MOD;
        while (answer >= MOD) answer -= MOD;
      }
      fila.push_back(answer);
    }
    ans.push_back(fila);
  }
}
vector<vector<int> > pot(vector<vector<int> > &base, int exp) {
  int n = base.size();
  vector<vector<int> > res(n, vector<int>(n, 0));
  for (int i = (int)0; i < (int)n; i++) res[i][i] = 1;
  while (exp) {
    if (exp & 1) {
      mult(res, base);
      res = ans;
    }
    mult(base, base);
    base = ans;
    exp /= 2;
  }
  return res;
}
int main() {
  for (int i = (int)1; i < (int)8; i++) {
    init(i);
  }
  int primer = -1;
  for (int i = (int)1; i < (int)8; i++) {
    cin >> cant[i];
    if (cant[i] > 0 && primer == -1) primer = i;
  }
  vector<vector<int> > respuesta(1, vector<int>(1 << primer, 0));
  respuesta[0][(1 << primer) - 1] = 1;
  int ant = primer, finalanswer = 0;
  for (int i = (int)1; i < (int)8; i++) {
    if (cant[i] > 0) {
      if (ant != i) respuesta[0] = transform(respuesta[0], ant, i);
      vector<vector<int> > base((1 << i), vector<int>(1 << i, 0));
      for (int j = (int)0; j < (int)(1 << i); j++)
        for (int k = (int)0; k < (int)(1 << i); k++) base[j][k] = vmat[i][j][k];
      base = pot(base, cant[i]);
      mult(respuesta, base);
      respuesta = ans;
      finalanswer = respuesta[0][respuesta[0].size() - 1];
      ant = i;
    }
  }
  cout << finalanswer << "\n";
}