C - Connecting Modules

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

Input

Output

Sample test(s)

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

Notes