B - Breaking Bad

Languages: C, C++, Java, Python, Kotlin
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
3 4 1 3 1 0 1 1 3 2 -1 3 -1 2 -1 4 1 -1 6
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
4 2 1 2 3 1
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
3 4 1 1 1 1 4 4 1 1 -1 1 1 1 1 -1 -1 1 1
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
0 0
--- Showing first 30 lines (click "Copy" to get full content) ---
Input
3 4 0 1 0 0 3 1 3 1 -1 -1 1 -1 -1 -1 1 -1 1
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
-1 -1
--- Showing first 30 lines (click "Copy" to get full content) ---

Notes