P14002 [HackerEarth] Background:
提高
题目描述

Background:
After returning from ACM ICPC 2014, Mehta is back with a much greater stamina and enthusiasm to solve much complicated tasks. So, he comes across the following problem.

Task:
You have to report the count of numbers which have the following properties.
-> Their length i.e number of digits in their decimal representation should be less than or equal to N.
-> Count of prime digits i.e 2,3,5,7 modulo 2 should be A,B,C,D respectively, whereas count of other digits may be odd or even.

Input:
First Line of the input contains an integer T denoting the number of test cases.
Each test case consists of single line having five integers N,A,B,C,D separated by a single space as explained in the problem statement.

Output:
Output the answer modulo 10^9 + 7 for each test case in a separate line.

Constraints:
T ≤ 50
1 ≤ N ≤ 10^18
A,B,C,D will all be either 0 or 1 as they are all counts of prime digits modulo 2

Note:
0 is an even number and length of number zero is 1.

SAMPLE INPUT
6
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
1 0 1 1 0
2 0 1 1 0
3 0 1 1 0

SAMPLE OUTPUT
6
40
288
0
2
36

输入格式

见题面

输出格式

见题面

样例输入
40 779014210825989986 1 0 1 1 322106255379613865 1 0 1 1 365150529464241254 0 1 0 0 174711157969604379 0 1 0 1 187175928032793466 1 1 0 0 651682711632373513 0 1 0 0 23214286674552982 0 0 0 0 891500359387525651 1 0 1 0 523652291731378855 0 1 1 0 881372985367650075 0 1 0 1 157360227165384175 0 0 1 1 663312809661917625 0 1 0 1 336784452266528669 1 1 0 0 502694979398697211 0 1 1 0 219701516632610477 1 1 1 0 525960829673173346 0 1 0 0 804933398907987458 1 1 0 1 431471585764159002 1 1 1 0 385796385560658881 0 1 0 1 544591465493747065 0 1 1 0 718206573299046896 1 1 0 1 139879720005029050 1 0 0 0 461087745967641680 1 1 0 1 316239421504081659 0 1 0 0 653184474729305976 0 1 0 0 523412031358864244 1 0 0 0 208904163843706163 1 0 0 0 546425418810765050 1 1 1 1 831841480410808859 1 1 1 0 227977648633836724 1 0 1 0 468193702600839286 0 0 1 1 533281232567933468 1 1 0 0 955513685270664273 1 1 1 1 220233980394426937 1 0 1 1 805021699879380187 1 1 1 1 717245881451287579 1 1 1 1 91884460539416324 0 0 0 1 312075117901242519 0 1 0 1 797861906541677911 0 0 1 1 573441518855641925 1 0 1 1
样例输出
354834843 254733350 59422999 865286973 558849455 592376439 655709200 733203073 273689455 535739825 225977626 621793148 265202247 842980181 551311202 885751637 439018556 937210885 733780682 589614766 932587169 320617291 740486332 585208958 95573115 598818885 596548333 623318176 285190970 955589106 709586155 182212087 493747169 959248584