#!/bin/python3 import sys def block1(x1,y1,x2,y2): l = [] while x1>x2 and [x1,y1]!=[x2,y2]: if y1>=y2: x1 = x1 - 2 y1 = y1 - 1 l.append("UL") elif y1y2 and (y1-y2)%2==0: while y1>y2: y1 = y1 - 2 l.append("L") elif y2>y1 and (y2-y1)%2==0: while y1y2: x1 = x1 + 2 y1 = y1 - 1 l.append("LL") elif y1<=y2: x1 = x1 + 2 y1 = y1 + 1 l.append("LR") if y1>y2 and (y1-y2)%2==0: while y1>y2: y1 = y1 - 2 l.append("L") elif y2>y1 and (y2-y1)%2==0: while y1x2 and [x1,y1]!=[x2,y2]: if y1<=y2: x1 = x1 - 2 y1 = y1 + 1 l.append("UR") elif y1>y2: x1 = x1 - 2 y1 = y1 - 1 l.append("UL") if y1y2: y1 = y1 - 2 l.append("L") if [x1,y1]!=[x2,y2]: return ("Impossible") else: return l def block4(x1,y1,x2,y2): l = [] while x1=y2: x1 = x1 + 2 y1 = y1 + 1 l.append("LR") if y1y2: y1 = y1 - 2 l.append("L") if [x1,y1]!=[x2,y2]: return ("Impossible") else: return l def printShortestPath(n, i_start, j_start, i_end, j_end): if i_start>=i_end and j_start>=j_end: #block1 if block1(i_start, j_start, i_end, j_end)!="Impossible": print(len(block1(i_start, j_start, i_end, j_end))) print(" ".join(block1(i_start, j_start, i_end, j_end))) else: print("Impossible") elif i_start>=i_end and j_start=j_end: #block2 if block2(i_start, j_start, i_end, j_end)!="Impossible": print(len(block2(i_start, j_start, i_end, j_end))) print(" ".join(block2(i_start, j_start, i_end, j_end))) else: print("Impossible") elif i_start