Solution:
We can deduce information about a from the grid b by looking at the largest element of it, say m. If m fills an entire row, then the value of a corresponding to this row must be equal to m. Otherwise, m must fill an entire column, and the value of a corresponding to this column must be equal to m. We can then ignore this row/column and continue this reasoning recursively on the remaining part of the grid.
Near the end, there are two cases. We could have a 1×1 remaining grid, where there are 2 permutations a consistent with b. We could also have a case where one of the dimensions of the remaining grid is 1, the other dimension is at least 2 (say k), and the number k+1 fills the entire remaining grid. In that case, there are k! ways to arrange the other elements 1,…,k.
It follows that there are exactly 2 permutations a consistent with the grid if and only if one of 1 and 2 is assigned to a row and the other is assigned to a column, or they are both assigned to the same type and 3 is assigned to the opposite type. The probability that this does not occur is the probability that 1,2,3 are all assigned to the same type, which happens with probability 3919⋅3818=2⋅3918=133, so the answer is 1−133=1310.