P26252 [AtCoder] Swap Digit
入门
题目描述

Problem Statement

You are given N-digit positive integers A and B whose topmost digits are not 0.
You can repeat the following operation any number of times (possibly zero).

  • Choose an integer i such that $1 \le i \le N$ and swap the i-th lowest digits of A and B.

Find the smallest possible value of $A \times B after your operations, modulo 998244353$.
Note that you are not asked to minimize the remainder when $A \times B$ is divided by 998244353.

Input

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

Output

Print a single line containing the answer.

Constraints

  • $1 \le N \le 200000$
  • A and B are N-digit positive integers whose topmost digits are not 0.

Sample Input 1

2
13
22

Sample Output 1

276

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

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

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

Sample Input 2

8
20220122
21002300

Sample Output 2

54558365

Find the value modulo 998244353.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 13 22
样例输出
276