Pipeline Plans#5841

Pipeline Plans

3 seconds
64 megabytes
Easy

There are twelve types of tiles, numbered through , as shown in Fig. 1. You are given a table (grid) of rows and columns. Your task is to fill the R \times C grid using the available tiles.

An arrangement is valid if all of the following conditions are satisfied:

Fig. 1: Types of tiles.

Input

The first line contains two integers and (2 \leq R \times C \leq 15). It is guaranteed that at least one of or is greater than .

The second line contains twelve integers: t_1, t_2, \ldots, t_{12} (0 \leq t_1 + t_2 + \cdots + t_{12} \leq 15), where t_i is the number of available tiles of type .

Output

Output the number of valid arrangements.

Examples

Example 1

Loading
Loading