atcoder#ARC154A. [ARC154A] Swap Digit

[ARC154A] Swap Digit

Score : 300300 points

Problem Statement

You are given NN-digit positive integers AA and BB whose topmost digits are not 00.

You can repeat the following operation any number of times (possibly zero).

  • Choose an integer ii such that 1iN1 \le i \le N and swap the ii-th lowest digits of AA and BB.

Find the smallest possible value of A×BA \times B after your operations, modulo 998244353998244353.

Note that you are not asked to minimize the remainder when A×BA \times B is divided by 998244353998244353.

Constraints

  • 1N2000001 \le N \le 200000
  • AA and BB are NN-digit positive integers whose topmost digits are not 00.

Input

The input is given from Standard Input in the following format:

NN

AA

BB

Output

Print a single line containing the answer.

2
13
22
276

You can make A×B=276A \times B = 276 by performing the operation once, as follows.

  • Choose i=1i=1 to swap the bottommost digits of AA and BB, making A=12,B=23A=12, B=23.

You cannot make A×B=275A \times B = 275 or less, so the answer is 276276.

8
20220122
21002300
54558365

Find the value modulo 998244353998244353.