#!/bin/python import sys import itertools import math def printShortestPath(n, i_start, j_start, i_end, j_end): #1:UL #2:UR #3:R #4:LR #5:LL #6:L c=[i_start,j_start] d=[i_end,j_end] if(abs(c[0]-d[0])%2>0): print "Impossible" s=[1,2,3,4,5,6] ss=[] if(c[0]==0): s.remove(1) s.remove(2) elif(c[0]==n): s.remove(4) s.remove(5) if(c[1]==0): s.remove(6) if(c[1]==n): s.remove(3) cc=c dd=math.sqrt(pow(d[0]-c[0],2)+pow(d[1]-c[1],2)) l=[] for i in s: if(i==1): cc[0]+=2 cc[1]-=1 if(dd<=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2))): dd=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2)) a=1 elif(i==2): cc[0]+=2 cc[1]+=1 if(dd<=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2))): dd=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2)) a=2 cc=c if(i==3): cc[1]+=2 if(dd<=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2))): dd=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2)) a=3 elif(i==6): cc[1]-=1 if(dd<=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2))): dd=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2)) a=6 cc=c if(i==4): cc[0]-=2 cc[1]+=1 if(dd<=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2))): dd=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2)) a=4 elif(i==5): cc[0]-=2 cc[1]-=1 if(dd<=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2))): dd=math.sqrt(pow(d[0]-cc[0],2)+pow(d[1]-cc[1],2)) a=5 ss.append(a) c=cc #print a if __name__ == "__main__": n = int(raw_input().strip()) i_start, j_start, i_end, j_end = raw_input().strip().split(' ') i_start, j_start, i_end, j_end = [int(i_start), int(j_start), int(i_end), int(j_end)] printShortestPath(n, i_start, j_start, i_end, j_end)