#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;

//////////////////////////////////////
///edge
typedef struct edge {
  int y;        /* adjancency info */
  int type;        /* edge type by dfs */
  int weight;     /* edge weight, if any */
  struct edge *next;    /* next edge in list */
} edge;


//////////////////////////////////////
///graph
#define MAXV    200001   /* maximum number of vertices */

typedef struct graph{
  vector< edge* > edges;
  vector< int > deg;
  int nv,ne,dir;

  void init_graph(int v, bool d){
    nv = v;
    ne = 0;
    dir = d;
    for (int i=0; i<=MAXV; i++) deg.push_back(0);
    for (int i=0; i<=MAXV; i++) edges.push_back(NULL);
  }

  void insert_edge(int x, int y, int w ,bool dir){
    edge *p = (edge*)malloc(sizeof(edge));

    p->weight = w;
    p->y = y;
    p->type = -1;
    p->next = edges[x];

    edges[x] = p;
    deg[x] ++;

    if (dir == false) insert_edge(y,x,w,true);
    else  ne ++;
  }


  void delete_edge(int x, int y, bool dir){
    edge *p, *p_back;

    p = edges[x];
    p_back = NULL;

    while (p != NULL)
      if (p->y == y) {
        deg[x] --;
        if (p_back != NULL)  p_back->next = p->next;
        else  edges[x] = p->next;
        free(p);

        if (dir == false)  delete_edge(y,x,true);
        else ne--;
        return;
      }
      else{
        p_back = p;
        p = p->next;
      }
    printf("Warning: deletion(%d,%d) not found in g.\n",x,y);
  }

  void traverse_graph(){
    edge *p;
    for (int i=0; i<nv; i++) {
//      cout << i << ": ";  /* insert any action */
      p = edges[i];
      while (p != NULL) {
//        cout << " " << p->y ;  /* insert any action */
        p = p->next;
      }
//      cout << endl;  /* insert any action */
    }
  }

  int graph_weight(){
    int w = 0;
    edge *p;      /* temporary pointer */
    for (int i=0; i<nv; i++) {
      p = edges[i];
      while (p != NULL) {
        w += p->weight;
        p = p->next;
      }
    }
    return w/2;
  }

  ///varibles for BFS
  vector<bool> processed,discovered;
  vector<int> parent,depth;
  //-----------------------------------------------------------
  void process_vertex_early(int v){
  }
  //-----------------------------------------------------------
  void process_vertex_late(int v){
  }
  //-----------------------------------------------------------
  void process_edge(int x, int y){
  }


  bool unsearched = true;
  void initialize_search(){
    for (int i=0; i<=nv; i++) {
      if(unsearched){
        processed.push_back(false);
        discovered.push_back(false);
        parent.push_back(-1);
        depth.push_back(-1);
      }else{
        processed[i] = discovered[i] = false;
        parent[i] = depth[i] = -1;
      }
    }
    unsearched = false;
  }

  void bfs(int start){
    queue<int> q;      /* queue of vertices to visit */
    int v;        /* current vertex */
    int y;        /* successor vertex */
    edge *p;      /* temporary pointer */

    q.push(start);
    discovered[start] = true;

    while (!q.empty()) {
      v = q.front();  q.pop();
//      process_vertex_early(v);
      processed[v] = true;
      if(parent[v] == -1){  depth[v] = 0;}
      else{ depth[v] = depth[parent[v]] + 1;}

      p = edges[v];
      while (p != NULL) {
        y = p->y;
        if ((processed[y] == false) || dir)
//          process_edge(v,y);
        if (discovered[y] == false) {
          q.push(y);
          discovered[y] = true;
          parent[y] = v;
        }
        p = p->next;
      }
//      process_vertex_late(v);
    }
  }

  ///*  use only after bfs    */
  void find_path(int x, int y){
    if(x == y)
      cout << x << endl;
    else if(parent[y] == -1)
      cout << "no path" << endl;
    else{
      find_path(x,parent[y]);
      cout << y << endl;
    }
  }

} graph;



int main()
{
  int n,m,x,y; cin >> n >> m;
  graph g;
  g.init_graph(n,0);
  for(int i=0;i<m;i++){
    cin >> x >> y;
    x--;  y--;
    g.insert_edge(x,y,1,0);
  }

  g.initialize_search();
  g.bfs(0);

  if(g.depth[n-1] == 2 )
    cout << "POSSIBLE";
  else
    cout << "IMPOSSIBLE";
  cout << endl;

  return 0;
}

Measured memory_bytes: 18032