#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
int a, b, c, d, n, m, k;
int dp[2][1 << 7], ndp[2][1 << 7];
int mas[1 << 7][1 << 7], ans[1 << 7][1 << 7];
inline void add(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
int tmp[1 << 7][1 << 7], tt[1 << 7][1 << 7];
const long long modll = (long long)1000000007 << 31;
inline void mul(int a[][1 << 7], int b[][1 << 7], int n) {
  for (int _n((n)-1), i(0); i <= _n; i++) {
    for (int _n((n)-1), j(0); j <= _n; j++) {
      tt[i][j] = b[j][i];
    }
  }
  for (int _n((n)-1), i(0); i <= _n; i++) {
    for (int _n((n)-1), j(0); j <= _n; j++) {
      long long t = 0;
      for (int _n((n)-1), z(0); z <= _n; z++) {
        t += (long long)a[i][z] * tt[j][z];
        if (t >= modll) t -= modll;
      }
      tmp[i][j] = t % 1000000007;
    }
  }
  for (int _n((n)-1), i(0); i <= _n; i++)
    for (int _n((n)-1), j(0); j <= _n; j++) a[i][j] = tmp[i][j];
}
inline void step(int cnt, int j, int wi, int wi1, int dp[][1 << 7], int &now,
                 int &nx) {
  for (int _n((wi)-1), h(0); h <= _n; h++) {
    swap(now, nx);
    memset((dp[nx]), 0, sizeof(dp[nx]));
    int need = 0;
    if (!j && h >= wi1) need |= 1 << 0;
    if (!h) need |= 1 << 1;
    for (int _n((1 << wi) - 1), mask(0); mask <= _n; mask++) {
      if (!dp[now][mask]) continue;
      int cd = dp[now][mask];
      for (int _n((4) - 1), cm(0); cm <= _n; cm++) {
        if ((cm & need) != need) continue;
        if ((cm & 1 << 0) && (mask & 1 << h)) continue;
        int nmask = mask;
        if (h) {
          if (mask & 1 << (h - 1)) {
            if (~cm & 1 << 1) nmask ^= 1 << (h - 1);
          }
        }
        if (nmask & 1 << h) nmask ^= 1 << h;
        if (cm == 3) nmask |= 1 << h;
        add(dp[nx][nmask], cd);
      }
    }
  }
}
int main() {
  vector<pair<int, int> > w;
  for (int _n((7) - 1), i(0); i <= _n; i++) {
    scanf("%d", &a);
    if (a) w.push_back(make_pair(i + 1, a));
  }
  int now, nx;
  now = 1;
  nx = 0;
  dp[nx][0] = 1;
  int tot = 0;
  for (int _n(((int)((w).size())) - 1), i(0); i <= _n; i++) {
    if (w[i].second <= 1) {
      for (int _n((w[i].second) - 1), j(0); j <= _n; j++) {
        step(1, j, w[i].first, i == 0 ? 0 : w[i - 1].first, dp, now, nx);
      }
    } else {
      step(1, 0, w[i].first, i == 0 ? 0 : w[i - 1].first, dp, now, nx);
      memset((mas), 0, sizeof(mas));
      for (int _n((1 << w[i].first) - 1), m1(0); m1 <= _n; m1++) {
        memset((ndp), 0, sizeof(ndp));
        int cnow = 1, cnx = 0;
        ndp[cnx][m1] = 1;
        step(1, 1, w[i].first, i == 0 ? 0 : w[i - 1].first, ndp, cnow, cnx);
        for (int _n((1 << w[i].first) - 1), j(0); j <= _n; j++) {
          mas[m1][j] = ndp[cnx][j];
        }
      }
      int t = w[i].second - 1;
      memset((ans), 0, sizeof(ans));
      for (int _n((1 << w[i].first) - 1), j(0); j <= _n; j++) ans[j][j] = 1;
      while (t) {
        if (t % 2) mul(ans, mas, 1 << w[i].first);
        mul(mas, mas, 1 << w[i].first);
        t /= 2;
      }
      memset((dp[now]), 0, sizeof(dp[now]));
      for (int _n((1 << w[i].first) - 1), mask(0); mask <= _n; mask++) {
        for (int _n((1 << w[i].first) - 1), m2(0); m2 <= _n; m2++) {
          dp[now][mask] =
              (dp[now][mask] + (long long)ans[m2][mask] * dp[nx][m2]) %
              1000000007;
        }
      }
      swap(now, nx);
    }
  }
  printf("%d\n", dp[nx][0]);
}
