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

using namespace std;

typedef long long ll;



int main(){

    int n,m;

    cin>>n>>m;

    vector<int> v[200010];

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

        int a,b;

        cin>>a>>b;

        v[a].push_back(b);

        v[b].push_back(a);

    }

    for(auto i:v[1]){

        for(auto j:v[i]){

            if(j==n){

                cout<<"POSSIBLE"<<endl;

                return 0;

            }

        }

    }

    cout<<"IMPOSSIBLE"<<endl;

}


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

using namespace std;

typedef long long ll;



bool from1[200010],ton[200010];



int main(){

    int n,m;

    cin>>n>>m;

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

        int a,b;

        cin>>a>>b;

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

        else if(b==1)from1[a]=true;

        else if(a==n)ton[b]=true;

        else if(b==n)ton[a]=true;

    }

    for(int i=2;i<=n-1;i++){

        if(from1[i]&&ton[i]){

            cout<<"POSSIBLE"<<endl;

            return 0;

        }

    }

    cout<<"IMPOSSIBLE"<<endl;

}


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

#include <cmath>

#include <vector>

#include <queue>

#include <algorithm>



using namespace std;



#define INF 1e9

#define MAXN 100005

#define MAXM 200005

#define ll long long

#define vi vector<int>

#define vll vector<long long>

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

#define pii pair<int, int>



int N, M, a[MAXM], b[MAXM],  cur, tmp, level = 0;

vi d[MAXM] = {}, dist(MAXM, -1);

queue<int> q;



void dfs(){

    q.push(0);

    dist[0] = 0;



    while(!q.empty()){

        cur = q.front();

        q.pop();

        

        rep(i, d[cur].size()){

            tmp = d[cur][i];

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

                // cout << tmp << " ";

                q.push(tmp);

                dist[tmp] = dist[cur] + 1;

            }

        }

        // cout << endl;

    }

}



void solve(){

    dfs();



    if(dist[N-1]==2)

        cout << "POSSIBLE" << endl;

    else

        cout << "IMPOSSIBLE" << endl;

}



int main(){

    cin >> N >> M;



    rep(i,M){

        cin >> a[i] >> b[i];

        a[i]--;

        b[i]--;

        d[a[i]].push_back(b[i]);

        d[b[i]].push_back(a[i]);

    }



    solve();

}


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

#include <cmath>

#include <vector>

#include <string>

#include <algorithm>



using namespace std;



#define INF 1e9

#define MAXN 200005

#define MAXM 100005

#define ll long long

#define vi vector<int>

#define vll vector<long long>

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

#define pii pair<int, int>



ll ans;

int N,M;

vi A, B;

bool visited[MAXN] = {}, flag=false;;



void solve(){

    rep(i, M){

        if(A[i] == 0) visited[B[i]] = true;

    }



    rep(i, M){

        if(B[i] == (N-1) && visited[A[i]]) {

            flag = true;

            break;

        }

    }



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

    else cout << "IMPOSSIBLE" << endl;

}



int main(){

    cin >> N >> M;

    A.resize(M);

    B.resize(M);



    rep(i, M) {

        cin >> A[i] >> B[i];

        A[i]--, B[i]--;

    }

    solve();

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
//关于划船问题，从1道n只能转一次船也必须转一次船，

//所以需要有【1，c】，【c，n】两条船，所以只需要保存a=1的值和b=n的值。



#include<bits/stdc++.h>

#define N 200010

using namespace std;



int arr[N];

int brr[N];

int p=0,q=0;

int n,m;



int main() {

	cin>>n>>m;

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

		int a,b;

		cin>>a>>b;

		if(a==1) {

			arr[p++]=b;

		}

		if(b==n) {

			brr[q++]=a;

		}

	}

	if(p==0||q==0) {

		cout<<"IMPOSSIBLE";

		return 0;

	}

	sort(arr,arr+p);

	sort(brr,brr+q);

	int i,j=1;

	for(i=0; i<p; i++) {

		j--;

		for(j; j<q; j++) {

			if(arr[i]==brr[j]) {

				break;

			}

			if(arr[i]<brr[j])

				break;

		}

		if(arr[i]==brr[j])

			break;

	}

	if(arr[i]==brr[j]&&i!=p)

		cout<<"POSSIBLE";

	else

		cout<<"IMPOSSIBLE";

	return 0;

}

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

int a[200005],b[200005];

int main() {

    int n,m;

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

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

    {

        int beg,ends;

        scanf("%d %d",&beg,&ends);

        if(beg==1)	a[ends]=1;

        if(ends==n)	b[beg]=1;

    }

    for(int i=1;i<=m;++i)	if(a[i] && b[i])	return 0*printf("POSSIBLE");

    printf("IMPOSSIBLE");

    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 <bits/stdc++.h>

#define LL long long

#define PII pair<int,int>

#define PIL pair<int,LL>

#define PLI pair<LL,int>

#define PIII pair<int,PII>

#define PLL pair<LL,LL>

#define PLII pair<LL,PII>

#define VI vector<int>

#define VVI vector<VI>

#define VL vector<LL>

#define VVL vector<VL>

#define VPII vector<PII>

#define FF first

#define SS second

#define MP make_pair

#define PB push_back

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

#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'

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

#define setp(x) cout<<fixed<<setprecision(x)

#define EPS 0.00000000001

#define PI acos(-1)

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

#define rev_loop(i,b,n) for(int i=b;i>=n;--i)

using namespace std;



const int MOD = 1e9 + 7;

const LL MX = 1e9;

const LL INF = 1e9;



void print_a(VI v)

{

    if(v.size()) cout<<v[0];

    loop(i,1,v.size()) cout<<' '<<v[i];

    cout<<'\n';

}



VVI init_vvi(int n, int m, int val)

{

    return VVI(n,VI(m,val));

}



VVL init_vvl(int n, int m, LL val)

{

    return VVL(n,VL(m,val));

}



int main()

{

    //ofstream out("output.txt");

    //ifstream in("input.txt");

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



    int n,m;

    cin>>n>>m;

    int u,v;



    VI g[n+1];

    loop(i,0,m)

    {

        cin>>u>>v;

        g[u].PB(v);

    }



    int f = 0;

    for(int u1 : g[1])

    {

        if(binary_search(all(g[u1]),n)) {f = 1; break;}

    }



    if(f) cout<<"POSSIBLE\n";

    else cout<<"IMPOSSIBLE\n";



    /*

    int t,n;

    cin>>t;

    while(t--)

    {

        cin>>n;

        int a[n];

        loop(i,0,n)

        {

            cin>>a[i];

        }

    }

    */



    /*

    int n;

    cin>>n;

    int a[n];

    loop(i,0,n)

    {

        cin>>a[i];

    }

    */



    /*

    cout<<ans<<'\n';



    if(f) cout<<"YES\n";

    else cout<<"NO\n";



    if(f) cout<<"Yes\n";

    else cout<<"No\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         pb         push_back

#define         sf(x)      scanf("%d",&x)

#define         sfl(x)     scanf("%lld",&x)

#define         pf(x)      printf("%d\n",x)

#define         pfl(x)     printf("%lld\n",x)

#define         endl       '\n'

#define         pii        pair<int,int>

#define         mapii      map<int,int>

#define         mapll      map<ll,ll>

#define         mapci      map<char,int>

#define         mapcl      map<char,ll>

#define         mapsi      map<string,int>

#define         mapsl      map<string,ll>

#define         pll        pair<ll,ll>

#define         vi         vector<int>

#define         vl         vector<ll>

#define         vd         vector<double,double>

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

#define         F          first

#define         S          second

#define         mp         make_pair

#define        ftc(x)      cerr << #x << ": " << x << " " << endl;

#define         PI         acos(-1)

#define         lcm(a,b)   ((a*b)/__gcd(a,b))

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

#define        sqr(a)       ((a)*(a))



vi ad[200009];

int dis[200009];

bool vis[200009];



void dfs(int x)

{

    vis[x] = 1;



    for(auto u : ad[x])

    {

        if(!vis[u] && dis[x]+1 < dis[u])

        {

            dis[u] = dis[x]+1;

            dfs(u);

        }

    }

}



int main()

{



    int n,m,i,j,k,l,u,v;



    cin >> n >> m;



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

    {

        cin >> u >> v;



        ad[u].pb(v);

        ad[v].pb(u);

    }



   bool faltu = false;



   for(auto x : ad[1])

   {

       if(x == n)faltu = true;



       for(auto kk : ad[x])

       {

           if(kk == n)faltu = true;

       }

   }

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

    else cout << "IMPOSSIBLE" << endl;

//    ll i,j,k,n,x,m;

//

//    cin >> n>> x;

//ll ar[n+10];

//

//ll cnt = 0;

//    for(i=0;i<n;i++)

//    {

//        cin >> ar[i];

//    }

//

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

//    {

//        m = ar[i]+ar[i-1];

//        if(m>x)

//        {

//            ll baki = m-x;

//

//            ar[i] -= baki;

//            cnt += baki;

//        }

//    }

//

//    cout << cnt << endl;

}


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

using namespace std;



inline void init(){

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

}



int main() {

	init();

	int n, m;

	cin >> n >> m;

	vector<int> st, ed;

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

		int a, b;

		cin >> a >> b;

		if(a == 1)

			st.push_back(b);

		if(b == n)

			ed.push_back(a);

	}

	sort(ed.begin(), ed.end());

	for(auto num : st)

		if(binary_search(ed.begin(), ed.end(), num)){

			cout << "POSSIBLE";

			return 0;

		}

	cout << "IMPOSSIBLE";

	return 0;

}


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

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>



#define            ll              long long

#define            pb              push_back

#define            mp              make_pair

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

#define            clr(x)          memset(x,0,sizeof x)

#define            min3(a,b,c)     min(a,min(b,c))

#define            max3(a,b,c)     max(a,max(b,c))

#define            min4(a,b,c,d)   min(a,min(b,min(c,d)))

#define            max4(a,b,c,d)   max(a,max(b,max(c,d)))

#define            fast            ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define            pii             pair<int,int>

#define            pll             pair<ll,ll>

#define            pli             pair<ll,int>

#define            pil             pair<int,ll>

#define            FF              first

#define            SS              second

#define            PI              acos(-1.0)

#define            bug             cout<<"ok"<<endl;



using namespace std;

using namespace __gnu_pbds;



typedef tree<int , null_type,less<int>,

       rb_tree_tag, tree_order_statistics_node_update> anik;



const int MOD = 1e9 + 7;

const ll MX= 1e9;

const ll INF = 1e9;

vector<int>adj[200009];

bool visited[200009];

int n,m;

bool dfs(int s)

{    visited[s]=true;

    for(int i=0;i<adj[s].size();i++)

    {

        if(visited[adj[s][i]]==false)

        {

            int p=adj[s][i];

            for(int j=0;j<adj[p].size();++j)

                if(adj[p][j]==n)return 1;

        }

    }

    return 0;

}



main()

{

   cin>>n>>m;



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

   {

       int x,y;

       cin>>x>>y;

       adj[x].pb(y);

       adj[y].pb(x);

   }

   bool ok=dfs(1);

   if(ok==1)cout<<"POSSIBLE"<<endl;

   else

    cout<<"IMPOSSIBLE"<<endl;

}




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

using namespace std;



inline void init(){

	ios_base::sync_with_stdio(false);

	cin.tie(NULL);

	cout.tie(NULL);

}



int main() {

	init();

	int n, m;

	cin >> n >> m;

	vector<int> st, ed;

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

		int a, b;

		cin >> a >> b;

		if(a == 1)

			st.push_back(b);

		if(b == n)

			ed.push_back(a);

	}

	sort(ed.begin(), ed.end());

	for(auto num : st)

		if(binary_search(ed.begin(), ed.end(), num)){

			cout << "POSSIBLE";

			return 0;

		}

	cout << "IMPOSSIBLE";

	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;

	bool first[200005], second[200005];

	fill(first, first + 200005, false);

	fill(second, second + 200005, false);

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

		int a, b;

		cin >> a >> b;

		if (a == 1 && b != n) {

			first[b] = true;

		}

		if (a != 1 && b == n) {

			second[a] = true;

		}

	}

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

		if (first[i] && second[i]) {

			cout << "POSSIBLE" << endl;

			return 0;

		}

	}

	cout << "IMPOSSIBLE" << endl;

	return 0;

}




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

using namespace std;



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);  

	int n, m;

	cin >> n >> m;

	vector<int> to, islands(n + 1);

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

		int a, b;

		cin >> a >> b;

		if(a == 1) {

			islands[b] = 1;

		}

		if(b == n) {

			to.push_back(a);

		}

	}

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

		if(islands[to[i]]) {

			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 n,m,x,y,fl[200005];

int main(){

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

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

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

		if (x>y) swap(x,y);

		if (x==1) fl[y]|=1;

		if (y==n) fl[x]|=2;

		if (fl[x]==3||fl[y]==3)

			return puts("POSSIBLE"),0;

	}

	puts("IMPOSSIBLE");

}

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

long a[200003],b[200003];

int main()



{

	long n,m,i,j=0,k=0,x,y,c,d,t1=0,t2=0,t;

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

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

	{

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

		if(x==1)

		{

			a[y]=1;

			t1=(y>t2)?y:t1;

		}

		if(y==n)

		{

			b[x]=1;

			t2=(x>t2)?x:t2;

		}

	}

	t=(t1>t2)?t1:t2;

	int flag=0;

	for(i=0;i<=t;i++)

	{

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

		flag=1;break;}

	}

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

	else printf("IMPOSSIBLE\n");

	return 0;

}

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

#include <cstring>

#include <cmath>

#include <algorithm>

#include <iostream>

using namespace std;



#define rp(i,t) for(int i=0;i<(t);i++)

#define rep(i,s,t) for(int i=(s);i<=(t);i++)

#define rsp(i,s,t) for(int i=(s);i<(t);i++)

#define rrp(i,t,s) for(int i=(t);i>=(s);i--)

#define rcp(i,s,b,d) for(int i=(s);b;d)

#define mst(a,x) memset(a,x,sizeof(a))

#define INF 0x3f3f3f3f

#define N 200002



#define Dp puts("")

#define Dw printf

#define Ds printf("#")



typedef long long ll;

bool b[N],d[N];

char ch;

int n,m,x,y;



inline void read(int &x){x=0;do{ch=getchar();}while(ch<'0'||'9'<ch);do{x=x*10+ch-'0';ch=getchar();}while('0'<=ch&&ch<='9');}



int main(void)

{

	read(n),read(m);

	rep(i,1,m)

	{

		read(x),read(y);

		if(x==1)b[y]=true;

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

	}

	rep(i,1,n)if(b[i]&&d[i])

	{

		printf("POSSIBLE");

		return 0;

	}

	printf("IMPOSSIBLE");

	return 0;

}


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

long a[200003],b[200003];

int main()



{

	long n,m,i,j=0,k=0,x,y,c,d,t1=0,t2=0,t;

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

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

	{

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

		if(x==1)

		{

			a[y]=1;

			t1=(y>t2)?y:t1;

		}

		if(y==n)

		{

			b[x]=1;

			t2=(x>t2)?x:t2;

		}

	}

	t=(t1>t2)?t1:t2;

	int flag=0;

	for(i=0;i<=t;i++)

	{

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

		flag=1;break;}

	}

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

	else printf("IMPOSSIBLE\n");

	return 0;

}

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

#include<cstdio>

#include<vector>

#include<map>

#include<set>

#include<queue>

#include<cmath>

#include<string>

#include<cstring>

#include<algorithm>

using namespace std;

typedef long long LL;

const LL INF=1e18;

const int MAXN=2e5+100;

const double eps=1e-10;

bool vis[MAXN];



int main()

{

    int n,m;

    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");

    }

    return 0;

}

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

long a[200003],b[200003];

int main()



{

	long n,m,i,j=0,k=0,x,y,c,d,t1=0,t2=0,t;

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

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

	{

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

		if(x==1)

		{

			a[y]=1;

			t1=(y>t2)?y:t1;

		}

		if(y==n)

		{

			b[x]=1;

			t2=(x>t2)?x:t2;

		}

	}

	t=(t1>t2)?t1:t2;

	int flag=0;

	for(i=0;i<=t;i++)

	{

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

		flag=1;break;}

	}

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

	else printf("IMPOSSIBLE\n");

	return 0;

}

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

using namespace std;

#define int long long

typedef pair<int, int> ii;

typedef vector<int> vi;

typedef vector<ii> vii;

#define pb push_back

#define ld long double

#define f first

#define s second

#define in insert

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

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

#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int INF = 1e18 + 5;

const int mod = 1e9 + 7;

const int  N = 2e5 + 314;

const long double pi = 3.1415926535897932384626433832795;

multiset<int>ms[N];

void solve(){

	int n, m;

	cin>>n>>m;

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

		int x, y;

		cin>>x>>y;

		ms[x].in(y);

	}

	for(auto i:ms[1]){

		auto it = *ms[i].lower_bound(n);

		if(it==n){

			cout<<"POSSIBLE";

			return;

		}

	}

	cout<<"IMPOSSIBLE";

}

signed main(){

	speed;

	int t=1;

	//cin>>t;

	while(t--)solve();

}

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

using namespace std;



int main()

{

    long int n, m;

    cin >> n >> m;

    long int a, b, chk = 0;

    vector<long int>cnct_a;

    vector<long int>cnct_b;

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

        cin >> a >> b;

        if(a == 1 && b == n){

            chk = 1;

            break;

        }

        else{

            if(a == 1)

                cnct_a.push_back(b);

            if( b == n)

                cnct_b.push_back(a);

        }

    }

    sort(cnct_a.begin(), cnct_a.end());

    sort(cnct_b.begin(), cnct_b.end());



    if(chk == 0){

        if(cnct_a.size() == 0 || cnct_b.size() == 0)

            chk = 0;

        else{

            vector<long int>v(cnct_a.size() + cnct_b.size());

            vector<long int>::iterator it, st;

            it = set_intersection(cnct_a.begin(), cnct_a.end(), cnct_b.begin(), cnct_b.end(), v.begin());



            for (st = v.begin(); st != it; ++st){

                chk = 1;

                break;

            }

        }

    }

    if(chk == 0)

        cout << "IMPOSSIBLE";

    else if(chk == 1)

        cout << "POSSIBLE";



    return 0;

}


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

using namespace std;

long long vis[200005],dis[200005];

vector<long long>adj[200005];

void bfs(long long node)

{

    queue<long long>q;

    q.push(node);

    vis[node]=1;

    dis[node]=0;

    while(!q.empty())

    {

        long long c=q.front();

        q.pop();

        for(auto j:adj[c])

        {

            if(!vis[j])

            {

                q.push(j);

                dis[j]=dis[c]+1;

                vis[j]=1;

            }

        }

    }

}

int main()

{

    long long T,i,j,n,m,a,b;



        cin>>n>>m;

        for(j=0;j<m;j++)

        {

            cin>>a>>b;

            adj[a].push_back(b);

            adj[b].push_back(a);

        }

        bfs(1);

        if(dis[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()

{

    long int n, m;

    cin >> n >> m;

    long int a, b, chk = 0;

    vector<long int>cnct_a;

    vector<long int>cnct_b;

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

        cin >> a >> b;

        if(a == 1 && b == n){

            chk = 1;

            break;

        }

        else{

            if(a == 1)

                cnct_a.push_back(b);

            if( b == n)

                cnct_b.push_back(a);

        }

    }

    sort(cnct_a.begin(), cnct_a.end());

    sort(cnct_b.begin(), cnct_b.end());



    if(chk == 0){

        if(cnct_a.size() == 0 || cnct_b.size() == 0)

            chk = 0;

        else{

            vector<long int>v(cnct_a.size() + cnct_b.size());

            vector<long int>::iterator it, st;

            it = set_intersection(cnct_a.begin(), cnct_a.end(), cnct_b.begin(), cnct_b.end(), v.begin());



            for (st = v.begin(); st != it; ++st){

                chk = 1;

                break;

            }

        }

    }

    if(chk == 0)

        cout << "IMPOSSIBLE";

    else if(chk == 1)

        cout << "POSSIBLE";



    return 0;

}


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

using namespace std;

typedef long long ll;

#define test int t; cin>>t; while(t--)

vector<int>arr[200001];

int vis[200001],di[200001];

void bfs(int root)

{



    queue<int> que;





    que.push(root);





    di[root] = 0;





    vis[root] = 1;





    while (!que.empty()) {





       root = que.front();

       que.pop();

        for (int i = 0; i < arr[root].size(); i++) {



            int b = arr[root][i];



            if (!vis[b]) {





                que.push(b);





                di[b] = di[root] + 1;





                vis[b] = 1;

            }

        }

    }

}















int main()

{

    int n,m,a,b;

    cin>>n>>m;

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

    {

        cin>>a>>b;

        arr[a].push_back(b);

        arr[b].push_back(a);



    }

    bfs(1);

    if(di[n]>2 || di[n]==0)

    {

        cout<<"IMPOSSIBLE"<<endl;

    }

    else cout<<"POSSIBLE"<<endl;



}


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

using namespace std;



#define LL long long

LL n,m, minx=1e9, maxx=0, miny=1e9, maxy=0;

int a,b;

bool valid=false;

bool connect1[300001];

bool connectn[300001];



int main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    cout.tie(0);

    

    cin>>n>>m;

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

        cin>>a>>b;

        if(a==1){

            connect1[b]=true;

        }

        if(b==n){

            connectn[a]=true;

        }

    }

    

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

        if(connect1[i] && connectn[i]){

            valid=true;

        }

    }

    if(valid){

        cout<<"POSSIBLE"<<endl;

    }else{

        cout<<"IMPOSSIBLE"<<endl;

    }

}


// Fastest known solution for this problem: