문제
Farmer John's
It takes
are unwilling to communicate with each-other.
Please determine the minimum amount of time needed to transmit the message.
입력
The first line contains
The next line contains
The next
출력
Print a single integer giving the minimum amount of time needed. If it is impossible to transmit the message from cow
예제1
5 4
1 4 2 3 4
1010
0001
0110
0100
6
The optimal sequence of transmissions is
. The total amount of time is
.