Good Bye 2022: 2023 is NEAR


A. Koxia and Whiteboards
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
3 2
1 2 3
4 5
2 3
1 2
3 4 5
1 1
100
1
5 3
1 1 1 1 1
1000000000 1000000000 1000000000
Output
12
9
1
3000000002
----------------------------------------------------------------------------------------------------
B. Koxia and Permutation
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
5 3
5 1
6 6
Output
5 1 2 3 4
1 2 3 4 5
3 2 4 1 6 5
----------------------------------------------------------------------------------------------------
C. Koxia and Number Theory
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
5 7 10
3
3 3 4
Output
YES
NO
----------------------------------------------------------------------------------------------------
D. Koxia and Game
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
2
3
1 2 2
1 3 3
5
3 3 1 3 4
4 5 2 5 5
Output
6
0
----------------------------------------------------------------------------------------------------
E. Koxia and Tree
time limit per test: 3 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2
1 3
1 2
2 3
Output
748683266
Input
5 3
3 4 5
1 2
1 3
2 4
2 5
Output
831870296
----------------------------------------------------------------------------------------------------
F. Koxia and Sequence
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 5 3
Output
2
Input
100 0 100
Output
0
Input
79877974817 749875791743978 982783
Output
64
----------------------------------------------------------------------------------------------------
G. Koxia and Bracket
time limit per test: 5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
())(()
Output
4
Input
(
Output
1
----------------------------------------------------------------------------------------------------
H. Koxia, Mahiru and Winter Festival
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
3 2 1
3 1 2
Output
5 1 1 2 1 2 2 3 2 3 3 
3 1 2 2 2 3 2 
5 1 3 1 2 1 1 2 1 3 1 
5 1 1 1 2 1 3 2 3 3 3
4 2 1 2 2 2 3 1 3 
4 3 1 3 2 3 3 2 3
Input
4
3 4 2 1
2 4 1 3
Output
6 1 1 1 2 2 2 2 3 3 3 4 3
6 1 2 1 3 2 3 2 4 3 4 4 4
5 1 3 2 3 2 2 3 2 4 2
7 1 4 1 3 1 2 2 2 2 1 3 1 4 1
7 1 1 2 1 3 1 3 2 3 3 2 3 2 4
6 2 1 2 2 3 2 4 2 4 3 4 4
6 3 1 3 2 3 3 3 4 2 4 1 4
5 4 1 4 2 4 3 3 3 3 4
Input
3
1 2 3
1 2 3
Output
3 1 1 2 1 3 1 
3 1 2 2 2 3 2 
3 1 3 2 3 3 3 
3 1 1 1 2 1 3 
3 2 1 2 2 2 3 
3 3 1 3 2 3 3 
----------------------------------------------------------------------------------------------------
