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

#include <vector>

#include <algorithm>

#include <cmath>

#include <numeric>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <time.h>

#include <list>

#include <bitset>

#include <iostream>



using namespace std;

typedef long long ll;

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

#define INF 2147483600

const int V=200010;

using P=pair<int,int>;

vector<P> G[V];

int dist[V];

bool used[V];

void dijkstra(int s){

  fill_n(dist,V,INF);

  fill_n(used,V,false);

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

  q.push(P(0,s));

  while(!q.empty()){

    int d; int t;

    tie(d,t)=q.top();q.pop();

    if(used[t])continue;

    used[t]=true;dist[t]=d;

    for(P e: G[t]){

      if(dist[e.second]<=d+e.first)continue;

      q.push(P(d+e.first,e.second));

    }

  }

}



inline ll read(){

  ll ans=0,c=getchar_unlocked();

  while(c<'0'||c>'9')c=getchar_unlocked();

  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}

  return ans;

}

int main(){

  ll n,m,a,b;

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

  rep(i,m){

    a=read();b=read();

    G[a].emplace_back(1,b);

    G[b].emplace_back(1,a);

  }

  dijkstra(1);

  if(dist[n]<=2){

    printf("POSSIBLE\n");

  }else{

    printf("IMPOSSIBLE\n");

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 40.774578061766555x):
#include<cstdio>

#include<vector>

#include<algorithm>

using namespace std;

inline char tc(void){

	static char fl[10000],*A=fl,*B=fl;

	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;	

}

inline int read(void){

	int a=0;static char c;

	while((c=tc())<'0'||c>'9');

	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();

	return a;

}

int n,m,o[200001],w[200001];

int main(void){

	register int i,x,y;

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

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

		x=read(),y=read(),x==1?o[y]=1:0,y==n?w[x]=1:0;

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

		if(o[i]&&w[i]){

			puts("POSSIBLE");

			return 0;

		}

	puts("IMPOSSIBLE");

	return 0;

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

#include <map>

inline int read(){

  int ans=0,c=getchar_unlocked();

  while(c<'0'||c>'9')c=getchar_unlocked();

  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}

  return ans;

}

int main(){

  int n,m,a,b;n=read();m=read();

  std::map<int,bool> mp;

  while(m--){a=read();b=read();

    if(a==1){

      if(mp[b]==true)return puts("POSSIBLE"),0;

      mp[b]=true;

    }

    if(b==n){

      if(mp[a]==true)return puts("POSSIBLE"),0;

      mp[a]=true;

    }

  }

  puts("IMPOSSIBLE");

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.953791545756874x):
#include<cstdio>

#include<vector>

#include<algorithm>

using namespace std;

inline char tc(void){

	static char fl[10000],*A=fl,*B=fl;

	return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;	

}

inline int read(void){

	int a=0;static char c;

	while((c=tc())<'0'||c>'9');

	while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();

	return a;

}

int n,m,o[200001],w[200001];

int main(void){

	register int i,x,y;

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

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

		x=read(),y=read(),x==1?o[y]=1:0,y==n?w[x]=1:0;

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

		if(o[i]&&w[i]){

			puts("POSSIBLE");

			return 0;

		}

	puts("IMPOSSIBLE");

	return 0;

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

#include <vector>

#include <algorithm>

#include <cmath>

#include <numeric>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <time.h>

#include <list>

#include <bitset>

#include <iostream>



using namespace std;

typedef long long ll;

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

#define INF 2147483600

const int V=200010;

using P=pair<int,int>;

vector<P> G[V];

int dist[V];

bool used[V];

void dijkstra(int s){

  fill_n(dist,V,INF);

  fill_n(used,V,false);

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

  q.push(P(0,s));

  while(!q.empty()){

    int d; int t;

    tie(d,t)=q.top();q.pop();

    if(used[t])continue;

    used[t]=true;dist[t]=d;

    for(P e: G[t]){

      if(dist[e.second]<=d+e.first)continue;

      q.push(P(d+e.first,e.second));

    }

  }

}



inline ll read(){

  ll ans=0,c=getchar_unlocked();

  while(c<'0'||c>'9')c=getchar_unlocked();

  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}

  return ans;

}

int main(){

  ll n,m,a,b;

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

  rep(i,m){

    a=read();b=read();

    G[a].emplace_back(1,b);

    G[b].emplace_back(1,a);

  }

  dijkstra(1);

  if(dist[n]<=2){

    printf("POSSIBLE\n");

  }else{

    printf("IMPOSSIBLE\n");

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 40.829738376204965x):
#include <cstdio>

bool A[200001];

inline char tc(void){

  static char fl[10000],*A=fl,*B=fl;

  return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;  

}

inline int read(void){

  int a=0;static char c;

  while((c=tc())<'0'||c>'9');

  while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();

  return a;

}

int main(){

  int n,m,a,b;n=read();m=read();

  while(m--){a=read();b=read();

    if(a==1){

      if(A[b]==true)return puts("POSSIBLE"),0;

      A[b]=true;

    }

    if(b==n){

      if(A[a]==true)return puts("POSSIBLE"),0;

      A[a]=true;

    }

  }

  puts("IMPOSSIBLE");

  return 0;

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

#include <map>

inline int read(){

  int ans=0,c=getchar_unlocked();

  while(c<'0'||c>'9')c=getchar_unlocked();

  while(c>='0'&&c<='9'){ans=ans*10+(c-'0'); c=getchar_unlocked();}

  return ans;

}

int main(){

  int n,m,a,b;n=read();m=read();

  std::map<int,bool> mp;

  while(m--){a=read();b=read();

    if(a==1){

      if(mp[b]==true)return puts("POSSIBLE"),0;

      mp[b]=true;

    }

    if(b==n){

      if(mp[a]==true)return puts("POSSIBLE"),0;

      mp[a]=true;

    }

  }

  puts("IMPOSSIBLE");

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 4.9604930914825545x):
#include <cstdio>

bool A[200001];

inline char tc(void){

  static char fl[10000],*A=fl,*B=fl;

  return A==B&&(B=(A=fl)+fread(fl,1,10000,stdin),A==B)?EOF:*A++;  

}

inline int read(void){

  int a=0;static char c;

  while((c=tc())<'0'||c>'9');

  while(c>='0'&&c<='9')a=a*10+c-'0',c=tc();

  return a;

}

int main(){

  int n,m,a,b;n=read();m=read();

  while(m--){a=read();b=read();

    if(a==1){

      if(A[b]==true)return puts("POSSIBLE"),0;

      A[b]=true;

    }

    if(b==n){

      if(A[a]==true)return puts("POSSIBLE"),0;

      A[a]=true;

    }

  }

  puts("IMPOSSIBLE");

  return 0;

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

using namespace std;

/* typedef */

typedef long long ll;

typedef pair<int, int> pii;

/* constant */

const int INF = 1 << 30;

const ll LINF = 1LL << 50;

const int NIL = -1;

const int MAX = 200005;

const int mod = 1000000007;

const double pi = 3.141592653589;

/* global variables */

vector<vector<int> > G(MAX, vector<int>());

int N, M;

/* function */

void bfs() {

    vector<int> visited(MAX, -1);



    visited[0] = 0;

    queue<int> q;

    q.push(0);

    while (!q.empty()) {

        int from = q.front();

        q.pop();

        if (visited[from] >= 2) continue;

        for (int to : G[from]) {

            if (visited[to] != NIL) continue;

            visited[to] = visited[from] + 1;

            q.push(to);

        }

    }



    cout << ((visited[N-1] == 1 || visited[N-1] == 2) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';

}

/* main */

int main(){

    cin >> N >> M;

    int a, b;

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

        cin >> a >> b;

        a--, b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }



    bfs();

}


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

using namespace std;

/* typedef */

typedef long long ll;

typedef pair<int, int> pii;

/* constant */

const int INF = 1 << 30;

const ll LINF = 1LL << 50;

const int NIL = -1;

const int MAX = 200005;

const int mod = 1000000007;

const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */

int main(){

    int N, M;

    cin >> N >> M;

    int a, b;

    vector<bool> fromOne(N+1), fromN(N+1);

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

        cin >> a >> b;

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

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

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

    }



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

        if (fromOne[i] && fromN[i]) {

            cout << "POSSIBLE" << '\n';

            return 0;

        }

    }

    cout << "IMPOSSIBLE" << '\n';

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

using namespace std;

/* typedef */

typedef long long ll;

typedef pair<int, int> pii;

/* constant */

const int INF = 1 << 30;

const ll LINF = 1LL << 50;

const int NIL = -1;

const int MAX = 200005;

const int mod = 1000000007;

const double pi = 3.141592653589;

/* global variables */

vector<vector<int> > G(MAX, vector<int>());

int N, M;

/* function */

void bfs() {

    vector<int> visited(MAX, -1);



    visited[0] = 0;

    queue<int> q;

    q.push(0);

    while (!q.empty()) {

        int from = q.front();

        q.pop();

        if (visited[from] >= 2) continue;

        for (int to : G[from]) {

            if (visited[to] != NIL) continue;

            visited[to] = visited[from] + 1;

            q.push(to);

        }

    }



    cout << ((visited[N-1] == 1 || visited[N-1] == 2) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';

}

/* main */

int main(){

    cin >> N >> M;

    int a, b;

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

        cin >> a >> b;

        a--, b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }



    bfs();

}


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

using namespace std;

/* typedef */

typedef long long ll;

typedef pair<int, int> pii;

/* constant */

const int INF = 1 << 30;

const ll LINF = 1LL << 50;

const int NIL = -1;

const int MAX = 10000;

const int mod = 1000000007;

const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */

int main(){

    int N, M;

    cin >> N >> M;

    vector<int> fromSt(N+1), toEnd(N+1);

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

        int a, b;

        cin >> a >> b;

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

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

        if (b == N) toEnd[a] = 1;

    }

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

        if (fromSt[i] && toEnd[i]) {

            cout << "POSSIBLE" << '\n';

            return 0;

        }

    }

    cout << "IMPOSSIBLE" << '\n';

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

}


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

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

}


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

}
// Slower C++ solution:
//关于划船问题，从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;

}

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

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

}

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

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

}

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

using namespace std;

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

#define ll unsigned long long

#define vi vector<int>

#define pii pair<int,int>

#define F first

#define S second

#define pb push_back

#define forn(b) for(int i = 0; i < b; i++)

#define rforn(b) for(int i = b - 1 ;i >= 0; i--)

#define It(m) for(auto it = m.begin(); it != m.end(); it++)

#define N 500500

#define PI 3.14159265358979323846264338327950L

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

    

const ll mod = (ll)1e9 + 7;

    

int main() {

	speed;

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

    map<int, bool> m1;

    map<int, bool> m2;

    vector<pii> v(m);

    bool yes = false;

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

        int l, r; cin >> l >> r;

        if(l == 1) {

            m1[r] = true;

        }

        if(r == n) {

            m2[l] = true;

        }

    }

    It(m1) {

        if(m2[it->first] == true) {

            yes = true;

        }

    }

    if(yes) {

        cout << "POSSIBLE";

    }

    else {

        cout << "IMPOSSIBLE";

    }

}
// 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.678837710894818x):
#include <bits/stdc++.h>

using namespace std;

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

#define ll unsigned long long

#define vi vector<int>

#define pii pair<int,int>

#define F first

#define S second

#define pb push_back

#define forn(b) for(int i = 0; i < b; i++)

#define rforn(b) for(int i = b - 1 ;i >= 0; i--)

#define It(m) for(auto it = m.begin(); it != m.end(); it++)

#define N 500500

#define PI 3.14159265358979323846264338327950L

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

    

const ll mod = (ll)1e9 + 7;

    

int main() {

	speed;

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

    map<int, bool> m1;

    map<int, bool> m2;

    vector<pii> v(m);

    bool yes = false;

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

        int l, r; cin >> l >> r;

        if(l == 1) {

            m1[r] = true;

        }

        if(r == n) {

            m2[l] = true;

        }

    }

    It(m1) {

        if(m2[it->first] == true) {

            yes = true;

        }

    }

    if(yes) {

        cout << "POSSIBLE";

    }

    else {

        cout << "IMPOSSIBLE";

    }

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

}

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

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

}

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

}