Under construction

Still being built. Things may change

Multiplication in Base N (tiny)

Time limit1sMemory limit1024 MB

Summary
Multiply two integers A and B written in base N, where N may be negative, and print the product in base N.
Level

Medium5 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

This problem differs from N-base Multiplication (HUGE) only in the length limits on AA and BB.

Write a program that multiplies two integers AA and BB written in base NN.

The digits of AA and BB map to ASCII characters in order. 00 is ! (ASCII 33), 11 is " (ASCII 34), and so on, so ii is the character with code 33+i33+i. A negative sign is written as ~ (ASCII code 126126). It appears only at the front, at most once, and only when NN is positive.

ASCII character mapping table for each digit

The examples below show numbers written as described above. To make them easier to read, each digit is wrapped in square brackets.

\[1]\[2]\[5]_(10)=\[1]\[2]\[5]\_{(10)}="#&

−\[1]\[2]\[16]_(27)=-\[1]\[2]\[16]\_{(27)}=~"#1

\[9]\[0]\[12]_(−15)=\[9]\[0]\[12]\_{(-15)}=*!-

\[43]\[52]\[44]\[40]_(69)=\[43]\[52]\[44]\[40]\_{(69)}=LUMI

NN may be a negative integer. See the hint for how negative bases work.

Input

The first line contains the base N(2≤∣N∣≤93)N(2 \le |N| \le 93).

The second and third lines contain AA and BB, each written in base NN. Each of AA and BB has at most 3 0003\,000 characters when written in base NN.

Neither AA nor BB has an unnecessary leading !. ~ appears only when NN is positive, and at most once at the front. Note that NN can be negative.

Output

Print the product of AA and BB in base NN.

Hint

In a negative base NN, a carry into the next position on the left multiplies the value by NN, just as in a positive base. The only difference is that the digit in each position is limited to 0≤x<−N0 \le x \lt -N.

For example, 9 9039\,903 in base 1010 is 11 90311\,903 in base −10-10.

11 903_(−10)=1×(−10)4+1×(−10)3+9×(−10)2+0×(−10)1+3×(−10)0=9 903_(10)11\,903\_{(-10)} = 1 \times (-10) ^ 4 + 1 \times (-10) ^ 3 + 9 \times (-10) ^ 2 + 0 \times (-10) ^ 1 + 3 \times (-10) ^ 0 = 9\,903 \_{(10)}.

Examples3

  1. Example 1

    Input
    69
    TOCA
    LUMI
    
    Expected output
    AV<_E$;G
    
  2. Example 2

    Input
    -90
    Pl3453_5h4k3-C4rr075
    1f-Y0u-F33l-7hr3473n3d
    
    Expected output
    "tkZAW&?="GL37Gz&W4*F[OkOr17Usc`E(.0_0^fJ5q
    
  3. Example 3

    Input
    87
    ~Diving_Into_Firewall_and_Find_Your_Code
    Waiting_For_Your_Code-Accessing_"THE_VIOLET"!
    
    Expected output
    ~7Q"#=VgLj6YR\g,WRrPg+;n3UauemVK[aDYAGlkGII#0jNs5XMhS@cY)r4Jv`$2\_UJs\q\v;Rte2!55dXe!