stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



struct edge { int to, cost; };

typedef pair<int, int> P; // firstは最短距離、secondは頂点の番号



const int VV = 222222;

const int INF = 1e8;

int V, M;

vector<edge> G[VV];

int d[VV];



void dijkstra(int s) {

   // 最短距離firstが小さい順に取り出せるようにする

   priority_queue<P, vector<P>, greater<P>> que;

   fill(d, d + V, INF); // 距離全てをINFで初期化

   d[s] = 0; // スタート地点を0で初期化

   que.push(P(0, s)); // キューに初期位置のコスト、初期位置をpush



   while (que.size()) {

      P p = que.top(); que.pop(); // p: 今の{最短距離、頂点番号}

      int v = p.second; // 今の頂点番号

      if (d[v] < p.first) continue; // 今見ている頂点の歴代最小距離 < 今見ている頂点の最短距離

      for (int i = 0; i < G[v].size(); i++) { // 今の頂点に隣接する頂点を調べる

         edge e = G[v][i];

         if (d[e.to] > d[v] + e.cost) { // 遷移先の頂点の歴代最小距離 > 今の距離 + 遷移コスト

            d[e.to] = d[v] + e.cost; // 歴代最小距離の更新

            que.push(P(d[e.to], e.to)); // 更新した遷移先の頂点をキューに突っ込む

         }

      }

   }

}



int main() {

   cin >> V >> M;

   for (int i = 0; i < M; i++) {

      int a, b;

      cin >> a >> b;

      a--, b--;

      G[a].push_back({b, 1});

      G[b].push_back({a, 1});

   }



   dijkstra(0);



   if (d[V-1] == 2) {

      puts("POSSIBLE");

   } else {

      puts("IMPOSSIBLE");

   }



   return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



bool A[222222];

bool B[222222];



int main() {

   int N, M;

   cin >> N >> M;



   map<int, int> mp;

   for (int i = 0; i < M; i++) {

      int a, b;

      cin >> a >> b;

      if (a == 1) A[b] = true;

      if (b == N) B[a] = true;

   }



   for (int i = 0; i <= N; i++) {

      if (A[i] && B[i]) {

         puts("POSSIBLE");

         return 0;

      }

   }



   puts("IMPOSSIBLE");



   return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define N 200005

int a[N],b[N];

using namespace std;

int main(){

    int c,d,e,f;

    cin>>e>>f;

    for(int i=0;i<f;i++){

        cin>>c>>d;

        if(c==1) a[d]=1;

        if(d==e) b[c]=1;

    }

    for(int j=1;j<e;j++){

        if(a[j]==1&&b[j]==1){

            cout<<"POSSIBLE"<<endl;

            return 0;

        }   

    }

    cout<<"IMPOSSIBLE"<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,m,a,b,i;bool s[200005],t[200005];

int main(){

	scanf("%d%d",&n,&m);

	for(i=1;i<=m;i++){

		scanf("%d%d",&a,&b);

		if(a==1) s[b]=1;

		if(b==n) t[a]=1;

	}

	for(i=2;i<n;i++)

		if(s[i]&&t[i]){

			printf("POSSIBLE\n");

			return 0;

		}

	printf("IMPOSSIBLE\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int a[1000001],b[1000001];

int main() {

	int n,m,i;

	scanf("%d%d",&n,&m);

	for(i=1; i<=m; i++) {

		int st,ed;

		scanf("%d%d",&st,&ed);

		if(st==1)a[ed]=1;

		if(ed==n)b[st]=1;

	}

	for(i=1; i<=m; i++)

		if(a[i]&&b[i]) {

			printf("POSSIBLE\n");

			return 0;

		}

	printf("IMPOSSIBLE\n");

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,m,a,b,i;bool s[200005],t[200005];

int main(){

	scanf("%d%d",&n,&m);

	for(i=1;i<=m;i++){

		scanf("%d%d",&a,&b);

		if(a==1) s[b]=1;

		if(b==n) t[a]=1;

	}

	for(i=2;i<n;i++)

		if(s[i]&&t[i]){

			printf("POSSIBLE\n");

			return 0;

		}

	printf("IMPOSSIBLE\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#pragma GCC optimize(2)

#include<iostream>

using namespace std;

bool a[200005],b[200005];

int main(){

	int n,m;

	cin>>n>>m;

	int u1=0,u2=0;

	for(int i=0;i<m;i++){

		int q,w;

		cin>>q>>w;

		if(w==n&&q==1){

			cout<<"POSSIBLE";

			return 0;

		}

		if(q==1){

			a[w]=1;

		}

		if(w==n){

			b[q]=q;

		}

	}

	for(int i=0;i<n;i++){

		if(a[i]==1&&b[i]==1){

			cout<<"POSSIBLE";

			return 0;

		}

	}

	cout<<"IMPOSSIBLE";

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,m,a,b,i;bool s[200005],t[200005];

int main(){

	scanf("%d%d",&n,&m);

	for(i=1;i<=m;i++){

		scanf("%d%d",&a,&b);

		if(a==1) s[b]=1;

		if(b==n) t[a]=1;

	}

	for(i=2;i<n;i++)

		if(s[i]&&t[i]){

			printf("POSSIBLE\n");

			return 0;

		}

	printf("IMPOSSIBLE\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#ifdef LOCAL

#include <cstdio>

#include <vector>

#include <algorithm>

#include <iostream>

#include <cstring>

#include <set>

#else

#include <bits/stdc++.h>

#endif

using namespace std ;



typedef long long ll ;

#define rep(i , n ) for ( int i =0; i < n ; i++)

#define _sort(arg) sort(begin(arg), end(arg))

#define MOD 1000000007

#define pb push_back

#define DEBUG(x) cout << #x << ": " << x << endl;



/*

__attribute__((constructor))

void initial()

{

	cin.tie(NULL);

	ios::sync_with_stdio(false);

}

*/



int main()

{

	cin.tie(NULL);

	ios::sync_with_stdio(false);



	int N, M;

	

	cin >> N >> M;

	set<int> start, end;



	rep(i, M)

	{

		int a, b;

		cin >> a >> b;



		if (a == 1)

		{

			start.insert(b);

		}

		else if (b == 1) 

		{

			start.insert(a);

		}



		if (a == N)

		{

			end.insert(b);

		}

		else if (b == N)

		{

			end.insert(a);

		}

	}



	set<int>::iterator it=start.begin();

	bool find_ = false;

	/*

	for(; it!=start.end(); it++)

	{

		cout<<*it<<endl;



	}

	cout << "sdf" <<endl;

	set<int>::iterator ite=end.begin();

	for(; ite!=end.end(); ite++)

	{

		cout << *ite << endl;

	}



	cout <<"sfag" <<(end.find(2) != end.end()) << endl;

	*/

	for(; it!=start.end(); it++)

	{

		//cout << *it << endl;

		if (end.find(*it) != end.end())

		{

			find_ = true;

			break;

		}



	}



	if (find_)

	{

		cout << "POSSIBLE" << endl;

	}

	else

	{

		cout << "IMPOSSIBLE" << endl;

	}



	

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

using namespace std;

int n,m,a,b,i;bool s[200005],t[200005];

int main(){

	scanf("%d%d",&n,&m);

	for(i=1;i<=m;i++){

		scanf("%d%d",&a,&b);

		if(a==1) s[b]=1;

		if(b==n) t[a]=1;

	}

	for(i=2;i<n;i++)

		if(s[i]&&t[i]){

			printf("POSSIBLE\n");

			return 0;

		}

	printf("IMPOSSIBLE\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
using namespace std;

#include <bits/stdc++.h>

const int N = 2e5+5;

struct Edge{

    int to;

    int next;

}edge[N];

int n,m;

int tot,head[N];

void addEdge(int from,int to){

    edge[++tot].to=to;

    edge[tot].next=head[from];

    head[from]=tot;

}

bool dfs(int s,int step){

    if (s == n&&step == 2) return true;

    for(int i=head[s];i!=-1;i=edge[i].next){

        int to=edge[i].to;

        if (dfs(to,step+1)) return true;

    }

    return false;

}

int main() {

    memset(head,-1,sizeof(head));

    scanf("%d%d",&n,&m);

    for(int i=1;i<=m;i++){

        int x,y;

        scanf("%d%d",&x,&y);

        addEdge(x,y);

    }

    bool flag=dfs(1,0);

    if (flag) printf("POSSIBLE\n");

    else printf("IMPOSSIBLE\n");

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

int a[1000001],b[1000001];

int main(){

    int n,m,i;

    scanf("%d%d",&n,&m);

    for(i=1;i<=m;i++){

        int st,ed;

        scanf("%d%d",&st,&ed);

        if(st==1)a[ed]=1;

        if(ed==n)b[st]=1;

    }

    for(i=1;i<=m;i++)

        if(a[i]&&b[i]){

            printf("POSSIBLE\n");return 0;

        }

    printf("IMPOSSIBLE\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include <algorithm>

#include<stdio.h>

#define N 200005

int a[N],b[N];

using namespace std;

int main(){

	int c,d,e,f;

	cin>>e>>f;

	for(int i=0;i<f;i++){

		cin>>c>>d;

		if(c==1) a[d]=1;

		if(d==e) b[c]=1;

	}

	for(int j=1;j<e;j++){

		if(a[j]==1&&b[j]==1){

			cout<<"POSSIBLE"<<endl;

			return 0;

		}	

	}

	cout<<"IMPOSSIBLE"<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int a[1000001],b[1000001];

int main(){

    int n,m,i;

    scanf("%d%d",&n,&m);

    for(i=1;i<=m;i++){

        int st,ed;

        scanf("%d%d",&st,&ed);

        if(st==1)a[ed]=1;

        if(ed==n)b[st]=1;

    }

    for(i=1;i<=m;i++)

        if(a[i]&&b[i]){

            printf("POSSIBLE\n");return 0;

        }

    printf("IMPOSSIBLE\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<cstring>

#include<string>

#include<algorithm>

#include<queue>

#include<cmath>

#include<set>

#include<list>

#include<stack>

#include<vector>

#include<cstdlib>

#include<iterator>

#include<deque>

#include<ctime>

#include<iomanip>

#include<map>

#include<bitset>

#include<utility>

#include<sstream>

using namespace std;

int a[1000001],b[1000001];

int main()

{

	int n,m,i;

	scanf("%d%d",&n,&m);

	for(i=1;i<=m;i++)

	{

		int st,ed;

		scanf("%d%d",&st,&ed);

		if(st==1)a[ed]=1;

		if(ed==n)b[st]=1;

	}

	for(i=1;i<=m;i++)

		if(a[i]&&b[i])

		{

			printf("POSSIBLE\n");return 0;

		}

	printf("IMPOSSIBLE\n");

	return 0;

}




// Optimized solution to the same problem (faster):
#include<cstdio>

int a[1000001],b[1000001];

int main(){

    int n,m,i;

    scanf("%d%d",&n,&m);

    for(i=1;i<=m;i++){

        int st,ed;

        scanf("%d%d",&st,&ed);

        if(st==1)a[ed]=1;

        if(ed==n)b[st]=1;

    }

    for(i=1;i<=m;i++)

        if(a[i]&&b[i]){

            printf("POSSIBLE\n");return 0;

        }

    printf("IMPOSSIBLE\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

int a[200001],b[200001];

int main(){

	int i,j,k,n,m;

	cin>>n>>m;

	for(i=1;i<=m;i++){

		int s1,s2;

		cin>>s1>>s2;

		if(s1==1)a[s2]=1;

		if(s2==n)b[s1]=1;

	}

	for(i=1;i<=m;i++)

	if(a[i]>0&&b[i]>0){

		cout<<"POSSIBLE"<<endl;

		return 0;

	}

	cout<<"IMPOSSIBLE"<<endl;

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int a[1000001],b[1000001];

int main(){

    int n,m,i;

    scanf("%d%d",&n,&m);

    for(i=1;i<=m;i++){

        int st,ed;

        scanf("%d%d",&st,&ed);

        if(st==1)a[ed]=1;

        if(ed==n)b[st]=1;

    }

    for(i=1;i<=m;i++)

        if(a[i]&&b[i]){

            printf("POSSIBLE\n");return 0;

        }

    printf("IMPOSSIBLE\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

int a[1000005],b[1000005],n,m,st,ed;

int main(void){

    cin>>n>>m;

    for(int i=1;i<=m;i++){

        scanf("%d",&st);

        cin>>ed;

        if(st==1)a[ed]=1;

        if(ed==n)b[st]=1;

    }

    for(int i=1;i<=m;i++)

        if(a[i]==1&&b[i]==1){

            puts("POSSIBLE");

            exit(0);

        }

    puts("IMPOSSIBLE");

}

// Optimized solution to the same problem (faster):
#include<cstdio>

int a[1000001],b[1000001];

int main(){

    int n,m,i;

    scanf("%d%d",&n,&m);

    for(i=1;i<=m;i++){

        int st,ed;

        scanf("%d%d",&st,&ed);

        if(st==1)a[ed]=1;

        if(ed==n)b[st]=1;

    }

    for(i=1;i<=m;i++)

        if(a[i]&&b[i]){

            printf("POSSIBLE\n");return 0;

        }

    printf("IMPOSSIBLE\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define F first

#define S second

#define pii pair<int, int>

#define eb emplace_back

#define all(v) v.begin(), v.end()

#define rep(i, n) for (int i = 0; i < (n); ++i)

#define rep3(i, l, n) for (int i = l; i < (n); ++i)

#define sz(v) (int)v.size()

#define inf (int)(1e9+7)

#define abs(x) (x >= 0 ? x : -(x))

#define ceil(a, b) a / b + !!(a % b)

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }

template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }







int cost[200001];

vector<vector<int> > v(200001);

void dfs(int now) {

    if (cost[now] == 2) return;

    for (int nxt : v[now]) {

        if (cost[nxt] <= cost[now] + 1) continue;

        cost[nxt] = cost[now] + 1;

        dfs(nxt);

    }

}



int main() {

    int n, m;

    cin >> n >> m;

    

    

    fill_n(cost, 200001, inf);

    

    rep(i, m) {

        int a, b;

        cin >> a >> b;

        

        a--; b--;

        

        v[a].eb(b);

        v[b].eb(a);

    }

    

    cost[0] = 0;

    dfs(0);

    

    if (cost[n - 1] <= 2) {

        cout << "POSSIBLE" << endl;

    } else {

        cout << "IMPOSSIBLE" << endl;

    }

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

#define F first

#define S second

#define pii pair<int, int>

#define eb emplace_back

#define all(v) v.begin(), v.end()

#define rep(i, n) for (int i = 0; i < (n); ++i)

#define rep3(i, l, n) for (int i = l; i < (n); ++i)

#define sz(v) (int)v.size()

#define inf (int)(1e9+7)

#define abs(x) (x >= 0 ? x : -(x))

#define ceil(a, b) a / b + !!(a % b)

template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

// template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }

template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }





int main() {

    int n, m;

    cin >> n >> m;

    

    map<pii, int> mp;

    rep(i, m) {

        int a, b;

        cin >> a >> b;

        mp[pii(a, b)] = 1;

        mp[pii(b, a)] = 1;

    }

    

    rep3(i, 2, n) {

        if (mp[pii(1, i)] && mp[pii(i, n)]) {

            cout << "POSSIBLE" << endl;

            return 0;

        }

    }

    cout << "IMPOSSIBLE" << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



using namespace std;



int main() {

  //cin.tie(0);

  //ios::sync_with_stdio(false);



  int n, m;

  bool s[200001] = {false};

  bool e[200001] = {false};

  scanf("%d %d", &n, &m);



  int cnt = 0;

  for (int i = 0; i < m; i++) {

    int a, b;

    scanf("%d %d", &a, &b);

    if (a == 1) {

      s[b] = true;

      cnt++;

    }

    else if (b == n) {

      e[a] = true;

    }

  }



  for (int i = 1; i <= m; i++) {

    if (s[i] == true && e[i] == true) {

      printf("POSSIBLE\n");

      return 0;

    }

  }





  printf("IMPOSSIBLE\n");



  return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;



#define INF 0x3f3f3f3f



typedef long long ll;

typedef pair<int, int> P;



int n, m;

int to[200010], from[200010];



int main(){

	cin.tie(0);

  ios::sync_with_stdio(false);



	cin >> n >> m;

	for (int i = 0; i < m; i++) {

		int a, b;

		cin >> a >> b;

		if (a == 1) to[b] = 1;

		if (b == n) from[a] = 1;

	}



	if (to[n] == 1) {

		cout << "POSSIBLE" << endl;

		return 0;

	}



	for (int i = 2; i <= m; i++) {

		if (to[i] == 1 && from[i] == 1) {

			cout << "POSSIBLE" << endl;

			return 0;

		}

	}



	cout << "IMPOSSIBLE" << endl;



	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main(){

  int n,m;

  cin >> n >> m;

  int c[200001]={},d[200001]={};

  for(int i=0;i<m;i++){

    int a,b;

    cin >> a >> b;

    if(a==1) c[b]=1;

    if(b==n) d[a]=1; 

  }

  for(int i=0;i<200001;i++){

    if(c[i]&&d[i]) {

      cout << "POSSIBLE" << endl;

      return 0;

    }   

  }

 cout << "IMPOSSIBLE" << endl;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)



int main(){

    int n,m;

    cin >> n >> m;

    vector<vector<int>> g(n);

    rep(i,m){

        int a,b;

        cin >> a >> b;

        a--;b--;

        g[a].push_back(b);

    } 

    int now = 0,flag = 0;

    for(auto i:g[now]){

        for(auto j :g[i]){

            if(j==n-1) flag = 1;

        }

    }

    if(flag) cout << "POSSIBLE" << endl;

    else cout << "IMPOSSIBLE" << endl;

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

const int maxn=2e5;

int pre[maxn+5],last[maxn+5],other[maxn+5],vis[maxn+5],a[maxn+5],b[maxn+5];

int all=-1,n,m,flag=0,ans=0;



void build(int u,int v)

{

	pre[++all]=last[u];

	last[u]=all;

	other[all]=v;

}



 void dfs(int ds,int cnt)

 {



 	 if(cnt>2) return;

 	 if(ds==n&&cnt<=2) ans++;

 	 int dt,de;

 	 dt=last[ds];

 	 while(dt!=-1){

	 	 de=other[dt];

	 	 if(vis[de]==0)

		 {

		 	 vis[de]=1;

		 	 dfs(de,cnt+1);

		 }

		 dt=pre[dt];

	 }

 }



int main(){

	memset(last,-1,sizeof(last));

	scanf("%d %d",&n,&m);

	for(int i = 1;i <= m;i++){

		scanf("%d %d",&a[i],&b[i]);

		build(a[i],b[i]);

	}

	dfs(1,0);

	if(ans!=0) printf("POSSIBLE\n");

	else printf("IMPOSSIBLE\n");

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

const int maxn=2e5;

int a[maxn+5],b[maxn+5],vis[maxn+5];



int main(){

	int n,m,flag=0;

	scanf("%d %d",&n,&m);

	for(int i = 1;i <= m;i++){

		scanf("%d %d",&a[i],&b[i]);

	}

	for(int i = 1;i <= m;i++){

		if(a[i]==1) vis[b[i]]=1;

	}

	for(int i = 1;i <= m;i++){

		if(b[i]==n&&vis[a[i]]==1) 

		{

			flag=1;

			break;

		}

	}

	if(flag==1) printf("POSSIBLE\n");

	else printf("IMPOSSIBLE\n");

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//周♂雨扬是最强的！！！

//大佬祝您AK

//沈哲♂贝是最强的！！！

#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<fstream>

using namespace std;

int n,m;

int head[2000003],nxt[2000003],to[2000003],tot;

inline void add(int a,int b){

	to[++tot]=b;  nxt[tot]=head[a];  head[a]=tot;

}

bool yes=false;

void dfs(int x,int len){

	if(len>=3||yes){

		return;

	}

	if(x==n){

		yes=true;

		return;

	}

	for(int i=head[x];i;i=nxt[i]){

		dfs(to[i],len+1);

	}

}

int main(){

	cin>>n>>m;

	for(int i=1;i<=m;i++){

		int a,b;

		cin>>a>>b;

		add(a,b);

	}

	dfs(1,0);

	if(yes){

		cout<<"POSSIBLE"<<endl;

	}else{

		cout<<"IMPOSSIBLE"<<endl;

	}

	return 0;

}

//沈♂哲贝是最强的！！！

//大佬祝您AK

//周♂雨扬是最强的！！！

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

    int n,m,vis[200001];

    while(scanf("%d%d",&n,&m)!=EOF)

    {

        int u,v;

        bool flag=false;

        for(int i=1;i<=n;i++)

            vis[i]=false;

        for(int i=1;i<=m;i++)

        {

            scanf("%d%d",&u,&v);

            if(flag) continue;

            if(u==1)

            {

                if(vis[v])

                {

                    flag=true;

                }

                vis[v]=true;

            }else if(v==n)

            {

                if(vis[u])

                {

                    flag=true;

                }

                vis[u]=true;

            }

        }

        if(flag) printf("POSSIBLE\n");

        else printf("IMPOSSIBLE\n");

        break;

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

#define Ll long long

using namespace std;

const int N=2e5+5;

vector<int>h[N];

int n,m,x,y;

void dfs(int x,int y){

	if(y>2)return;

	if(x==n){cout<<"POSSIBLE";exit(0);}

	for(int k=0;k<h[x].size();k++)

		dfs(h[x][k],y+1);

}

int main()

{

	scanf("%d%d",&n,&m);

	for(int i=1;i<=m;i++){

		scanf("%d%d",&x,&y);

		h[x].push_back(y);

	}

	dfs(1,0);

	cout<<"IMPOSSIBLE"; 

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

int main()

{

    int n,m,vis[200001];

    while(scanf("%d%d",&n,&m)!=EOF)

    {

        int u,v;

        bool flag=false;

        for(int i=1;i<=n;i++)

            vis[i]=false;

        for(int i=1;i<=m;i++)

        {

            scanf("%d%d",&u,&v);

            if(flag) continue;

            if(u==1)

            {

                if(vis[v])

                {

                    flag=true;

                }

                vis[v]=true;

            }else if(v==n)

            {

                if(vis[u])

                {

                    flag=true;

                }

                vis[u]=true;

            }

        }

        if(flag) printf("POSSIBLE\n");

        else printf("IMPOSSIBLE\n");

        break;

    }

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

vector<int> a[200500];

int main() {

	int n, m;

	cin >> n >> m;

	for (int i = 0; i < m; i++) {

		int u, v;

		cin >> u >> v;

		a[u].push_back(v);

		a[v].push_back(u);

	}

	bool ok = false;

	for (auto f : a[1]) {

		if (f == n) {

			ok = true;

		}

		for (auto ff : a[f]) {

			if (ff == n) {

				ok = true;

			}

		}

	}

	if (ok)

		cout << "POSSIBLE";

	else

		cout << "IMPOSSIBLE";

	return 0;

}

// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



int main(){

    int n,m;

    scanf(" %d %d",&n,&m);

    vector<vector<int>> g(n);

    for(int i = 0; i < m;++i){

        int a,b;

        scanf(" %d %d",&a,&b);

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

            if(dist[va] == -1){

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"



using namespace std;



const int mx = 200000 + 9;



bitset <mx> mark;

int d[mx];

vector <int> adj[mx];



int main() {

    int n, m; cin >> n >> m;

    for (int i = 0; i < m; i++) {

        int a, b; cin >> a >> b;

        adj[a].push_back(b);

        adj[b].push_back(a);

    }



    mark[1] = 1;

    queue <int> q;

    q.push(1);



    while (!q.empty()) {

        auto u = q.front();

        q.pop();

        for (auto v : adj[u]) {

            if (mark[v]) continue;

            mark[v] = 1;

            d[v] = 1 + d[u];

            q.push(v);

        }

    }



    if (d[n] == 2) cout << "POSSIBLE" << endl;

    else cout << "IMPOSSIBLE" << endl;

}


// Optimized solution to the same problem (faster):
#include<bits/stdc++.h>

using namespace std;



int main(){

    int n,m;

    scanf(" %d %d",&n,&m);

    vector<vector<int>> g(n);

    for(int i = 0; i < m;++i){

        int a,b;

        scanf(" %d %d",&a,&b);

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

            if(dist[va] == -1){

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

}

// Fastest known solution for this problem: