stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 7.152557668059436x):
#include <bits/stdc++.h>

using namespace std;



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 > b) swap(a, b);

      if (a == 1) mp[b]++;

      if (b == N) mp[a]++;

   }



   for (auto x : mp) {

      if (x.second >= 2) {

         puts("POSSIBLE");

         return 0;

      }

   }



   puts("IMPOSSIBLE");



   return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



int s[200009];

int t[200009];



int main() {

    int n, m;

    cin >> n >> m;



    bool flag = false;

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

        int a, b;

        cin >> a >> b;

        if (a == 1) {

            s[b]++;

        }

        if (b == n) {

            t[a]++;

        }

    }



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

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

            flag = true;

        }

    }



    if (flag) {

        puts("POSSIBLE");

    } else {

        puts("IMPOSSIBLE");

    }



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.7793177398450335x):
#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;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



#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;

}


// Faster C++ solution for the same problem (measured speedup: 7.166821498024352x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 7.166821498024352x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.297365323783238x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.225899694345541x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.282436875387257x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.4202511643626465x):
#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;

}
// Slower C++ solution:
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;

}


// Faster C++ solution for the same problem (measured speedup: 1.7995649901127746x):
#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");

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.295387259768548x):
#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;

}
// Slower C++ solution:
#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;

}




// Faster C++ solution for the same problem (measured speedup: 5.223948315971965x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.29466712107517x):
#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;

}
// Slower C++ solution:
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;

}


// Faster C++ solution for the same problem (measured speedup: 9.513492969016255x):
#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;

}
// Slower C++ solution:
#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");

}

// Faster C++ solution for the same problem (measured speedup: 5.286551483989509x):
#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;

}
// Slower C++ solution:
#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;

    }

}


// Faster C++ solution for the same problem (measured speedup: 7.396849865469462x):
#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;

}
// Slower C++ solution:
#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;

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.34362094336303x):
#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;

    

    bool table[200001][2] = {0};

    rep(i, m) {

        int a, b;

        cin >> a >> b;

        a--; b--;

        if (a > b) swap(a, b);

        

        if (a == 0) {

            table[b][0] = 1;

        }

        if (b == n - 1) {

            table[a][1] = 1;

        }

    }

    

    rep3(i, 1, n) {

        if (table[i][0] && table[i][1]) {

            cout << "POSSIBLE" << endl;

            return 0;

        }

    }

    cout << "IMPOSSIBLE" << endl;

}