Palindromic Tax Paths The cows are bored. To amuse themselves, they have started searching for palindromes in Farmer Chris's tax forms. Palindromes are numbers that read the same forwards and backwards, e.g., 1234321 (but not 1231). A palindrome can be as short as 1 digit in length. Each tax form is an N x N (2 <= N <= 20) table of random single digits (0..9). The cows wish to find paths on the grid such that the sequence of digits the path traces is a palindrome. For example, in the table below, the path shown traces out the palindrome 122221: 1-2 0 0 \ 3 8 2=2 / 3 1 8 9 3 4 5 4 Some of the other palindromes that exist in the above example are 000, 121, 131, 1331, 13331, 2002 (many different ways), 318813, 454, and 8338. The paths may loop back upon themselves (as is the case with, e.g., 121, 122221, and 000). However, the paths may not use the same table entry more than once sequentially (i.e., 9889, 95559, and 9999999 are not valid palindromes). The length of a palindromic path is the number of digits it uses (12221 uses 5 digits). The cows would like to know how many palindromic paths of a given length L (1 <= L <= 18) exist. Write a program to determine the number of palindromic paths of length L for a given table of digits. If a path and its inverse are distinct, count them as two paths. That is, if traversing a path backwards is not the same as traversing it forwards, count it as two paths. In the example table above, count 122221 as two paths because it can be traversed either starting on the 1 in the first row and ending on the 1 in the third row, or starting on the 1 in the third row and ending on the 1 in the first row. On the other hand, count `949' only once, as it can only be traversed starting at 9, going to 4, and returning to the single 9. PROBLEM NAME: palpath INPUT FORMAT: * Line 1: Two space-separated integers: N and L * Lines 2..N+1: The tax form: N lines of N space-separated digits SAMPLE INPUT: 3 3 1 2 3 1 2 3 1 2 3 OUTPUT FORMAT: * Line 1: A single integer: the total number of palindromic paths. All answers for this problem's test data fit into signed 32 bit entities. SAMPLE OUTPUT: 86