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>
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;
}