import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static class pos { int x; int y; String c; pos(int x,int y,String c) { this.x = x; this.y =y; this.c = c; } } static boolean check(int i_start, int j_start, int i_end, int j_end,int r,int c) { if(ri_end||c>j_end) return true; else return false; } static ArrayList populate(int i_start,int j_start,int i_end,int j_end) { ArrayList tem = new ArrayList(); if(check(i_start,j_start,i_end,j_end,i_start-2,j_start-1)) { pos p = new pos(i_start-2,j_start-1,"UL"); tem.add(p); } if(check(i_start,j_start,i_end,j_end,i_start-2,j_start+1)) { pos p = new pos(i_start-2,j_start+1,"UR"); tem.add(p); } if(check(i_start,j_start,i_end,j_end,i_start+2,j_start-1)) { pos p = new pos(i_start+2,j_start+1,"LR"); tem.add(p); } if(check(i_start,j_start,i_end,j_end,i_start+2,j_start+1)) { pos p = new pos(i_start+2,j_start-1,"LL"); tem.add(p); } if(check(i_start,j_start,i_end,j_end,i_start,j_start-2)) { pos p = new pos(i_start,j_start-2,"L"); tem.add(p); } if(check(i_start,j_start,i_end,j_end,i_start,j_start+2)) { pos p = new pos(i_start,j_start+2,"R"); tem.add(p); } return tem; } static boolean checkpathrepetition(ArrayList next , pos p) { for(int i=0;i> q = new LinkedList>(); pos p = new pos(i_start,j_start,"S"); ArrayList tem= new ArrayList(); tem.add(p); ArrayList> result = new ArrayList>(); q.add(tem); int min =10000,flg=0; int itr=0; while(!q.isEmpty()) { if(itr>50) break; ArrayList path = q.remove(); //System.out.println(path); pos cur = path.get(path.size()-1); ArrayList temp = populate(cur.x,cur.y,i_end,j_end); if(temp.size()==0) continue; for(int i=0;i next = new ArrayList(path); if(!checkpathrepetition(next,temp.get(i))) continue; next.add(temp.get(i)); if(flg==1 && next.size()>min) continue; if(temp.get(i).x == i_end && temp.get(i).y==j_end) { if(min>next.size()) { flg=1; min = next.size(); result.add(next); } } else { q.add(next); } } ++itr; } if(result.size()==0) System.out.println("Impossible"); else { ArrayList prin = result.get(0); System.out.println(prin.size()-1); for(int i=1;i