#!/bin/python import sys def printShortestPath(n, i_start, j_start, i_end, j_end): # Print the distance along with the sequence of moves. if (i_start<0 or i_start>=n) or (j_start<0 or j_start>=n) or ((j_start-j_end)%2)!=0: print "Impossible" return 0 l=[] for i in range(0,n): l.append([]) for j in range(0,n): l[i].append(0) l[i_start][j_start]='start' l[i_end][j_end]='end' opr=[] pointer=l[i_start][j_start] while pointer!=l[i_end][j_end]: if j_end==j_start: if (i_start>i_end) and (i_start-2>=0): pointer=l[i_start-2][j_start] i_start-=2 opr.append("L") continue if i_starti_end) and (i_start-1>=0): if j_startj_end and (j_start-2>=0): pointer=l[i_start-1][j_start-2] opr.append("UL") i_start-=1 j_start-=2 continue if (i_startj_end and (j_start-2>=0): pointer=l[i_start+1][j_start-2] opr.append("UR") i_start+=1 j_start-=2 continue if (i_start==i_end) and (i_start-1>=0): if (j_start>j_end) and (j_start-2>=0): pointer=l[i_start+1][j_start-2] opr.append("UL") i_start-=1 j_start-=2 continue if (i_start==i_end) and (i_start+1j_end) and (j_start-2>=0): pointer=l[i_start+1][j_start-2] opr.append("UR") i_start+=1 j_start-=2 continue if (j_start=0): if (j_start