N,M=list(map(int,input().split()))

x=y=1

for _ in[0]*M:

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

    if a==1: x|=1<<b

    if b==N: y|=1<<a

print(('IM'*(x&y==1)+'POSSIBLE'))
n,m,*T=list(map(int,open(0).read().split()))

*S,=list(zip(T[::2],T[1::2]))

f=lambda e:set(s[e<2]for s in S if e in s)

print(('IM'*(f(1)&f(n)==set())+'POSSIBLE'))
N, M = list(map(int, input().split()))
x = y = 1
for _ in [0] * M:
    a, b = list(map(int, input().split()))
    if a == 1:
        x |= 1 << b
    if b == N:
        y |= 1 << a
print(("IM" * (x & y == 1) + "POSSIBLE"))

n, m, *T = list(map(int, open(0).read().split()))
(*S,) = list(zip(T[::2], T[1::2]))
f = lambda e: set(s[e < 2] for s in S if e in s)
print(("IM" * (f(1) & f(n) == set()) + "POSSIBLE"))

-N, M = list(map(int, input().split())) -x = y = 1 -for _ in [0] * M: -    a, b = list(map(int, input().split())) -    if a == 1: -        x |= 1 << b -    if b == N: -        y |= 1 << a -print(("IM" * (x & y == 1) + "POSSIBLE")) +n, m, *T = list(map(int, open(0).read().split())) +(*S,) = list(zip(T[::2], T[1::2])) +f = lambda e: set(s[e < 2] for s in S if e in s) +print(("IM" * (f(1) & f(n) == set()) + "POSSIBLE"))