stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<cstdio>

#include<queue>

#include<vector>

#include<algorithm>

#include<cstring>

#define pa pair<int,int>

#define mp make_pair

using namespace std;

inline int read(){int x=0,f=1; char ch=getchar(); 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;}

const int maxn=200005;

struct edge{

	int link,next;

}e[maxn];

int head[maxn],tot,m,n; 

inline void insert(int u,int v){

	e[++tot]=(edge){v,head[u]};

	head[u]=tot;

}

inline void init(){

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

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

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

		insert(u,v);

	}

}

int dis[maxn];

bool vis[maxn];

priority_queue<pa, vector<pa>, greater<pa> > heap; 

inline void solve(){

	memset(dis,127/3,sizeof(dis));

	dis[1]=0; heap.push(mp(0,1));

	while (!heap.empty()){

		int u=heap.top().second; heap.pop();

		if (vis[u]) continue;

		vis[u]=1;

		for (int i=head[u];i;i=e[i].next){

			int v=e[i].link;

			if (dis[v]>dis[u]+1){

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

				if (!vis[v]){

					heap.push(mp(dis[v],v));

				}

			}

		}

	}

	if (dis[n]==2) puts("POSSIBLE");

		else puts("IMPOSSIBLE");

}

int main(){

	init();

	solve();

	return 0;

} 

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

}
// Slower C++ solution:
///Bismillahir Rahmanir Rahim

#include "bits/stdc++.h"



#define                           ll                          long long

#define                           int                         ll

#define                           fi                          first

#define                           si                          second

#define                           mp                          make_pair

#define                           pb                          push_back

#define                           pi                          pair<ll,ll>

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

#define                           f(i,l,r)                    for(int i=l;i<=r;i++)

#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)

#define                           done(i)                     cout<<"done = "<<i<<endl;

#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;

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



using namespace std;



const ll inf=1e18;

const int mod=1e9+7;

const int M=200005;

vector<int>adj[M];

 main()



{

    fast

    int n,m;

    cin>>n>>m;

    f(i,1,m)

    {

       int u,v;

       cin>>u>>v;

       adj[u].pb(v);

       adj[v].pb(u);

    }

    for(auto x:adj[1])

    {

        if(x!=n)

        {

            for(auto y:adj[x])

            {

                if(y==n)

                {

                    cout<<"POSSIBLE"<<endl;

                    return 0;

                }

            }

        }

    }

    cout<<"IMPOSSIBLE"<<endl;

    return 0;



}








































































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

}
// Slower C++ solution:


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

}


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

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

}




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

}
// Slower C++ solution:




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

}




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

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

}

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

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

}


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

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

}

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

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

}

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

int a[300000],b[300000];

int main()

{

	int i,f,a1,b1,n,k;

	f=0;

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

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

	{

		scanf("%d%d",&a1,&b1);

		if(a1==1)

			a[b1]=1;

		if(b1==k)

			b[a1]=1;



	}

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

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

			f=1;

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

	else printf("IMPOSSIBLE\n");

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

}


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

int a[300000],b[300000];

int main()

{

	int i,f,a1,b1,n,k;

	f=0;

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

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

	{

		scanf("%d%d",&a1,&b1);

		if(a1==1)

			a[b1]=1;

		if(b1==k)

			b[a1]=1;



	}

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

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

			f=1;

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

	else printf("IMPOSSIBLE\n");

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

}

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

int a[300000],b[300000];

int main()

{

	int i,f,a1,b1,n,k;

	f=0;

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

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

	{

		scanf("%d%d",&a1,&b1);

		if(a1==1)

			a[b1]=1;

		if(b1==k)

			b[a1]=1;



	}

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

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

			f=1;

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

	else printf("IMPOSSIBLE\n");

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

}

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



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

}

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

}