from collections import defaultdict

from heapq import heappop, heappush





class Graph(object):

    """

    隣接リストによる有向グラフ

    """



    def __init__(self):

        self.graph = defaultdict(list)



    def __len__(self):

        return len(self.graph)



    def add_edge(self, src, dst, weight=1):

        self.graph[src].append((dst, weight))



    def get_nodes(self):

        return list(self.graph.keys())





class Dijkstra(object):

    """

    ダイクストラ法（二分ヒープ）による最短経路探索

    計算量: O((E+V)logV)

    """



    def __init__(self, graph, start):

        self.g = graph.graph



        # startノードからの最短距離

        # startノードは0, それ以外は無限大で初期化

        self.dist = defaultdict(lambda: float('inf'))

        self.dist[start] = 0



        # 最短経路での1つ前のノード

        self.prev = defaultdict(lambda: None)



        # startノードをキューに入れる

        self.Q = []

        heappush(self.Q, (self.dist[start], start))



        while self.Q:

            # 優先度（距離）が最小であるキューを取り出す

            dist_u, u = heappop(self.Q)

            if self.dist[u] < dist_u:

                continue

            for v, weight in self.g[u]:

                alt = dist_u + weight

                if self.dist[v] > alt:

                    self.dist[v] = alt

                    self.prev[v] = u

                    heappush(self.Q, (alt, v))



    def shortest_distance(self, goal):

        """

        startノードからgoalノードまでの最短距離

        """

        return self.dist[goal]



    def shortest_path(self, goal):

        """

        startノードからgoalノードまでの最短経路

        """

        path = []

        node = goal

        while node is not None:

            path.append(node)

            node = self.prev[node]

        return path[::-1]





if __name__ == "__main__":

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



    g1 = Graph()



    for i in range(m):

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

        g1.add_edge(a-1, b-1)

        g1.add_edge(b-1, a-1)



    d = Dijkstra(g1, 0)



    if d.dist[n-1] == 2:

        print('POSSIBLE')

    else:

        print('IMPOSSIBLE')

from collections import defaultdict





def main():

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

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



    g = defaultdict(list)



    for n in ab:

        g[n[0]].append(n[1])



    if 1 not in g:

        print('IMPOSSIBLE')

        exit()



    for i in g[1]:

        if i not in g:

            continue

        for j in g[i]:

            if j == N:

                print('POSSIBLE')

                exit()



    print('IMPOSSIBLE')





if __name__ == "__main__":

    main()

from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return list(self.graph.keys())


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph
        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float("inf"))
        self.dist[start] = 0
        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)
        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))
        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]


if __name__ == "__main__":
    n, m = list(map(int, input().split()))
    g1 = Graph()
    for i in range(m):
        a, b = list(map(int, input().split()))
        g1.add_edge(a - 1, b - 1)
        g1.add_edge(b - 1, a - 1)
    d = Dijkstra(g1, 0)
    if d.dist[n - 1] == 2:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

from collections import defaultdict


def main():
    N, M = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in range(M)]
    g = defaultdict(list)
    for n in ab:
        g[n[0]].append(n[1])
    if 1 not in g:
        print("IMPOSSIBLE")
        exit()
    for i in g[1]:
        if i not in g:
            continue
        for j in g[i]:
            if j == N:
                print("POSSIBLE")
                exit()
    print("IMPOSSIBLE")


if __name__ == "__main__":
    main()

-from heapq import heappop, heappush -class Graph(object): -    """ -    隣接リストによる有向グラフ -    """ - -    def __init__(self): -        self.graph = defaultdict(list) - -    def __len__(self): -        return len(self.graph) - -    def add_edge(self, src, dst, weight=1): -        self.graph[src].append((dst, weight)) - -    def get_nodes(self): -        return list(self.graph.keys()) - - -class Dijkstra(object): -    """ -    ダイクストラ法（二分ヒープ）による最短経路探索 -    計算量: O((E+V)logV) -    """ - -    def __init__(self, graph, start): -        self.g = graph.graph -        # startノードからの最短距離 -        # startノードは0, それ以外は無限大で初期化 -        self.dist = defaultdict(lambda: float("inf")) -        self.dist[start] = 0 -        # 最短経路での1つ前のノード -        self.prev = defaultdict(lambda: None) -        # startノードをキューに入れる -        self.Q = [] -        heappush(self.Q, (self.dist[start], start)) -        while self.Q: -            # 優先度（距離）が最小であるキューを取り出す -            dist_u, u = heappop(self.Q) -            if self.dist[u] < dist_u: -                continue -            for v, weight in self.g[u]: -                alt = dist_u + weight -                if self.dist[v] > alt: -                    self.dist[v] = alt -                    self.prev[v] = u -                    heappush(self.Q, (alt, v)) - -    def shortest_distance(self, goal): -        """ -        startノードからgoalノードまでの最短距離 -        """ -        return self.dist[goal] - -    def shortest_path(self, goal): -        """ -        startノードからgoalノードまでの最短経路 -        """ -        path = [] -        node = goal -        while node is not None: -            path.append(node) -            node = self.prev[node] -        return path[::-1] +def main(): +    N, M = list(map(int, input().split())) +    ab = [list(map(int, input().split())) for _ in range(M)] +    g = defaultdict(list) +    for n in ab: +        g[n[0]].append(n[1]) +    if 1 not in g: +        print("IMPOSSIBLE") +        exit() +    for i in g[1]: +        if i not in g: +            continue +        for j in g[i]: +            if j == N: +                print("POSSIBLE") +                exit() +    print("IMPOSSIBLE") -    n, m = list(map(int, input().split())) -    g1 = Graph() -    for i in range(m): -        a, b = list(map(int, input().split())) -        g1.add_edge(a - 1, b - 1) -        g1.add_edge(b - 1, a - 1) -    d = Dijkstra(g1, 0) -    if d.dist[n - 1] == 2: -        print("POSSIBLE") -    else: -        print("IMPOSSIBLE") +    main()