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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class E {

    private static final int MOD = (int) (1e9+7);
    public static final int N = 7;
    public static final int NN = 128;

    private void solve() throws IOException {
        int[] w = new int[N];
        for (int i = 0; i < N; i++) {
            w[i] = nextInt();
        }
        int[] start = new int[2];
        start[1] = 1;
        int[] a = start;
        for (int h = 0; h < N; h++) if (w[h] > 0) {
            int nn = (1 << (h + 1));
            {
                int[] aa = new int[nn];
                for (int i = 0; i < a.length; i++) {
                    aa[i - a.length + nn] = a[i];
                }
                a = aa;
            }
            int[][] q = new int[nn][];
            int[] t = new int[nn];
            for (int i = 0; i < nn; i++) {
                t[i] = 1;
                q[i] = add(t, h + 1);
                t[i] = 0;
            }
            q = pow(q, w[h]);
            int[] aa = new int[nn];
            for (int i = 0; i < nn; i++) {
                for (int j = 0; j < nn; j++) {
                    aa[j] = (int) ((aa[j] + 1l * a[i] * q[i][j]) % MOD);
                }
            }
            a = aa;
        }
        out.println(a[a.length - 1]);
    }

    private int[][] pow(int[][] a, int b) {
        int n = a.length;
        if (b == 0) {
            int[][] res = new int[n][n];
            for (int i = 0; i < n; i++) {
                res[i][i] = 1;
            }
            return res;
        }
        if (b % 2 == 0) {
            int[][] aa = mult(a, a);
            return pow(aa, b / 2);
        } else {
            int[][] aa = pow(a, b - 1);
            return mult(aa, a);
        }
    }

    private int[][] mult(int[][] a, int[][] b) {
        int n = a.length;
        int[][] c = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    c[i][k] = (int) ((c[i][k] + 1l * a[i][j] * b[j][k]) % MOD);
                }
            }
        }
        return c;
    }

    private int[] add(int[] a, int n) {
        int nn = (1 << (n + 1));
        int[][] d = new int[n + 1][nn];
        for (int i = 0; i < nn / 2; i++) {
            d[0][(i << 1) + 1] = a[i + a.length - (1 << n)];
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < nn; j++) if (d[i][j] > 0) {
                int q = (j >> i) & 3;
                for (int k = 0; k < 4; k++) {
                    if (q == 3 && k == 3) continue;
                    int jj = (j - (q << i) + (k << i));
                    d[i + 1][jj] += d[i][j];
                    while (d[i + 1][jj] >= MOD) {
                        d[i + 1][jj] -= MOD;
                    }
                }
            }
        }
        int[] res = new int[a.length];
        for (int i = 0; i < (1 << n); i++) {
            res[i + a.length - (1 << n)] = d[n][i + (1 << n)];
        }
        return res;
    }


    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    public static void main(String[] args) throws IOException {
        new E().run();
    }

    private void run() throws IOException {
        solve();
        out.close();
    }

}