We store a matrix of integers in a file by putting each row on a separate line, and separating all integers on a row by spaces. Your task is to find the length of a longest path in a rectangular city:

Example

In the following interactive session, we assume the text files down01.txt1 and right01.txt2 to be located in the current directory.

>>> longest_path('down01.txt', 'right01.txt')
34