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.PrintStream;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Collection;
import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author AlexFetisov
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE_CF_Round solver = new TaskE_CF_Round();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE_CF_Round {
    public static final int MOD = (int)1e9 + 7;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int[] w = Utils.readIntArray(in, 7);
        int[][][] a = new int[7][][];
        for (int i = 1; i <= 7; ++i) {
            a[i-1] = getMatrix(i);
            a[i-1] = MatrixUtils.pow(a[i-1], w[i-1], MOD);
        }
        int[] d = new int[1 << 7];
        int last = -1;
        int[] memo = new int[1 << 7];
        for (int i = 0; i < 7; ++i) {
            for (int j = (1 << (i+1))-1; j >= 0; --j) {
                if (d[j] != 0) {
                    d[j | (1 << i)] = d[j];
                    d[j] = 0;
                }
            }
            if (w[i] != 0) {
                if (last == -1) {
                    d[(1 << (i+1)) - 1] = 1;
                }
                last = i;
                int[] nd = new int[1 << 7];
                for (int j = 0; j < (1 << 7); ++j) {
                    if (d[j] > 0) {
                        for (int k = 0; k < (1 << 7); ++k) {
                            if (a[i].length > j && a[i][j].length > k) {
                                nd[k] += (d[j] * 1L * a[i][j][k]) % MOD;
                                if (nd[k] >= MOD) {
                                    nd[k] -= MOD;
                                }
                            }
                        }
                    }
                }
                int[] temp = d;
                d = nd;
                nd = temp;
                Arrays.fill(nd, 0);
                memo = d.clone();
            }
        }
        out.println(memo[(1 << (last+1)) - 1]);
    }

    private int[][] getMatrix(int w) {
        int[][] a = new int[1 << w][1 << w];
        for (int maskLeft = 0; maskLeft < (1 << w); ++maskLeft) {
            for (int maskRight = 0; maskRight < (1 << w); ++maskRight) {
                for (int mask = 0; mask < (1 << (w-1)); ++mask) {
                    boolean ok = true;
                    for (int bit = 0; bit < w; ++bit) {
                        if (BitUtils.checkBit(maskLeft, bit) && BitUtils.checkBit(maskRight, bit)) {
                            boolean upper = bit == 0 || BitUtils.checkBit(mask, bit-1);
                            boolean lower = bit == w-1 || BitUtils.checkBit(mask, bit);
                            if (upper && lower) {
                                ok = false;
                            }
                        }
                    }
                    if (ok) {
                        ++a[maskLeft][maskRight];
                    }
                }
            }
        }
        return a;
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer stt;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    public String nextString() {
        while (stt == null || !stt.hasMoreTokens()) {
            stt = new StringTokenizer(nextLine());
        }
        return stt.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(nextString());
    }

}

class Utils {
    public static int[] readIntArray(InputReader in, int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
        }
        return a;
    }

}

class MatrixUtils {

    public static int[][] mul(int[][] a, int[][] b, int MOD) {
        int n = a.length;
        int m = a[0].length;
        int k = b[0].length;
        int[][] r = new int[n][k];
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < k; ++j) {
                for (int p = 0; p < m; ++p) {
                    r[i][j] += (a[i][p] * 1L * b[p][j]) % MOD;
                    if (r[i][j] >= MOD) r[i][j] -= MOD;
                }
            }
        }
        return r;
    }

    public static int[][] pow(int[][] aa, long p, int MOD) {
        int[][] a = aa.clone();
        int n = a.length;
        int[][] r = buildOne(n);
        for (long i = p; i > 0; i /= 2) {
            if (i % 2 == 1) r = mul(r, a, MOD);
            a = mul(a, a, MOD);
        }
        return r;
    }

    private static int[][] buildOne(int n) {
        int[][] r = new int[n][n];
        for (int i = 0; i < n; ++i) {
            r[i][i] = 1;
        }
        return r;
    }

}

class BitUtils {
    public static boolean checkBit(int mask, int bit) {
        return (mask & (1 << bit)) > 0;
    }

}