문제
Farmer John has recently built an enormous barn consisting of an
Bessie starts in room
Please determine the maximum number of rooms Bessie can illuminate.
Problem credits: Austin Bannister and Brian Dean
입력
The first line of input contains integers
The next
출력
A single line giving the maximum number of rooms Bessie can illuminate.
예제1
3 6
1 1 1 2
2 1 2 2
1 1 1 3
2 3 3 1
1 3 1 2
1 3 2 1
5
Here, Bessie can use the switch in