atcoder#ARC148F. [ARC148F] 998244353 → 1000000007

[ARC148F] 998244353 → 1000000007

Score : 10001000 points

Problem Statement

This problem is output-only.

We have a programming language equipped with the following operations of unsigned 64-bit integers: addition, multiplication, and a modulo operation where the divisor is 998244353998244353. Write a program that performs multiplication modulo 10000000071000000007 in this language.

More formally, write a program that receives integers aa and bb between 00 and 10000000061000000006 and computes a×bmod1000000007a \times b \bmod{1000000007} under the following Specification and Format.

Specification

The program can handle 2626 variables represented by uppercase English letters: A,B,,ZA, B, \dots, Z. Each variable can hold an integer value between 00 and 26412^{64}-1 (inclusive). Below, such a value is called unsigned 64-bit integer. At the start of the execution of the program, AA is assigned an integer aa, BB is assigned an integer bb, and the other variables are assigned 00. At the end of the execution, CC must hold a×bmod1000000007a \times b \bmod{1000000007}.

Format

The 11-st line of the program contains an integer NN (1N100)(1 \leq N \leq 100) representing the number of instructions in the program. The 22-nd through (N+1)(N + 1)-th lines contain NN instructions. The instructions are executed one by one from top to bottom. Each instruction is in one of the following three forms.

  • add x y z- Assign (y+z)mod264(y + z) \bmod{2^{64}} to xx, where xx is a variable, and each of yy and zz is a variable or an unsigned 64-bit integer.
  • Assign (y+z)mod264(y + z) \bmod{2^{64}} to xx, where xx is a variable, and each of yy and zz is a variable or an unsigned 64-bit integer.
  • mul x y z- Assign (y×z)mod264(y \times z) \bmod{2^{64}} to xx, where xx is a variable, and each of yy and zz is a variable or an unsigned 64-bit integer.
  • Assign (y×z)mod264(y \times z) \bmod{2^{64}} to xx, where xx is a variable, and each of yy and zz is a variable or an unsigned 64-bit integer.
  • rem x y- Assign ymod998244353y \bmod{998244353} to xx, where xx is a variable, and yy is a variable or an unsigned 64-bit integer.
  • Assign ymod998244353y \bmod{998244353} to xx, where xx is a variable, and yy is a variable or an unsigned 64-bit integer.

Input

The input given from Standard Input is empty.

Output

Print a program under the Specification and Format.

Judging

If the submitted program is malformed, the verdict will be indeterminate. If the submitted program is well-formed, for each test case, the judge will execute it against 10410^4 pairs of integers (a,b)(a, b) (0a,b1000000006)(0 \leq a, b \leq 1000000006) independently. (These pairs are prepared beforehand and constant for each test case.) If the variable CC holds a×bmod1000000007a \times b \bmod{1000000007} at the end of the execution for all pairs (a,b)(a, b), the verdict will be AC; otherwise, it will be WA.

Sample Output

Here is an example of a well-formed program. (The Specification is not satisfied, so it will be judged as WA if submitted.)

5

mul C A B

rem C C

add A A 10

add D 2 B

add E 1 0

At the end of the execution of this program, the variables will hold the following values.

  • AA: a+10a + 10
  • BB: bb
  • CC: a×bmod998244353a \times b \bmod{998244353}
  • DD: b+2b + 2
  • EE: 11
  • The others: 00