QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓

#17950. Almond Chocolate

Statistiques

For Valentine's Day, Hanbyeol's chocolate shop is selling hexagonal chocolates topped with almonds. The interior angles of the hexagonal chocolate are all $120^\circ$, and the lengths of each side are integers. One almond is shaped like two equilateral triangles with side length $1$ joined together along an edge. The almonds must cover the chocolate completely without overlapping or extending beyond the boundaries of the chocolate.

To make the almond chocolate look attractive, Hanbyeol has already placed $6$ almonds such that each covers two triangles containing one of the vertices of the hexagon.

Find the number of ways to fill the remaining part of the chocolate.

Input

The first line contains $6$ integers $a_i$ representing the lengths of the sides of the hexagonal chocolate in clockwise order, separated by spaces. $(2 \le a_i \le 6;$ $1 \le i \le 6)$ The given input forms a valid hexagon.

Output

Output the answer to the problem modulo $1\,000\,000\,007$ on the first line. $1\,000\,000\,007$ is a prime number.

Examples

Input 1

2 2 2 2 2 2

Output 1

1

Note

In the example, there is only one way to fill the remaining space with almonds without any gaps, as shown in the figure below.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.