{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003ch2\u003e\u003c/h2\u003e\n\n\u003cp\u003e\nYou are given a simple, but long formula in a compressed format. A compressed formula is a sequence of $N$ pairs of an integer $r_i$ and a string $s_i$, which consists only of digits (\u00270\u0027-\u00279\u0027), \u0027+\u0027, \u0027-\u0027, and \u0027*\u0027. To restore the original formula from a compressed formula, first we generate strings obtained by repeating $s_i$ $r_i$ times for all $i$, then we concatenate them in order of the sequence.\n\u003c/p\u003e\n\n\u003cp\u003e\nYou can assume that a restored original formula is well-formed. More precisely, a restored formula satisfies the following BNF:\n\u003c/p\u003e\n\n\u003cpre\u003e\u0026lt;expression\u0026gt; :\u003d \u0026lt;term\u0026gt; | \u0026lt;expression\u0026gt; \u0027+\u0027 \u0026lt;term\u0026gt; | \u0026lt;expression\u0026gt; \u0027-\u0027 \u0026lt;term\u0026gt;\n\u0026lt;term\u0026gt; :\u003d \u0026lt;number\u0026gt; | \u0026lt;term\u0026gt; * \u0026lt;number\u0026gt;\n\u0026lt;number\u0026gt; :\u003d \u0026lt;digit\u0026gt; | \u0026lt;non-zero-digit\u0026gt; \u0026lt;number\u0026gt;\n\u0026lt;digit\u0026gt; :\u003d \u00270\u0027 | \u0026lt;non-zero-digit\u0026gt;\n\u0026lt;non-zero-digit\u0026gt; :\u003d \u00271\u0027 | \u00272\u0027 | \u00273\u0027 | \u00274\u0027 | \u00275\u0027 | \u00276\u0027 | \u00277\u0027 | \u00278\u0027 | \u00279\u0027\n\u003c/pre\u003e\n\n\u003cp\u003e\nHere, \u0027+\u0027 means addition, \u0027-\u0027 means subtraction, and \u0027*\u0027 means multiplication of integers.\n\u003c/p\u003e\n\n\u003cp\u003e\nYour task is to write a program computing the answer of a given formula modulo 1,000,000,007, where $x$ modulo $m$ is a non-negative integer $r$ such that there exists an integer $k$ satisfying $x \u003d km + r$ and $0 \\leq r \u0026lt; m$; it is guaranteed that such $r$ is uniquely determined for integers $x$ and $m$.\n\u003c/p\u003e\n\n\u003ch3\u003eInput\u003c/h3\u003e\n\u003cp\u003e\nThe input consists of a single test case.\u003cbr\u003e\n\u003cbr\u003e\n$N$\u003cbr\u003e\n$r_1$ $s_1$\u003cbr\u003e\n$r_2$ $s_2$\u003cbr\u003e\n...\u003cbr\u003e\n$r_N$ $s_N$\n\u003c/p\u003e\n\n\u003cp\u003e\nThe first line contains a single integer $N$ ($1 \\leq N \\leq 10^4$), which is the length of a sequence of a compressed formula. The following $N$ lines represents pieces of a compressed formula. The $i$-th line consists of an integer $r_i$ ($1 \\leq r_i \\leq 10^9$) and a string $s_i$ ($1 \\leq |s_i| \\leq 10$), where $t_i$ is the number of repetition of $s_i$, and $s_i$ is a piece of an original formula. You can assume that an original formula, restored from a given compressed formula by concatenation of repetition of pieces, satisfies the BNF in the problem statement.\n\u003c/p\u003e\n\n\n\u003ch3\u003eOutput\u003c/h3\u003e\n\u003cp\u003e\nPrint the answer of a given compressed formula modulo 1,000,000,007.\n\u003c/p\u003e\n\n\n\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\n5 1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e11111\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n19 2*\n1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1048576\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n1 1-10\n10 01*2+1\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e999999825\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n\n\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e4\n3 12+45-12\n4 12-3*2*1\n5 12345678\n3 11*23*45\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e20008570\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\n"}}]}