#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int a[7];
int pre[128];
int curr[128];
int last;
int n;
int h, base;
long long f[128][128];
int fdp[8][2][128][128];
const int MAXPOW = 1024;
int ok[MAXPOW + 1];
long long pw[MAXPOW + 1][128][128];
int lo, hi;
void rundfs() {
  for (unsigned int(b) = (0); (b) < (2); (b)++)
    for (unsigned int(msk) = (0); (msk) < (128); (msk)++)
      for (unsigned int(tg) = (0); (tg) < (128); (tg)++)
        fdp[h][b][msk][tg] = (msk == tg);
  for (int j = h - 1; j >= 0; j--) {
    int top = (j == (h - 1));
    for (unsigned int(b) = (0); (b) < (2); (b)++) {
      for (unsigned int(msk) = (0); (msk) < (128); (msk)++) {
        int rem = 4 - b - top - last - ((msk & 1 << j) != 0);
        if (rem == 0) {
          for (unsigned int(i) = (0); (i) < (128); (i)++) fdp[j][b][msk][i] = 0;
          continue;
        }
        for (unsigned int(i) = (0); (i) < (128); (i)++)
          fdp[j][b][msk][i] = fdp[j + 1][0][msk & ~(1 << j)][i];
        if (rem > 1 && !last)
          for (unsigned int(i) = (0); (i) < (128); (i)++)
            fdp[j][b][msk][i] =
                ((fdp[j][b][msk][i]) + (fdp[j + 1][0][msk | (1 << j)][i])) %
                MOD;
        ;
        if (rem > 1 && !top)
          for (unsigned int(i) = (0); (i) < (128); (i)++)
            fdp[j][b][msk][i] =
                ((fdp[j][b][msk][i]) + (fdp[j + 1][1][msk & ~(1 << j)][i])) %
                MOD;
        ;
        if (rem > 2 && !top && !last)
          for (unsigned int(i) = (0); (i) < (128); (i)++)
            fdp[j][b][msk][i] =
                ((fdp[j][b][msk][i]) + (fdp[j + 1][1][msk | (1 << j)][i])) %
                MOD;
        ;
      }
    }
  }
  for (unsigned int(msk) = (0); (msk) < (128); (msk)++)
    for (unsigned int(tg) = (0); (tg) < (128); (tg)++)
      f[msk][tg] = fdp[0][1][msk][tg];
}
long long act[128][128];
long long aux[128][128];
void makepw(int p) {
  if (ok[p]) return;
  makepw(p / 2);
  for (unsigned int(i) = (base); (i) < (128); (i)++)
    for (unsigned int(j) = (base); (j) < (128); (j)++)
      aux[i][j] = pw[p / 2][i][j];
  for (unsigned int(i) = (base); (i) < (128); (i)++)
    for (unsigned int(j) = (base); (j) < (128); (j)++) {
      act[i][j] = 0;
      for (unsigned int(k) = (base); (k) < (128); (k)++)
        act[i][j] = ((act[i][j]) + (aux[i][k] * aux[k][j])) % MOD;
      ;
    }
  if (p % 2) {
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) {
        aux[i][j] = 0;
        for (unsigned int(k) = (base); (k) < (128); (k)++)
          aux[i][j] = ((aux[i][j]) + (act[i][k] * f[k][j])) % MOD;
        ;
      }
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) act[i][j] = aux[i][j];
  }
  for (unsigned int(i) = (base); (i) < (128); (i)++)
    for (unsigned int(j) = (base); (j) < (128); (j)++) pw[p][i][j] = act[i][j];
  ok[p] = 1;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  lo = -1;
  for (unsigned int(i) = (0); (i) < (7); (i)++) {
    cin >> a[i];
    if (a[i]) {
      if (lo == -1) lo = i;
      hi = i;
    }
  }
  for (unsigned int(i) = (0); (i) < (128); (i)++) curr[i] = 1;
  int id = hi;
  last = 1;
  while (id >= lo) {
    n = a[id];
    h = id + 1;
    base = 128 - (1 << h);
    rundfs();
    for (unsigned int(msk) = (0); (msk) < (128); (msk)++) pre[msk] = curr[msk];
    if (last) {
      for (unsigned int(msk) = (0); (msk) < (128); (msk)++) {
        curr[msk] = 0;
        for (unsigned int(tg) = (0); (tg) < (128); (tg)++)
          curr[msk] = ((curr[msk]) + (f[msk][tg] * pre[tg])) % MOD;
        ;
      }
      last = 0;
      n--;
      rundfs();
      for (unsigned int(msk) = (0); (msk) < (128); (msk)++)
        pre[msk] = curr[msk];
    }
    for (unsigned int(i) = (0); (i) < (MAXPOW + 1); (i)++) ok[i] = 0;
    ok[0] = ok[1] = 1;
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) pw[0][i][j] = (i == j);
    for (unsigned int(i) = (base); (i) < (128); (i)++)
      for (unsigned int(j) = (base); (j) < (128); (j)++) pw[1][i][j] = f[i][j];
    makepw(MAXPOW);
    makepw(n % MAXPOW);
    for (unsigned int(i) = (0); (i) < (n / MAXPOW); (i)++) {
      for (unsigned int(msk) = (base); (msk) < (128); (msk)++) {
        curr[msk] = 0;
        for (unsigned int(tg) = (base); (tg) < (128); (tg)++)
          curr[msk] = ((curr[msk]) + (pw[MAXPOW][msk][tg] * pre[tg])) % MOD;
        ;
      }
      for (unsigned int(msk) = (base); (msk) < (128); (msk)++)
        pre[msk] = curr[msk];
    }
    for (unsigned int(msk) = (base); (msk) < (128); (msk)++) {
      curr[msk] = 0;
      for (unsigned int(tg) = (base); (tg) < (128); (tg)++)
        curr[msk] = ((curr[msk]) + (pw[n % MAXPOW][msk][tg] * pre[tg])) % MOD;
      ;
    }
    for (unsigned int(msk) = (base); (msk) < (128); (msk)++)
      pre[msk] = curr[msk];
    id--;
    while (id && !a[id]) id--;
  }
  cout << curr[127] << endl;
  return 0;
}
