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>
#pragma comment(linker, "/STACK:100000000000,100000000000")
using namespace std;
const double eps = 1E-9;
const double Exp = 2.718281828459045;
const double Pi = 3.1415926535897932;
const int NMAX = 100000 + 5;
const int MMAX = 100000 + 5;
const int INF = 1000000000;
const int BS = 1000000007;
template <typename T>
inline T abs(const T a) {
  if (a < 0) return -a;
  return a;
}
template <typename T>
inline T sqr(const T& a) {
  return a * a;
}
int a[1 << 8][1 << 8];
int b[1 << 8][1 << 8];
int buf[1 << 8][1 << 8];
int cl[8][1 << 8][1 << 8];
int op[8][1 << 8][1 << 8];
int dp[1 << 8];
int res[1 << 8];
void mult_a_buf(int n) {
  int i, j, k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      b[i][j] = 0;
      for (k = 0; k < n; k++) {
        b[i][j] = (b[i][j] + a[i][k] * 1ll * buf[k][j]) % BS;
      }
    }
  }
}
void mult_buf_buf(int n) {
  int i, j, k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      b[i][j] = 0;
      for (k = 0; k < n; k++) {
        b[i][j] = (b[i][j] + buf[i][k] * 1ll * buf[k][j]) % BS;
      }
    }
  }
}
void mult_dp_buf(int n) {
  int i, j, k;
  for (j = 0; j < n; j++) {
    res[j] = 0;
    for (k = 0; k < n; k++) {
      res[j] = (res[j] + dp[k] * 1ll * buf[k][j]) % BS;
    }
  }
}
void pw(int n, int p) {
  int i, j;
  if (0 == p) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        if (i == j)
          buf[i][j] = 1;
        else
          buf[i][j] = 0;
      }
    }
    return;
  }
  if (p % 2 == 1) {
    pw(n, p - 1);
    mult_a_buf(n);
    for (i = 0; i < n; i++) {
      for (j = 0; j < n; j++) {
        buf[i][j] = b[i][j];
      }
    }
    return;
  }
  pw(n, p / 2);
  mult_buf_buf(n);
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      buf[i][j] = b[i][j];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int n = 7;
  int w[8];
  int i, j, k;
  for (i = 1; i <= 7; i++) {
    cin >> w[i];
  }
  for (j = 0; j < (1 << 8); j++) {
    for (k = 0; k < (1 << 8); k++) {
      cl[0][j][k] = 1;
      op[0][j][k] = 0;
    }
  }
  for (i = 1; i <= 7; i++) {
    for (j = 0; j < (1 << 8); j++) {
      for (k = 0; k < (1 << 8); k++) {
        cl[i][j][k] = op[i - 1][j][k];
        if (((1 << (i - 1)) & j) && ((1 << (i - 1)) & k))
          ;
        else
          cl[i][j][k] = (cl[i][j][k] + cl[i - 1][j][k]) % BS;
        op[i][j][k] = (op[i - 1][j][k] + cl[i - 1][j][k]) % BS;
      }
    }
  }
  dp[0] = 0;
  dp[1] = 1;
  for (i = 1; i <= 7; i++) {
    for (j = 0; j < (1 << i); j++) {
      for (k = 0; k < (1 << i); k++) {
        a[j][k] = cl[i][j][k];
      }
    }
    pw(1 << i, w[i]);
    mult_dp_buf(1 << i);
    for (j = 0; j < (1 << i); j++) {
      dp[j] = 0;
      dp[j ^ (1 << i)] = res[j];
    }
  }
  cout << dp[(1 << 8) - 1] << endl;
  return 0;
}