#601. 「Nowcoder多校 2019 Day5」subsequence 1
「Nowcoder多校 2019 Day5」subsequence 1
当前没有测试数据。
题目描述
You are given two strings s and t composed by digits (characters '0' ∼\sim∼ '9'). The length of s is n and the length of t is m. The first character of both s and t aren't '0'.
Please calculate the number of valid subsequences of s that are larger than t if viewed as positive integers. A subsequence is valid if and only if its first character is not '0'. Two subsequences are different if they are composed of different locations in the original string. For example, string "1223" has 2 different subsequences "23".
Because the answer may be huge, please output the answer modulo 998244353.
输入格式
The first line contains one integer T, indicating that there are T tests.
Each test consists of 3 lines.
The first line of each test contains two integers n and m, denoting the length of strings s and t.
The second line of each test contains the string s.
The third line of each test contains the string t.
-
.
-
sum of n in all tests .
-
the first character of both s and t aren't '0'.
输出格式
For each test, output one integer in a line representing the answer modulo 998244353.
样例
样例输入 1
3
4 2
1234
13
4 2
1034
13
4 1
1111
2
样例输出 1
9
6
11
样例解释 1
For the last test, there are 6 subsequences "11", 4 subsequcnes "111" and 1 subsequence "1111" that are valid, so the answer is 11.