Chef recently learned about ratios and proportions. He wrote some positive integers a, b, c, d on a paper. Chef wants to know whether he can shuffle these numbers so as to make some proportion? Formally, four numbers x, y, z, w are said to make a proportion if ratio of x : y is same as that of z : w.

-----Input-----
Only line of the input contains four space separated positive integers - a, b, c, d.

-----Output-----
Print "Possible" if it is possible to shuffle a, b, c, d to make proportion, otherwise "Impossible" (without quotes).

-----Constraints-----
- 1 ≤ a, b, c, d  ≤ 1000

-----Example-----
Input:
1 2 4 2

Output:
Possible

-----Explanation-----
By swapping 4 and the second 2, we get 1 2 2 4. Note that 1 2 2 4 make proportion as 1 : 2 = 2 : 4. Hence answer is "Possible"

Difficulty: interview

Starter code:

Solutions:
def permutate(arr):
 if len(arr) == 1:
  yield arr
 for x in range(len(arr)):
  for perm in permutate(arr[:x] + arr[x+1:]):
   yield [arr[x]] + perm

vals = [int(x) for x in input().split()]

founded = False
for val in permutate(vals):
 if (val[0] / float(val[1]) == val[2] / float(val[3])):
  print("Possible")
  founded = True 
  break
if not founded:
 print("Impossible")


a = input().split()
a = [int(x) for x in a]
a.sort()
if (float(a[0])/float(a[1]))==(float(a[2])/float(a[3])):
 print("Possible")
else:
 print("Impossible")

a,b,c,d=list(map(int,input().split()))
if(a*b==c*d or a*c==b*d or a*d==b*c):
 print("Possible")
else:
 print("Impossible")

import sys

a, b, c, d = list(map(float, input().split()))

if a/b == c/d:
 print("Possible")
 return

if a/b == d/c:
 print("Possible")
 return

if a/c == b/d:
 print("Possible")
 return

if a/c == d/b:
 print("Possible")
 return

if a/d == c/b:
 print("Possible")
 return

if a/d == b/c:
 print("Possible")
 return

if a/b == c/d:
 print("Possible")
 return

if a/b == c/d:
 print("Possible")
 return

print("Impossible")

import sys

a, b, c, d = list(map(float, input().split()))

if a/b == c/d:
 print("Possible")
 return

if a/b == d/c:
 print("Possible")
 return

if a/c == b/d:
 print("Possible")
 return

if a/c == d/b:
 print("Possible")
 return

if a/d == c/b:
 print("Possible")
 return

if a/d == b/c:
 print("Possible")
 return

if a/b == c/d:
 print("Possible")
 return

if a/b == c/d:
 print("Possible")
 return

print("Impossible")

a,b,c,d = list(map(float,input().split()))
li = []
li.append(a)
li.append(b)
li.append(c)
li.append(d)
li = sorted(li)
if li[1]/li[0] == li[3]/li[2]:
 print("Possible")
else:
 print("Impossible")

a,b,c,d = list(map(int , input().split()))

if(a*d == c*b or a*c == d*b or b*d == c*a or b*c == d*a):
 print("Possible")
elif(a*d == b*c or a*b ==d*c or c*d == b*a or c*b == d*a):
 print("Possible")
elif(a*c == b*d or a*b == c*d or d*c == b*a or d*b == c*a):
 print("Possible")
else:
 print("Impossible") 

a=list(map(float,input().split()))
a.sort()
if(a[0]/a[1]==a[2]/a[3]):
  print('Possible')
else:
  print('Impossible')

a, b , c, d = list(map(int , input().split()))

ab = a*b
ac = a*c
ad = a*d
bc = b*c
bd = b*d
cd = c*d

if ab == cd or ac == bd or ad == bc:
 print('Possible')
else:
 print('Impossible')


def min(a,b):
 if(a<b):
  return a;
 return b;

def max(a,b):
 if(a<b):
  return b;
 return a;


 
[a,b,c,d]=[float(x) for x in input().split()];
flag=False;
if(min(a,b)/max(a,b)==min(c,d)/max(c,d)):
 flag=True;

if(min(a,c)/max(a,c)==min(b,d)/max(b,d)):
 flag=True;

if(min(a,d)/max(a,d)==min(b,c)/max(b,c)):
 flag=True;

if(flag):
 print ("Possible");
else:
 print ("Impossible");
 
 

 
 
 


a,b,c,d = input().split(" ")
A = []
A.append(float(a))
A.append(float(b))
A.append(float(c))
A.append(float(d))

A.sort()

if A[0]/A[1] == A[2]/A[3]:
 print("Possible")
elif A[0]/A[2] == A[1]/A[3]:
 print("Possible")
elif A[0]/A[3] == A[1]/A[2]:
 print("Possible")
else:
 print("Impossible")

a=list(map(int,input().split(" ")))
a.sort()
if a[1]*a[2]==a[0]*a[3]:
 print("Possible")
else :
 print("Impossible")


def __starting_point():
 a, b, c, d = sorted(map(int, input().split()))
 if d * a == b * c:
  print('Possible')
 else:
  print('Impossible')

__starting_point()

import sys

def check(a,b,c,d) :
 return (a==c and b==d) or (a==d and b==c)

a,b,c,d = list(map(int,sys.stdin.readline().split()))
gcd = lambda x,y : x if y==0 else gcd(y,x%y)
flag=False
lg0,rg0 = gcd(a,b),gcd(c,d)
if check(a/lg0,b/lg0,c/rg0,d/rg0) :
 flag = True

lg0,rg0 = gcd(a,c),gcd(b,d)
if check(a/lg0,c/lg0,b/rg0,d/rg0) :
 flag = True

lg0,rg0 = gcd(a,d),gcd(c,b)
if check(a/lg0,d/lg0,c/rg0,b/rg0) :
 flag = True

print("Possible" if flag else "Impossible")

from itertools import permutations
a = [int(num) for num in input().split()]

l = list(permutations(a))
flag = False
for e in l:
 e0 = float(e[0])
 e1 = float(e[1])
 e2 = float(e[2])
 e3 = float(e[3])
 if e0 / e1 == e2 / e3:
  print("Possible")
  flag = True
  break
if flag == False:
 print("Impossible")

a,b,c,d = list(map(float, input().strip().split()))
if a/b == c/d or a/b == d/c:
 print('Possible')
elif a/c == b/d or a/c == d/b:
 print('Possible')
elif a/d == c/b or a/d == b/c:
 print('Possible')
else:
 print('Impossible')



a = list(map(int,input().split()))
out = "Impossible"
for i in range(4):
 if out == "Possible":
  break
 for j in range(1,4):
  a[i],a[j] = a[j],a[i]
  if a[0]/a[1] == a[2]/a[3]:
   out = "Possible"
   break
  else:
   a[i],a[j] = a[j],a[i]
print(out)


a = list(map(int,input().split()))
out = "Impossible"
for i in range(4):
 if out == "Possible":
  break
 for j in range(1,4):
  a[i],a[j] = a[j],a[i]
  if a[0]/a[1] == a[2]/a[3]:
   out = "Possible"
   break
  else:
   a[i],a[j] = a[j],a[i]
print(out)

a=[int(x) for x in input().split()]
a.sort()
if a[0]*a[3]==a[2]*a[1]:
 print("Possible")
else:
 print("Impossible") 

li=list(map(int,input().split()))
li =sorted(li)
a,b,c,d=li
#print float(b/float(a))
#print float(d/float(c))
if float(b/float(a)) == float(d/float(c)):
 print("Possible")
else:
 print("Impossible")

import itertools
a,b,c,d = list(map(float , input().split()))
li = list(itertools.permutations([a,b,c,d]))
flag = False
for i in li:
 if i[0]/i[1] == i[2]/i[3]:
  flag = True
  break
if flag == True :
 print('Possible')
else :
 print('Impossible')

abcd = input()
abcd = abcd.split()
abcd = list(map(int, abcd))
prod = 1
cnt = 0
for item in abcd:
 prod*=item
flo = prod**(0.5)
if int(flo) == flo:
 for i in range(3):
  for j in range(i+1,4):
   if abcd[i]*abcd[j] == flo:
    cnt = 1
    break
  if cnt==1:
   break
 if cnt == 1:
  print("Possible")
 else:
  print("Impossible")
else:
 print("Impossible")