atcoder#ARC154A. [ARC154A] Swap Digit
[ARC154A] Swap Digit
Score : points
Problem Statement
You are given -digit positive integers and whose topmost digits are not .
You can repeat the following operation any number of times (possibly zero).
- Choose an integer such that and swap the -th lowest digits of and .
Find the smallest possible value of after your operations, modulo .
Note that you are not asked to minimize the remainder when is divided by .
Constraints
- and are -digit positive integers whose topmost digits are not .
Input
The input is given from Standard Input in the following format:
Output
Print a single line containing the answer.
2
13
22
276
You can make by performing the operation once, as follows.
- Choose to swap the bottommost digits of and , making .
You cannot make or less, so the answer is .
8
20220122
21002300
54558365
Find the value modulo .