CodeEff/ECCO huggingface dataset:
# Original solution
from collections import defaultdict
N, M = list(map(int, input().split()))
d = defaultdict(list)
for i in range(M):
    a,b = list(map(int, input().split()))
    d[a].append(b)

for i,j in list(d.items()):
    if i!=1:
        continue
    for k in j:
        if N in d[k]:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')

# Optimized solution
from collections import defaultdict
N, M = list(map(int, input().split()))
d = defaultdict(list)
for i in range(M):
    a,b = list(map(int, input().split()))
    d[a].append(b)

for j in d[1]:
    if N in d[j]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')
# Original solution
n, m = list(map(int, input().split()))
s = []
e = []
for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1 and b not in s:
        s.append(b)
    elif b == n and a not in e:
        e.append(a)
if len(set(s) & set(e)) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


# Optimized solution
n, m = list(map(int, input().split()))
s = []
e = []
for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        s.append(b)
    elif b == n:
        e.append(a)
if len(set(s) & set(e)) != 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
# Original solution
n, m = list(map(int, input().split()))
r = [[0, 0] for _ in range(m)]
ln = []
l1 = []
for i in range(m):
    r[i][0], r[i][1] = list(map(int, input().split()))
    if r[i][1] == n:
        ln.append(i)
    if r[i][0] == 1:
        l1.append(i)
ans = "IMPOSSIBLE"
for i in l1:
    for j in ln:
        if r[i][1] == r[j][0]:
            ans = "POSSIBLE"
            break
print(ans)


# Optimized solution
n, m = list(map(int, input().split()))
l = [0] * n
r = []
for i in range(m):
    a, b = list(map(int, input().split()))
    if a == 1:
        r.append(b)
    if b == n:
        l[a - 1] = 1
ans = "IMPOSSIBLE"
for i in r:
    if l[i - 1] == 1:
        ans = "POSSIBLE"
print(ans)
# Original solution
# ABC068c
import collections
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n, m = list(map(int, input().split()))
INF = 10**12


class Edge:  # 通常の辺
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


class Dijkstra:  # ダイクストラ法 O(E * logV)
    def __init__(self, n):
        self.n = n
        self.dist = [INF for _ in range(n)]
        self.edges = [list() for _ in range(n)]
        self.q = collections.deque()

    def calcShortest(self, start):
        self.q.append((start, 0))
        while(len(self.q) != 0):
            v, cost = self.q.popleft()
            if self.dist[v] <= cost:
                continue
            self.dist[v] = cost
            for edge in self.edges[v]:
                self.q.append((edge.to, cost+edge.cost))

    def addEdge(self, st, gl, cost):
        self.edges[st].append(Edge(gl, cost))


v = Dijkstra(n)
for _ in range(m):
    a, b = list(map(int, input().split()))
    v.addEdge(a-1, b-1, 1)
    v.addEdge(b-1, a-1, 1)

v.calcShortest(0)
if v.dist[n-1] <= 2:
    print('POSSIBLE')
    exit(0)
print('IMPOSSIBLE')


# Optimized solution
# ABC068c
import collections
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n, m = list(map(int, input().split()))
INF = 10**12


class Edge:  # 通常の辺
    def __init__(self, to, cost):
        self.to = to
        self.cost = cost


class Dijkstra:  # ダイクストラ法 O(E * logV)
    def __init__(self, n):
        self.n = n
        self.dist = [INF for _ in range(n)]
        self.edges = [list() for _ in range(n)]
        self.q = collections.deque()

    def calcShortest(self, start):
        self.q.append((start, 0))
        while(len(self.q) != 0):
            v, cost = self.q.popleft()
            if cost > 3:
                continue
            if self.dist[v] <= cost:
                continue
            self.dist[v] = cost
            for edge in self.edges[v]:
                self.q.append((edge.to, cost+edge.cost))

    def addEdge(self, st, gl, cost):
        self.edges[st].append(Edge(gl, cost))


v = Dijkstra(n)
for _ in range(m):
    a, b = list(map(int, input().split()))
    v.addEdge(a-1, b-1, 1)
    v.addEdge(b-1, a-1, 1)

v.calcShortest(0)
if v.dist[n-1] <= 2:
    print('POSSIBLE')
    exit(0)
print('IMPOSSIBLE')
# Original solution
n,m = list(map(int,input().split()))
First = []
Second = []
for i in range(m):
    a,b = list(map(int,input().split()))
    if a == 1:
        First.append(b)
    if b == n:
        Second.append(a)
for i in range(1,n+1):
    if i in First and i in Second:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")


# Optimized solution
n,m = list(map(int,input().split()))
route = [0]*(n+10)
for i in range(m):
    a,b = list(map(int,input().split()))
    if a == 1:
        route[b] += 1
    if b == n:
        route[a] += 1
if 2 in route:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
from collections import deque
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
ship = [[] for i in range(N)]
for i in range(M):
  a,b = list(map(int, input().split()))
  a -= 1
  b -= 1
  ship[a].append(b)
H = deque()
H.append(0)
visited = [0]*N
visited[0] = 1

while (4 not in visited) and H:
  x = H.popleft()
  for y in ship[x]:
    if visited[y] == 0:
      H.append(y)
      visited[y] = visited[x] + 1
if 0 < visited[N-1] < 4:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

# Optimized solution
from collections import deque
import sys
input = sys.stdin.readline

N, M = list(map(int, input().split()))
ship = [[] for i in range(N)]
for i in range(M):
  a,b = list(map(int, input().split()))
  a -= 1
  b -= 1
  ship[a].append(b)
visited = []
for i in ship[0]:
  visited.append(i)
  for j in ship[i]:
    visited.append(j)

if N-1 in visited:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
# Original solution
n,m =list(map(int,input().split()))
ab = [[int(i) for i in input().split()] for _ in range(m)]
visited = [False]*n
visited[0] = True
q = []

for j in range(m):
    if ab[j][0]==1:
        q.append((ab[j][1]))
        visited[ab[j][1]-1] = True
            
while q:
    c = q.pop()
    for j in range(m):
        if ab[j][0]==c:
            visited[ab[j][1]-1] = True
print(('POSSIBLE' if visited[n-1] else 'IMPOSSIBLE'))

# Optimized solution
n,m =list(map(int,input().split()))
visited = False
q = [[] for _ in range(n)]
flag = False
for j in range(m):
    a,b = list(map(int,input().split()))
    q[a].append(b)

while q[1]:
    c = q[1].pop()
    if n in q[c]:
        flag = True
print(('POSSIBLE' if flag==True else 'IMPOSSIBLE'))
# Original solution
n,m = list(map(int,input().split()))
 
lis = [[] for i in range(n)] #なぜか知らんけど[[]]*nじゃだめらしい
 
for i in range(m):
  a,b = list(map(int,input().split()))
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)


for i in set(lis[-1]):
  if i in set(lis[0]):
    print('POSSIBLE')
    exit()
  
print('IMPOSSIBLE')

# Optimized solution
n,m = list(map(int,input().split()))
 
lis = [[] for i in range(n)] #なぜか知らんけど[[]]*nじゃだめらしい
 
for i in range(m):
  a,b = list(map(int,input().split()))
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
 
 
if set(lis[-1]).isdisjoint(set(lis[0])):
    print('IMPOSSIBLE')
else:
  print('POSSIBLE')
# Original solution
n,m = list(map(int,input().split()))
 
lis = [[] for i in range(n)] #なぜか知らんけど[[]]*nじゃだめらしい
 
for i in range(m):
  a,b = list(map(int,input().split()))
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
 
 
if set(lis[-1]).isdisjoint(set(lis[0])):
    print('IMPOSSIBLE')
else:
  print('POSSIBLE')

# Optimized solution

n,m = list(map(int,input().split()))
 
lis = [[] for i in range(n)] #なぜか知らんけど[[]]*nじゃだめらしい
 
for i in range(m):
  a,b = list(map(int,input().split()))
  lis[a-1].append(b-1)
  lis[b-1].append(a-1)
 
 
if set(lis[-1]).isdisjoint(set(lis[0])): #交叉しているか？
    print('IMPOSSIBLE')
else:
  print('POSSIBLE')
# Original solution
N,M = list(map(int, input().split()))

islands = {}
for i in range(M):
    a,b = list(map(int, input().split()))
    if a not in islands:
        islands[a] = {}
    if b not in islands:
        islands[b] = {}
    islands[a][b] = islands[b][a] = 1

if N not in islands:
    print('IMPOSSIBLE')
    exit()
for i in list(islands[1].keys()):
    if i in islands[N]:
        print('POSSIBLE')
        exit()
print('IMPOSSIBLE')

# Optimized solution
n,m = list(map(int, input().split()))
d = {}
for _ in range(m):
    a,b = list(map(int, input().split()))
    if a not in d:
        d[a] = {}
    if b not in d:
        d[b] = {}
    d[a][b] = d[b][a] = 1

for v in list(d.values()):
    if 1 in v and n in v:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')
# Original solution
n,m = list(map(int, input().split()))
d = {}
for _ in range(m):
    a,b = list(map(int, input().split()))
    if a not in d:
        d[a] = {}
    if b not in d:
        d[b] = {}
    d[a][b] = d[b][a] = 1

for v in list(d.values()):
    if 1 in v and n in v:
        print('POSSIBLE')
        break
else:
    print('IMPOSSIBLE')


# Optimized solution

def resolve():
    n,m = list(map(int, input().split()))
    d = {}
    for i in range(m):
        a,b = list(map(int, input().split()))
        if a not in d:
            d[a] = {}
        if b not in d:
            d[b] = {}
        d[a][b] = d[b][a] = 1

    if 1 not in d or n not in d:
        print('IMPOSSIBLE')
        return

    for a in list(d[1].keys()):
        if a in d[n]:
            print('POSSIBLE')
            break
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    resolve()
# Original solution
N,M = list(map(int, input().split()))
A = [0] * M
B = [0] * M

for i in range(M):
    A[i],B[i] = list(map(int, input().split()))

ans = 'IMPOSSIBLE'
for i in range(M):
    if(A[i] == 1):
        for j in range(M):
            if(B[i] == A[j] and B[j] == N):
                ans = 'POSSIBLE'
                break

print(ans)

# Optimized solution
N,M = list(map(int, input().split()))
A = [0] * M
B = [0] * M

for i in range(M):
    A[i],B[i] = list(map(int, input().split()))
aa = []
bb = []
for i in range(M):
    if(A[i] == 1):
        aa.append(B[i])
    if(B[i] == N):
        bb.append(A[i])

aa = set(aa)
bb = set(bb)
ret = aa & bb
if (len(ret) == 0):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")
# Original solution
def main():
    n, m = list(map(int, input().split()))

    islands_to_1 = []
    islands_to_n = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands_to_1.append(max(boat))

        if n in boat:
            islands_to_n.append(min(boat))

    for island_to_1 in islands_to_1:
        if island_to_1 in islands_to_n:
            print("POSSIBLE")
            return

    print("IMPOSSIBLE")
    return


if __name__ == "__main__":
    main()


# Optimized solution
def main():
    n, m = list(map(int, input().split()))

    islands_to_1 = [0 for _ in range(n+1)]
    islands_to_n = []
    for _ in range(m):
        boat = list(map(int, input().split()))
        if 1 in boat:
            islands_to_1[boat[1]] = 1

        if n in boat:
            islands_to_n.append(min(boat))

    for island_to_n in islands_to_n:
        if islands_to_1[island_to_n] == 1:
            print("POSSIBLE")
            return

    print("IMPOSSIBLE")
    return


if __name__ == "__main__":
    main()
# Original solution
import sys
input = sys.stdin.readline
n,m = (int(i) for i in input().split())
ab = [[int(i)-1 for i in input().split()] for i in range(m)]

ab = list([x for x in ab if x[0]==0 or x[1]==n-1])
ab0 = list([x for x in ab if x[0]==0])
abn = list([x for x in ab if x[1]==n-1])

ab0 = list([x[1] for x in ab0])
abn = list([x[0] for x in abn])


res="IMPOSSIBLE"
for x in ab0:
    if x in abn:
        res= "POSSIBLE"
        break
 
print(res)

# Optimized solution
import sys
input = sys.stdin.readline
n,m = (int(i) for i in input().split())
ab = [[int(i)-1 for i in input().split()] for i in range(m)]

ab = list([x for x in ab if x[0]==0 or x[1]==n-1])
ab0 = list([x for x in ab if x[0]==0])
abn = list([x for x in ab if x[1]==n-1])

ab0_bin = ["0"]*n
abn_bin = ["0"]*n
for x in ab0:
    ab0_bin[x[1]] = "1"
for x in abn:
    abn_bin[x[0]] = "1"

ab0_bin = "".join(ab0_bin)
abn_bin = "".join(abn_bin)

if bin(int(ab0_bin,2) & int(abn_bin, 2))[2:].count("1") > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
def main():
    from collections import deque
    N, M = (int(i) for i in input().split())
    G = [[] for i in range(N+1)]
    G_color = ['WHITE' for _ in range(N+1)]
    G_distance = [float('inf') for _ in range(N+1)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        G[a].append(b)
        G[b].append(a)

    def bfs(s):
        """
        G_color: BLACK if visited, GRAY if discovered, but will visit, WHITE
                 if not discovered
        G_distance: a distance from s to v when algorithm computed
        """
        G_color[s] = 'GRAY'
        G_distance[s] = 0
        Q = deque()
        Q.append(s)
        while Q:
            u = Q.popleft()
            for v in G[u]:
                if G_color[v] == 'WHITE':
                    G_color[v] = 'GRAY'
                    G_distance[v] = G_distance[u] + 1
                    Q.append(v)
                    # distance <= 2 が探索し終わったら終わり
                    if G_distance[v] == 3:
                        return None
            G_color[u] = 'BLACK'
    bfs(1)
    if G_color[N] != 'WHITE' and G_distance[N] <= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()


# Optimized solution
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, M = (int(i) for i in input().split())
    edge = [[] for _ in range(N)]
    for i in range(M):
        a, b = (int(i) for i in input().split())
        edge[a-1].append((1, b-1))
        edge[b-1].append((1, a-1))
    from heapq import heappop, heappush

    def dijkstra(G, s):
        d = [10**12]*N
        used = [True] * N  # True:未確定
        d[s] = 0
        used[s] = False
        edges = []
        for e in G[s]:
            heappush(edges, e)
        while len(edges):
            c, v = heappop(edges)
            if not used[v]:
                continue
            d[v] = c
            used[v] = False
            for nexc, nexv in G[v]:
                if used[nexv]:
                    heappush(edges, (nexc+c, nexv))
        return d

    dist = dijkstra(edge, 0)
    if dist[N-1] <= 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")


if __name__ == '__main__':
    main()
# Original solution
import sys

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

s = []
e = []

for _ in range(M):
	tmp = list(map(int, input().split()))
	if 1 in tmp:
		s.append(max(tmp))
	elif N in tmp:
		e.append(min(tmp))

for ss in s:
	if ss in e:
		print("POSSIBLE")
		sys.exit()
print("IMPOSSIBLE")

# Optimized solution
import sys

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

A = [list(map(int, input().split())) for _ in range(M)]
B = []

for i in range(M):
	if 1 in A[i]:
		B.append(A[i][1])
	elif N in A[i]:
		B.append(A[i][0])

C = set(B)

if len(C) == len(B):
	print("IMPOSSIBLE")
else:
	print("POSSIBLE")
# Original solution
n, m = list(map(int, input().split()))
info = sorted([list(map(int, input().split())) for _ in range(m)])

q = []
t = m
append = q.append
for i in range(m):
	if info[i][0] == 1:
		append(info[i][1])
	else:
		t = i
		break

for j in range(t, m):
	if info[j][1] == n:
		if info[j][0] in q:
			print("POSSIBLE")
			break
else:
	print("IMPOSSIBLE")

# Optimized solution
n, m = list(map(int, input().split()))
side1 = set()
side2 = set()

for i in range(m):
	a, b = list(map(int, input().split()))

	if a == 1:
		side1.add(b)
	
	elif b == n:
		side2.add(a)

print((("" if side1 & side2 else "IM") + "POSSIBLE"))
# Original solution
#!/usr/bin/env python3
import sys, math, fractions, itertools

YES = "POSSIBLE"  # type: str
NO = "IMPOSSIBLE"  # type: str

def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    G = [[] for _ in range(N)]
    for i in range(M):
        G[a[i]-1].append(b[i]-1)
        G[b[i]-1].append(a[i]-1)
    flag = False
    for g in G[0]:
        if g in G[-1]:
            flag = True
    if flag:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()


# Optimized solution
#!/usr/bin/env python3
import sys, math, fractions, itertools, bisect

YES = "POSSIBLE"  # type: str
NO = "IMPOSSIBLE"  # type: str

def solve(N: int, M: int, a: "List[int]", b: "List[int]"):
    G = [[] for _ in range(N)]
    for i in range(M):
        G[a[i]-1].append(b[i]-1)
        G[b[i]-1].append(a[i]-1)
    G[0].sort()
    G[-1].sort()
    flag = False
    for g in G[0]:
        i = bisect.bisect_left(G[-1], g)
        if 0 <= i <= len(G[-1])-1:
            if G[-1][i] == g:
                flag = True
    if flag:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()
# Original solution
import sys
n,m=list(map(int,input().split()))
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]

a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])

a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    if a[i][1] in c:
            print("POSSIBLE")
            sys.exit()
        
print("IMPOSSIBLE")


# Optimized solution
import sys
n,m=list(map(int,input().split()))
a = [[int(i) for i in input().split()] for i in range(m)] 
c=[]
s=[]
a = sorted(a,key = lambda x:-x[1])

#print(a[0][0],a[0][1])
for i in range(m):
    if a[i][1] < n:
        break
    else:
        c.append(a[i][0])
c=set(c)
a = sorted(a,key = lambda x:x[0])
for i in range(m):
    if a[i][0] > 1:
        break
    else:
        s.append(a[i][1])

    #if a[i][1] in c:
s=set(s)

for i in s:
    if i in c:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")
# Original solution
N, M = list(map(int, input().split()))

one2 = []
toN = []

for _ in range(M):
    a, b = list(map(int, input().split()))

    if a == 1:
        one2.append(b)

    if b == N:
        toN.append(a)

flag = False
for a in one2:
    if a in toN:
        flag = True
        break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


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

one2 = set()
toN = set()

for _ in range(M):
    a, b = list(map(int, input().split()))

    if a == 1:
        one2.add(b)

    if b == N:
        toN.add(a)

inter = one2 & toN

if len(inter) > 0:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
# Original solution
N,M = list(map(int,input().split()))
ans = "IMPOSSIBLE"
f = []
s = []
for i in range(M):
    a,b = [int(x)-1 for x in input().split()]
    if a == 0:
        f.append(b)
    if b == N-1:
        s.append(a)
if len(f) > len(s):
    for i in range(len(s)):
        if s[i] in f:
            ans = "POSSIBLE"
            break
else:
    for i in range(len(f)):
        if f[i] in s:
            ans = "POSSIBLE"
            break
print(ans)

# Optimized solution
N,M = list(map(int,input().split()))
ans = "IMPOSSIBLE"
f = dict(list(zip(list(range(N)),[0]*N)))
s = dict(list(zip(list(range(N)),[0]*N)))
for i in range(M):
    a,b = [int(x)-1 for x in input().split()]
    if a == 0:
        f[b] = 1
    if b == N-1:
        s[a] = 1
if len(f) > len(s):
    for i in range(len(s)):
        if s[i] == 1 and f[i] == 1:
            ans = "POSSIBLE"
            break
else:
    for i in range(len(f)):
        if f[i] == 1 and s[i] == 1:
            ans = "POSSIBLE"
            break
print(ans)
# Original solution
import sys
n,m=list(map(int,input().split()))

a=[]
b=[]
l=[]

for i in range(m):
    c=[int(i) for i in input().split()]
    a.append(c[0])
    b.append(c[1])
    if a[i]==1 or b[i]==1:
        l.append(a[i]*b[i])


for i in range(m):
    if b[i]==n:
        if a[i] in l:
            print("POSSIBLE")        
            sys.exit()
    if a[i]==n:
        if b[i] in l:
            print("POSSIBLE")
            sys.exit()

print("IMPOSSIBLE")

# Optimized solution
import sys
n,m=list(map(int,input().split()))

a=[]
b=[]
l1=[False for i in range(n)]
ln=[False for i in range(n)]

for i in range(m):
    c=[int(i) for i in input().split()]
    a.append(c[0])
    b.append(c[1])
    if c[0]==1 or c[1]==1:
        l1[c[0]*c[1]]=True
    if c[0]==n or c[1]==n:
        ln[c[0]*c[1]//n]=True

for i in range(n):
    if l1[i] and ln[i]:
        print("POSSIBLE")
        sys.exit()

print("IMPOSSIBLE")
# Original solution
n, m = list(map(int, input().split()))

A = 0
B = 1
mid = [0] * (n+1)
goal = [0] * (n+1)
ab = []

for i in range(m):
    a,b = list(map(int, input().split()))
    ab.append([a, b])
    if a == 1:
        mid[b] += 1
    elif b == n:
        goal[a] += 1

# print(mid)
# print(goal)

for i in range(n+1):
    if mid[i] == 1 and goal[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")

# Optimized solution
n, m = list(map(int, input().split()))

A = 0
B = 1
cnt = [0] * (n+1)
ab = []

for i in range(m):
    a,b = list(map(int, input().split()))
    ab.append([a, b])
    if a == 1:
        cnt[b] += 1
    elif b == n:
        cnt[a] += 1

for i in range(n+1):
    if cnt[i] == 2:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
# Original solution
n,m = list(map(int,input().split()))
a = []
z = []
p = 0
for i in range(m):
    x,y = list(map(int,input().split()))
    if x == 1:
        z.append(y)
    elif y == n:
        a.append(x)
        p += 1
    else:
        pass
flg = False
for i in range(p):
    if a[i] in z:
        flg = True
        break
if flg:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

# Optimized solution
n,m = list(map(int,input().split()))
a = [] # 1 → x
z = [] # x → n
an = 0
zn = 0
for i in range(m):
    x,y = list(map(int,input().split()))
    if x == 1:
        zn += 1
        z.append(y)
    elif y == n:
        an += 1
        a.append(x)
    else:
        pass
a.sort()
z.sort()
i = 0
j = 0
while i < an and j < zn:
    if a[i] == z[j]:
        print('POSSIBLE')
        exit(0)
    else:
        if a[i] > z[j]:
            j += 1
        else:
            i += 1
print('IMPOSSIBLE')
# Original solution
N,M = list(map(int, input().split()))

S = []
for _ in range(M):
    D = list(map(int, input().split()))
    S.append(D)

#S.sort(key=lambda x:x[0])
S.sort()

first = []

for tmp in S:
    if tmp[0]!=1:
        break
    first.append(tmp[1])

for tmp in S:
    if tmp[1] == N and tmp[0] in first:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

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

S = []
for _ in range(M):
    D = list(map(int, input().split()))
    S.append(D)

set1=set()
set2=set()

for tmp in S:
    if tmp[0]==1:
        set1.add(tmp[1])
    if tmp[1]==N:
        set2.add(tmp[0])

if len(set1&set2) == 0:
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")