Central-European Olympiad in Informatics, CEOI 2020, Day 1 (IOI, Unofficial Mirror Contest, Unrated)


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

Examples
Input
2
1 2
1 2
Output
12
----------------------------------------------------------------------------------------------------
B. Roads
time limit per test: 1.5 seconds
memory limit per test: 256 megabytes
input: standard input
output: standard output

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

Examples
Input
3 1
1 2
2 3
Output
4
----------------------------------------------------------------------------------------------------
