#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:16777216")
const int inf = 0x3f3f3f3f;
const long double pi = acos(-1.0);
const string debug_line = "yolo";
const double PI = 4 * atan(1);
vector<int> v1;
long long dp[10][(1 << 7)][(1 << 7)];
long long answer1[10][(1 << 7)][(1 << 7)];
vector<pair<int, int> > collection;
void solve1(int bit1, int bit2, int size) {
  vector<int> vec1;
  vector<int> vec2;
  for (int(i) = (0); (i) < (size); ++(i)) {
    if ((1 << i) & bit1) {
      vec1.push_back(1);
    } else {
      vec1.push_back(0);
    }
    if ((1 << i) & bit2) {
      vec2.push_back(1);
    } else {
      vec2.push_back(0);
    }
  }
  for (int(i) = (0); (i) < ((1 << (size - 1))); ++(i)) {
    vector<int> fill;
    fill.push_back(1);
    for (int(j) = (0); (j) < (size - 1); ++(j)) {
      if ((1 << j) & i) {
        fill.push_back(1);
      } else {
        fill.push_back(0);
      }
    }
    fill.push_back(1);
    vector<int> sides;
    for (int(j) = (0); (j) < (size); ++(j)) {
      sides.push_back(0);
    }
    for (int(j) = (0); (j) < (size); ++(j)) {
      sides[j] = sides[j] + vec1[j] + vec2[j];
    }
    for (int(j) = (0); (j) < (size + 1); ++(j)) {
      if (j == 0) {
        sides[j] += fill[j];
      } else if (j == size) {
        sides[j - 1] += fill[j];
      } else if (j > 0 && j < size) {
        sides[j - 1] += fill[j];
        sides[j] += fill[j];
      }
    }
    bool poss = true;
    for (int(j) = (0); (j) < (size); ++(j)) {
      if (sides[j] == 4) {
        poss = false;
      }
    }
    if (poss) {
      dp[size][bit1][bit2]++;
    }
  }
}
void mul(vector<vector<long long> > &a, vector<vector<long long> > &b, int n) {
  vector<vector<long long> > res = a;
  for (int(i) = (0); (i) < ((1 << n)); ++(i)) {
    for (int(j) = (0); (j) < ((1 << n)); ++(j)) {
      long long temp1 = 0;
      for (int(k) = (0); (k) < ((1 << n)); ++(k)) {
        temp1 = (temp1 + a[i][k] * b[k][j]) % 1000000007;
      }
      res[i][j] = temp1;
    }
  }
  a = res;
  return;
}
void powmul(int n, int k, vector<vector<long long> > &answer1) {
  if (k == 0) {
    return;
  } else if (k == 1) {
    vector<vector<long long> > res;
    res.resize((1 << n), vector<long long>((1 << n), 0));
    for (int(i) = (0); (i) < ((1 << n)); ++(i)) {
      for (int(j) = (0); (j) < ((1 << n)); ++(j)) {
        res[i][j] = dp[n][i][j];
      }
    }
    answer1 = res;
    return;
  } else {
    if (k % 2 == 0) {
      powmul(n, k / 2, answer1);
      vector<vector<long long> > answer2 = answer1;
      mul(answer1, answer2, n);
      return;
    } else {
      powmul(n, k / 2, answer1);
      vector<vector<long long> > answer2 = answer1;
      mul(answer1, answer2, n);
      vector<vector<long long> > res;
      res.resize((1 << n), vector<long long>((1 << n), 0));
      for (int(i) = (0); (i) < ((1 << n)); ++(i)) {
        for (int(j) = (0); (j) < ((1 << n)); ++(j)) {
          res[i][j] = dp[n][i][j];
        }
      }
      mul(answer1, res, n);
      return;
    }
  }
}
void scalarmul(vector<long long> &start1, vector<vector<long long> > &mat,
               vector<long long> &end1, int n) {
  for (int(i) = (0); (i) < ((1 << n)); ++(i)) {
    for (int(j) = (0); (j) < ((1 << n)); ++(j)) {
      end1[i] = (end1[i] + start1[j] * mat[j][i]) % 1000000007;
    }
  }
  return;
}
int main() {
  for (int(i) = (0); (i) < (7); ++(i)) {
    int temp;
    scanf("%d", &temp);
    v1.push_back(temp);
  }
  for (int(i) = (0); (i) < (7); ++(i)) {
    if (v1[i] != 0) {
      assert(i + 1 != 0);
      collection.push_back(make_pair(i + 1, v1[i]));
    }
  }
  for (int(i) = (1); (i) < (8); ++(i)) {
    for (int(j) = (0); (j) < ((1 << i)); ++(j)) {
      for (int(k) = (0); (k) < ((1 << i)); ++(k)) {
        solve1(j, k, i);
      }
    }
  }
  long long finalAnswer = 0;
  if (collection.size() == 1) {
    vector<vector<long long> > answer1;
    vector<long long> start1;
    vector<long long> end1;
    answer1.resize((1 << collection[0].first),
                   vector<long long>((1 << collection[0].first), 0));
    powmul(collection[0].first, collection[0].second, answer1);
    for (int(i) = (0); (i) < ((1 << collection[0].first)); ++(i)) {
      start1.push_back(0);
      end1.push_back(0);
    }
    start1[(int)(1 << collection[0].first) - 1] = 1;
    scalarmul(start1, answer1, end1, collection[0].first);
    finalAnswer = end1[(int)(1 << collection[0].first) - 1];
  } else {
    vector<long long> start1;
    vector<long long> end1;
    vector<vector<long long> > answer1;
    for (int(i) = (0); (i) < (collection.size()); ++(i)) {
      if (i == 0) {
        start1.clear();
        end1.clear();
        answer1.clear();
        answer1.resize((1 << collection[0].first),
                       vector<long long>((1 << collection[0].first), 0));
        for (int(i) = (0); (i) < ((1 << collection[0].first)); ++(i)) {
          start1.push_back(0);
          end1.push_back(0);
        }
        start1[(int)(1 << collection[0].first) - 1] = 1;
        powmul(collection[0].first, collection[0].second, answer1);
        scalarmul(start1, answer1, end1, collection[0].first);
        start1 = end1;
      } else if (i > 0) {
        vector<long long> start2;
        end1.clear();
        answer1.clear();
        answer1.resize((1 << collection[i].first),
                       vector<long long>((1 << collection[i].first), 0));
        for (int(j) = (0); (j) < ((1 << collection[i].first)); ++(j)) {
          start2.push_back(0);
          end1.push_back(0);
        }
        for (int(j) = (0); (j) < ((1 << collection[i - 1].first)); ++(j)) {
          int index =
              (1 << collection[i].first) - (1 << collection[i - 1].first);
          start2[j + index] = start1[j];
        }
        start1.clear();
        powmul(collection[i].first, collection[i].second, answer1);
        scalarmul(start2, answer1, end1, collection[i].first);
        if (i == collection.size() - 1) {
          finalAnswer = end1[(1 << collection[i].first) - 1];
        }
        start1 = end1;
      }
    }
  }
  printf("%lld\n", finalAnswer);
  return 0;
}
