stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int read(){

	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();

	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();

	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;

}int n,m,f[1000000],x,y;

struct lsg{int x,y;}a[1000000];

int pd(lsg x,lsg y){return x.y<y.y;}

int main(){

	n=read();m=read();memset(f,10,sizeof(f));f[1]=0;

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

		x=read();y=read();

		a[i].x=x;a[i].y=y;

	}sort(a+1,a+1+m,pd);

	for (int i=1;i<=m;i++)f[a[i].y]=min(f[a[i].x]+1,f[a[i].y]);

	if (f[n]<=2)puts("POSSIBLE");else puts("IMPOSSIBLE");

}


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

#define FOR(k,m,n) for(int(k)=(m);(k)<(n);(k)++)

#define REP(k,n) FOR((k),0,(n))

using namespace std;

typedef long long ll;

typedef vector<ll> VLL;

const int MOD=1000000007;



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    ll n, m;

    cin >> n >> m;



    vector< vector<ll> > arr(n);



    ll a, b;

    REP(i, m){

        cin >> a >> b;

        a--;

        b--;

        arr[a].push_back(b);

        arr[b].push_back(a);

    }



    REP(i, arr[0].size()){

        REP(j, arr[arr[0][i]].size()){

            if(arr[arr[0][i]][j] == n-1){

                cout << "POSSIBLE" << endl;

                return 0;

            }

        }

    }



    cout << "IMPOSSIBLE" << endl;



    return 0;

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<map>

#define ll long long

#define N 200005

#define mod 1000000007

#define rep(i,j,k) for (ll i=j;i<=k;++i)

#define per(i,j,k) for (ll i=j;i>=k;--i)

using namespace std;

inline ll read(){

	char ch=getchar(); ll x=0,f=1;

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}

map<ll,ll>mp[N];

ll n,m;

int main(){

	n=read(); m=read();

	rep(i,1,m){

		ll u=read(),v=read();

		mp[u][v]=1; mp[v][u]=1;

	}

	rep(i,2,n-1) if (mp[1][i]&&mp[i][n]) return puts("POSSIBLE")&0;

	puts("IMPOSSIBLE");

}

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

using namespace std;



typedef long long ll;

#define mp make_pair

#define pb push_back

#define pi pair<ll,ll>

#define ff first

#define ss second

#define MAX 200550

const ll MOD = 1000000007;



vector<int>g[MAX];

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);



	int t=1;

//	cin>>t;

	while(t--){

	 int n,m;

	 cin>>n>>m;

	 

	 while(m--)

	 {

	 	int u,v;

	 	cin>>u>>v;

	 	

	 	g[u].pb(v);

	 	g[v].pb(u);

	 }

	 for(auto elm:g[1])

	 {

	 	for(auto f:g[elm])

	 	{

	 		if(f==n)

	 		{

	 			cout<<"POSSIBLE\n";

	 			return 0;

			 }

		 }

	 }

	 cout<<"IMPOSSIBLE\n";

	}		

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<map>

#define ll long long

#define N 200005

#define mod 1000000007

#define rep(i,j,k) for (ll i=j;i<=k;++i)

#define per(i,j,k) for (ll i=j;i>=k;--i)

using namespace std;

inline ll read(){

	char ch=getchar(); ll x=0,f=1;

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}

map<ll,ll>mp[N];

ll n,m;

int main(){

	n=read(); m=read();

	rep(i,1,m){

		ll u=read(),v=read();

		mp[u][v]=1; mp[v][u]=1;

	}

	rep(i,2,n-1) if (mp[1][i]&&mp[i][n]) return puts("POSSIBLE")&0;

	puts("IMPOSSIBLE");

}

// Faster C++ solution for the same problem (measured speedup: 11.830741371905178x):
///Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>

using namespace std;

#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)

#define     int 	    long long

#define 	pb 	        push_back

#define 	mp 	        make_pair

#define 	pi 	        2*acos(0.0)

#define     scan(i)     scanf("%lld",&i)

#define     scann(i,j)  scanf("%lld%lld",&i,&j)

#define     print(i)    printf("%lld\n",i)

#define     printt(i,j) printf("%lld %lld\n",i,j)

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

#define     loopp(i,n) 	for(int i = 1 ; i <=n ; i++)

#define 	vect 	    vector<int>

#define 	vec_it 	    vector<int>::reverse_iterator vi

#define     sorta(v)    sort(v.begin(),v.end())

#define     sortd(v)    sort(v.begin(),v.end(),greater<>())

#define     sorted      is_sorted(v.begin(),v.end())

#define 	mapp 	    map<int,int>

#define 	pairr 	    pair<int,int>

#define 	sett	    set<int>

#define 	set_it 	    set<int>::reverse_iterator si

#define     map_it      map<int,int> :: reverse_iterator mi

#define 	yes 	    cout<<"YES"<<endl

#define 	no 	        cout<<"NO"<<endl

#define 	ff 	        first

#define 	ss 	        second

#define     mx          INT_MAX

#define     lmx         LLONG_MAX

#define     mn          INT_MIN

#define     lmn         LLONG_MIN

#define     GCD         __gcd(a,b)

#define     LCM         (a/GCD)*b

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

template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}

int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }



void solve()

{

  //  freopen ("(input).txt" , "r",  stdin) ;

  //  string st,stt ;

  //  int low=0,high=0;

  //  int l=0,r;

    int n,k,t,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;

    cin>>n>>k  ; vect v ,a ,b  ; sett s ; set_it ; mapp m,mm ;  map_it ; pairr p[k] ;

    loop(i,k)

    {

        cin>>p[i].ff>>p[i].ss;

        if(p[i].ff==1)

            m[p[i].ss]++;

    }

    loop(i,k)

    {

        if(m[p[i].ff]>0&&p[i].ss==n)

        {

            temp=1;break;

        }



    }

    if(temp==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





}



main()

{

    int t;

  //  cin>>t;

  //  while(t--)

        solve();

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

using namespace std;

int read(){

	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();

	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();

	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;

}int n,m,f[1000000],x,y;

struct lsg{int x,y;}a[1000000];

int pd(lsg x,lsg y){return x.y<y.y;}

int main(){

	n=read();m=read();memset(f,10,sizeof(f));f[1]=0;

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

		x=read();y=read();

		a[i].x=x;a[i].y=y;

	}sort(a+1,a+1+m,pd);

	for (int i=1;i<=m;i++)f[a[i].y]=min(f[a[i].x]+1,f[a[i].y]);

	if (f[n]<=2)puts("POSSIBLE");else puts("IMPOSSIBLE");

}


// Faster C++ solution for the same problem (measured speedup: 5.0198112972276485x):
///Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>

using namespace std;

#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)

#define     int 	    long long

#define 	pb 	        push_back

#define 	mp 	        make_pair

#define 	pi 	        2*acos(0.0)

#define     scan(i)     scanf("%lld",&i)

#define     scann(i,j)  scanf("%lld%lld",&i,&j)

#define     print(i)    printf("%lld\n",i)

#define     printt(i,j) printf("%lld %lld\n",i,j)

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

#define     loopp(i,n) 	for(int i = 1 ; i <=n ; i++)

#define 	vect 	    vector<int>

#define 	vec_it 	    vector<int>::reverse_iterator vi

#define     sorta(v)    sort(v.begin(),v.end())

#define     sortd(v)    sort(v.begin(),v.end(),greater<>())

#define     sorted      is_sorted(v.begin(),v.end())

#define 	mapp 	    map<int,int>

#define 	pairr 	    pair<int,int>

#define 	sett	    set<int>

#define 	set_it 	    set<int>::reverse_iterator si

#define     map_it      map<int,int> :: reverse_iterator mi

#define 	yes 	    cout<<"YES"<<endl

#define 	no 	        cout<<"NO"<<endl

#define 	ff 	        first

#define 	ss 	        second

#define     mx          INT_MAX

#define     lmx         LLONG_MAX

#define     mn          INT_MIN

#define     lmn         LLONG_MIN

#define     GCD         __gcd(a,b)

#define     LCM         (a/GCD)*b

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

template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}

int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }



void solve()

{

  //  freopen ("(input).txt" , "r",  stdin) ;

  //  string st,stt ;

  //  int low=0,high=0;

  //  int l=0,r;

    int n,k,t,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;

    cin>>n>>k  ; vect v ,a ,b  ; sett s ; set_it ; mapp m,mm ;  map_it ; pairr p[k] ;

    loop(i,k)

    {

        cin>>p[i].ff>>p[i].ss;

        if(p[i].ff==1)

            m[p[i].ss]++;

    }

    loop(i,k)

    {

        if(m[p[i].ff]>0&&p[i].ss==n)

        {

            temp=1;break;

        }



    }

    if(temp==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





}



main()

{

    int t;

  //  cin>>t;

  //  while(t--)

        solve();

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

using namespace std;



typedef long long ll;

#define mp make_pair

#define pb push_back

#define pi pair<ll,ll>

#define ff first

#define ss second

#define MAX 200550

const ll MOD = 1000000007;



vector<int>g[MAX];

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);



	int t=1;

//	cin>>t;

	while(t--){

	 int n,m;

	 cin>>n>>m;

	 

	 while(m--)

	 {

	 	int u,v;

	 	cin>>u>>v;

	 	

	 	g[u].pb(v);

	 	g[v].pb(u);

	 }

	 for(auto elm:g[1])

	 {

	 	for(auto f:g[elm])

	 	{

	 		if(f==n)

	 		{

	 			cout<<"POSSIBLE\n";

	 			return 0;

			 }

		 }

	 }

	 cout<<"IMPOSSIBLE\n";

	}		

}

// Faster C++ solution for the same problem (measured speedup: 6.460290951411114x):
///Bismillahir Rahmanir Rahim

#include<bits/stdc++.h>

using namespace std;

#define     FAST        ios_base::sync_with_stdio(false);cin.tie(NULL)

#define     int 	    long long

#define 	pb 	        push_back

#define 	mp 	        make_pair

#define 	pi 	        2*acos(0.0)

#define     scan(i)     scanf("%lld",&i)

#define     scann(i,j)  scanf("%lld%lld",&i,&j)

#define     print(i)    printf("%lld\n",i)

#define     printt(i,j) printf("%lld %lld\n",i,j)

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

#define     loopp(i,n) 	for(int i = 1 ; i <=n ; i++)

#define 	vect 	    vector<int>

#define 	vec_it 	    vector<int>::reverse_iterator vi

#define     sorta(v)    sort(v.begin(),v.end())

#define     sortd(v)    sort(v.begin(),v.end(),greater<>())

#define     sorted      is_sorted(v.begin(),v.end())

#define 	mapp 	    map<int,int>

#define 	pairr 	    pair<int,int>

#define 	sett	    set<int>

#define 	set_it 	    set<int>::reverse_iterator si

#define     map_it      map<int,int> :: reverse_iterator mi

#define 	yes 	    cout<<"YES"<<endl

#define 	no 	        cout<<"NO"<<endl

#define 	ff 	        first

#define 	ss 	        second

#define     mx          INT_MAX

#define     lmx         LLONG_MAX

#define     mn          INT_MIN

#define     lmn         LLONG_MIN

#define     GCD         __gcd(a,b)

#define     LCM         (a/GCD)*b

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

template <typename T> T lcm(T a,T b) {return a*(b/gcd(a,b));}

int modulo (int a, int b) { return a >= 0 ? a % b : ( b - abs ( a%b ) ) % b; }



void solve()

{

  //  freopen ("(input).txt" , "r",  stdin) ;

  //  string st,stt ;

  //  int low=0,high=0;

  //  int l=0,r;

    int n,k,t,x,y,z,d=0,temp=0,cnt=0,sum=0,f=0;

    cin>>n>>k  ; vect v ,a ,b  ; sett s ; set_it ; mapp m,mm ;  map_it ; pairr p[k] ;

    loop(i,k)

    {

        cin>>p[i].ff>>p[i].ss;

        if(p[i].ff==1)

            m[p[i].ss]++;

    }

    loop(i,k)

    {

        if(m[p[i].ff]>0&&p[i].ss==n)

        {

            temp=1;break;

        }



    }

    if(temp==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





}



main()

{

    int t;

  //  cin>>t;

  //  while(t--)

        solve();

}
// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<algorithm>

#include<map>

#define ll long long

#define N 200005

#define mod 1000000007

#define rep(i,j,k) for (ll i=j;i<=k;++i)

#define per(i,j,k) for (ll i=j;i>=k;--i)

using namespace std;

inline ll read(){

	char ch=getchar(); ll x=0,f=1;

	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }

	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }

	return x*f;

}

map<ll,ll>mp[N];

ll n,m;

int main(){

	n=read(); m=read();

	rep(i,1,m){

		ll u=read(),v=read();

		mp[u][v]=1; mp[v][u]=1;

	}

	rep(i,2,n-1) if (mp[1][i]&&mp[i][n]) return puts("POSSIBLE")&0;

	puts("IMPOSSIBLE");

}

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

using namespace std;



int main()

{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, n1; cin >> n >> n1;

    bool arr[n];

    memset(arr, false, sizeof(arr));

    bool res = false;

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

        int x, y; cin >> x >> y;

        if(x == 1){

            if(arr[y]) res = true;

            arr[y] = true;

        }

        else if(y == n){

            if(arr[x]) res = true;

            arr[x] = true;

        }

    }

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

    else cout << "IMPOSSIBLE"<< endl;





    return 0;

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

using namespace std;

int read(){

	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();

	int kk=1,k=0;if (c=='-')kk=-1,c=getchar();

	while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();return kk*k;

}int n,m,f[1000000],x,y;

struct lsg{int x,y;}a[1000000];

int pd(lsg x,lsg y){return x.y<y.y;}

int main(){

	n=read();m=read();memset(f,10,sizeof(f));f[1]=0;

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

		x=read();y=read();

		a[i].x=x;a[i].y=y;

	}sort(a+1,a+1+m,pd);

	for (int i=1;i<=m;i++)f[a[i].y]=min(f[a[i].x]+1,f[a[i].y]);

	if (f[n]<=2)puts("POSSIBLE");else puts("IMPOSSIBLE");

}


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

using namespace std;



int main()

{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, n1; cin >> n >> n1;

    bool arr[n];

    memset(arr, false, sizeof(arr));

    bool res = false;

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

        int x, y; cin >> x >> y;

        if(x == 1){

            if(arr[y]) res = true;

            arr[y] = true;

        }

        else if(y == n){

            if(arr[x]) res = true;

            arr[x] = true;

        }

    }

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

    else cout << "IMPOSSIBLE"<< endl;





    return 0;

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

using namespace std;



typedef long long ll;

#define mp make_pair

#define pb push_back

#define pi pair<ll,ll>

#define ff first

#define ss second

#define MAX 200550

const ll MOD = 1000000007;



vector<int>g[MAX];

int main(){

	ios_base::sync_with_stdio(0); cin.tie(0);



	int t=1;

//	cin>>t;

	while(t--){

	 int n,m;

	 cin>>n>>m;

	 

	 while(m--)

	 {

	 	int u,v;

	 	cin>>u>>v;

	 	

	 	g[u].pb(v);

	 	g[v].pb(u);

	 }

	 for(auto elm:g[1])

	 {

	 	for(auto f:g[elm])

	 	{

	 		if(f==n)

	 		{

	 			cout<<"POSSIBLE\n";

	 			return 0;

			 }

		 }

	 }

	 cout<<"IMPOSSIBLE\n";

	}		

}

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

using namespace std;



int main()

{

    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n, n1; cin >> n >> n1;

    bool arr[n];

    memset(arr, false, sizeof(arr));

    bool res = false;

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

        int x, y; cin >> x >> y;

        if(x == 1){

            if(arr[y]) res = true;

            arr[y] = true;

        }

        else if(y == n){

            if(arr[x]) res = true;

            arr[x] = true;

        }

    }

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

    else cout << "IMPOSSIBLE"<< endl;





    return 0;

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

using namespace std;



int n, m;

vector<int>E[200005];

bool vis[200005];



void dfs(int Now,int dep){

    if(Now == n){

        puts("POSSIBLE");

        exit(0);

    }

    else if(dep > 1) return;

    for(auto Nex : E[Now]){

        if( !vis[Nex] ){

            vis[Nex] = true;

            dfs(Nex, dep + 1);

            //vis[Nex] = false;

        }

    }

}



int main(){

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

    while(m--){

        int x,y;

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

        E[x].push_back(y);

        E[y].push_back(x);

    }

    dfs(1, 0);

    printf("IMPOSSIBLE");

    return 0;



}


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

using namespace std;



int n, m;

bool vis[200005];

vector<int>E;



int main(){

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

    E.push_back(1);

    while(m--){

        int x,y;

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

        if(x == n) vis[y] = true;

        if(y == n) vis[x] = true;

        if(x == 1) E.push_back(y);

        if(y == 1) E.push_back(x);

    }

    for(auto Pos : E){

        if( vis[Pos] == true ){

            printf("POSSIBLE");

            exit(0);

        }



    }

    printf("IMPOSSIBLE");

    return 0;



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

#include <vector>

#include <queue>

#include <string.h>

using namespace std;



int d[200005];

const int inf = 200005;

vector<int> v[200005];



void bfs(void)

{

    d[1] = 0;



    queue<int> q;



    q.push(1);



    while (!q.empty())

    {

        int t = q.front();q.pop();



        for (int i = 0;i < v[t].size();i++)

        {

            int tt = v[t][i];



            if (d[t] + 1 < d[tt])

            {

                d[tt] = d[t] + 1;



                q.push(tt);

            }

        }

    }

}



int main()

{

    memset(d,inf,sizeof(d));



    int n,m;



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



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

    {

        int a,b;



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



        v[a].push_back(b);

    }



    bfs();



    if (d[n] == 2) printf("POSSIBLE\n");

    else printf("IMPOSSIBLE\n");



    return 0;

}


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

#include <string.h>



bool from[200005];

bool to[200005];



int main()

{

    int n,m;



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



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

    {

        int a,b;



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



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

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

    }



    bool ans = 0;



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

    {

        if (from[i] && to[i])

        {

            ans = 1;

            break;

        }

    }



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

    else printf("IMPOSSIBLE\n");



    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <fstream>

#include <cstdio>

#include <cassert>

#include <complex>

#include <cmath>

#include <algorithm>

#include <vector>

#include <string>

#include <cstdlib>

#include <cstring>

#include <iomanip>

#include <numeric>

#include <sstream>

#include <ctime>

#include <cctype>

#include <set>

#include <map>

#include <queue>

#include <bitset>

#include <deque>

#include <stack>

#include <memory.h>

using namespace std;

#define ll long long

int n,m;

vector<int> to;

bool ok[200010];

int main()

{

	memset(ok,0,sizeof(ok));

	cin>>n>>m;

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

		int x,y;

		cin>>x>>y;

		if(x==1&&y==n){

			cout<<"POSSIBLE";

			return 0;

		}

		if(x==1){

			ok[y]=1;

		}

		if(y==n){

			to.push_back(x);

		}

	}

	for(int i=0;i<to.size();i++){

		if(ok[to[i]]){

			cout<<"POSSIBLE";

			return 0;

		}

	}

	cout<<"IMPOSSIBLE";

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1979812834748294x):
//周♂雨扬是最强的！！！

//大佬祝您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

//周♂雨扬是最强的！！！
// Slower C++ solution:
// skyrim belongs to the nords

#include<bits/stdc++.h>

#define mp make_pair

#define pb push_back 

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

#define rep(i, a, b) for(int (i) = (a); (i) < (b); (i)++)

#define dec(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)

#define clr(a,v) memset(a, v, sizeof(a))

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

#define LOGN 18

#define EPS 1e-8

#define fcin ios_base::sync_with_stdio(false)

using namespace std;

typedef long long ll;

typedef double ld;

typedef pair<int,int> pii;

typedef vector<int> vi;



int d[200005], N, M;

vector<int> adj[200005];

vector<int> v;

bool pos = false; 

void dfs(int curr, int k) {

	if (pos) return;

	if (k == 0) {

		if (curr == N) pos = true;

		return;

	}

	// v.push_back(curr);

	for (auto &x: adj[curr]) {

		dfs(x, k - 1);

		if (pos) return;

	}

	// v.pop_back(); 

}

int main(){

	fcin;

	cin.tie(0);

 

	cin >> N >> M;

	int a, b;

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

		cin >> a >> b;

		adj[a].pb(b);

		adj[b].pb(a);

	} 

	dfs(1, 2);

	if (!pos) cout << "IMPOSSIBLE\n";

	else cout << "POSSIBLE\n";

}


// Faster C++ solution for the same problem (measured speedup: 6.50866519266896x):
//周♂雨扬是最强的！！！

//大佬祝您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

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