Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×
C. Get Out Away (getoutaway)
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output
Examples
Input
5
3 4 2
1 2 6
4 2 5
2 5 3
Output
13 9
Input
5
3 4 1
1 2 2
4 2 1
2 5 2
Output
4 4