#include <bits/stdc++.h>
using namespace std;
const int N = 7;
struct B {
  int L, R, M;
  int n;
  bool check() {
    if (L & R & M & (M >> 1)) return 0;
    return 1;
    for (int i = 0; i < n; ++i) {
      if ((L >> i & 1) && (R >> i & 1) && (M >> i & 1) && (M >> i + 1 & 1))
        return 0;
    }
    return 1;
  }
} b;
const long long Mod = 1e9 + 7;
struct Mat {
  static int n;
  long long a[1 << N][1 << N];
  void clear(bool e) {
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < n; ++j) a[i][j] = 0;
    if (e)
      for (int i = 0; i < n; ++i) a[i][i] = 1;
  }
  Mat operator*(const Mat &o) {
    Mat r;
    r.clear(0);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        for (int k = 0; k < n; ++k) {
          r.a[i][j] += a[i][k] * o.a[k][j];
          r.a[i][j] %= Mod;
        }
      }
    }
    return r;
  }
  Mat operator^(int b) {
    Mat r, c(*this);
    r.clear(1);
    while (b) {
      if (b & 1) r = r * c;
      c = c * c;
      b >>= 1;
    }
    return r;
  }
} mt;
int Mat::n = 0;
long long dp[1 << N], tdp[1 << N];
int main() {
  int pre = -1;
  for (int i = 1; i <= N; ++i) {
    int w;
    scanf("%d", &w);
    if (!w) continue;
    if (pre == -1) {
      for (int R = 0; R < 1 << i; ++R) {
        for (int M = 0; M < 1 << i - 1; ++M) {
          b.L = (1 << i) - 1;
          b.R = R;
          b.M = 1 << 0 | M << 1 | 1 << i;
          b.n = i;
          dp[R] += b.check();
        }
      }
    } else {
      for (int s = 0; s < 1 << pre; ++s) tdp[s] = dp[s];
      int tL = 0;
      for (int j = pre; j < i; ++j) tL |= 1 << j;
      for (int R = 0; R < 1 << i; ++R) {
        dp[R] = 0;
        for (int L = 0; L < 1 << pre; ++L) {
          long long nu = 0;
          for (int M = 0; M < 1 << i - 1; ++M) {
            b.R = R;
            b.L = L | tL;
            b.M = 1 << 0 | M << 1 | 1 << i;
            b.n = i;
            nu += b.check();
          }
          dp[R] += tdp[L] * nu;
          dp[R] %= Mod;
        }
      }
    }
    mt.n = 1 << i;
    mt.clear(0);
    for (int R = 0; R < 1 << i; ++R) {
      for (int L = 0; L < 1 << i; ++L) {
        int nu = 0;
        for (int M = 0; M < 1 << i - 1; ++M) {
          b.R = R;
          b.L = L;
          b.M = 1 << 0 | M << 1 | 1 << i;
          b.n = i;
          nu += b.check();
        }
        mt.a[R][L] = nu;
      }
    }
    mt = mt ^ (w - 1);
    for (int s = 0; s < 1 << i; ++s) tdp[s] = dp[s];
    for (int R = 0; R < 1 << i; ++R) {
      dp[R] = 0;
      for (int L = 0; L < 1 << i; ++L) {
        dp[R] += tdp[L] * mt.a[R][L];
        dp[R] %= Mod;
      }
    }
    pre = i;
  }
  int ans = int(dp[(1 << pre) - 1]);
  printf("%d\n", ans);
  return 0;
}
