Good Bye 2023


A. 2023
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
7
2 2
5 2
3 1
7 17 7
4 2
1 289 1 1
3 1
7 17 17
1 1
289
1 1
2023
1 3
1
Output
NO
NO
YES
7 1
YES
1
YES
7
YES
1
YES
7 17 17
----------------------------------------------------------------------------------------------------
B. Two Divisors
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
8
2 3
1 2
3 11
1 5
5 10
4 6
3 9
250000000 500000000
Output
6
4
33
25
20
12
27
1000000000
----------------------------------------------------------------------------------------------------
C. Training Before the Olympiad
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
1
31
6
6 3 7 2 5 4
3
3 10 11
5
7 13 11 19 1
Output
31 
6 8 16 18 22 26 
3 12 24 
7 20 30 48 50 
----------------------------------------------------------------------------------------------------
D. Mathematical Problem
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1
3
5
Output
1
169
196
961
16384
31684
36481
38416
43681
----------------------------------------------------------------------------------------------------
E. Happy Life in University
time limit per test: 1 second
memory limit per test: 512 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1
1 2
7
1 1 2 2 3 3
6 5 2 3 6 5 6
13
1 1 1 2 2 2 3 3 4 5 6 6
2 2 2 1 4 9 7 2 5 2 1 11 2
12
1 1 1 2 2 3 4 4 7 7 6
11 2 1 11 12 8 5 8 8 5 11 7
Output
2
9
9
12
----------------------------------------------------------------------------------------------------
F. Group Division
time limit per test: 1 second
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3
1 2 3
2 3
1 3
1 2
1 4 7
2 5
3 4
2 4
1 2
3 5
4 5
1 5
3 3 7
1 2
1 6
2 3
2 5
3 4
4 5
4 6
Output
3 
1 2 
5 
1 2 3 4 
4 5 6 
1 2 3 
----------------------------------------------------------------------------------------------------
G. Optimizations From Chelsu
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
4
2
1 2 1000000000000
4
3 2 6
2 1 10
2 4 6
8
1 2 12
2 3 9
3 4 9
4 5 6
5 6 12
6 7 4
7 8 9
12
1 2 12
2 3 12
2 4 6
2 5 9
5 6 6
1 7 4
4 8 12
8 9 4
8 10 12
2 11 9
7 12 9
Output
1000000000000
12
18
24
----------------------------------------------------------------------------------------------------
H1. Matrix Rank (Easy Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 3
Output
1 49 294 168 
Input
1 51549919 2
Output
1 51549918 0 
----------------------------------------------------------------------------------------------------
H2. Matrix Rank (Hard Version)
time limit per test: 2 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

Examples
Input
3 2 3
Output
1 49 294 168 
Input
1 51549919 2
Output
1 51549918 0 
----------------------------------------------------------------------------------------------------
