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

using namespace std;

queue<int>q;

int nedge=0,p[1000010],nex[1000010],head[1000010],rp[1000010];

int dist[200010],vis[200010],n,m,s,t,g,l;

inline void addedge(int x,int y){

	p[++nedge]=y;nex[nedge]=head[x];head[x]=nedge;

}

inline void spfa(){

	memset(dist,0x3f,sizeof dist);

	dist[1]=0;q.push(1);vis[1]=1;

	while(!q.empty()){

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

		for(int k=head[now];k;k=nex[k])if(dist[p[k]]>dist[now]+1){

			dist[p[k]]=dist[now]+1;

			if(!vis[p[k]]){vis[p[k]]=1;q.push(p[k]);}

		}vis[now]=0;

	}

}

int main()

{

	ios::sync_with_stdio(0);

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

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

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

		addedge(x,y);

	}

	spfa();

	if(dist[n]>2)puts("IMPOSSIBLE");

	else puts("POSSIBLE");

}

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

using namespace std;

typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;

#define INF 1<<30

#define LINF 1LL<<60



bool dfs(int u,int t,int dep,vector<vector<int>>& G){

    if(dep == 2)return false;

    for(auto next: G[u]){

        if(next == t)return true;

        if(dfs(next,t,dep+1,G)){

            return true;

        }

    }

    return false;

}

int main(void) {

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

    int N,M; cin >> N >> M;

    vector<vector<int>> G(N);

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

        int a,b; cin >> a >> b;

        a--; b--;

        G[a].push_back(b);

        G[b].push_back(a);

    }

    if(dfs(0,N-1,0,G)){

        cout << "POSSIBLE" << endl;

    }else{

        cout << "IMPOSSIBLE" << endl;

    }

    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.170429016704364x):
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define uint unsigned int

#define ull  unsigned long long

typedef string str;

typedef long long ll;

typedef double db;

typedef pair<int, int> pii;

typedef map<int, int> mii;

typedef vector<int> vi;

typedef vector<bool> vb;

#define pb push_back

#define fi first

#define se second

#define in insert

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

#define rall(x) (x).rbegin(), (x).rend()

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

const int INF = 1e9 + 5;

const int N = 2e5 + 1;

// int a[N][N];



// int a[1][N], b[N][1];

int main(){

    speed;

    int n, m;

    cin >> n >> m;

    map<int, mii > v;

    int ok = 0;

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

        int x, y;

        cin >> x >> y;

        v[x][y] = 1;

        if(x == 1 && v[y][n]){

            ok = 1;

        }

        if(y == n && v[1][x]){

            ok = 1;

        }

    }

    if(ok){

        cout << "POSSIBLE";

    }

    else{

        cout << "IMPOSSIBLE";

    }

}
// 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.358972971111122x):
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define uint unsigned int

#define ull  unsigned long long

typedef string str;

typedef long long ll;

typedef double db;

typedef pair<int, int> pii;

typedef map<int, int> mii;

typedef vector<int> vi;

typedef vector<bool> vb;

#define pb push_back

#define fi first

#define se second

#define in insert

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

#define rall(x) (x).rbegin(), (x).rend()

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

const int INF = 1e9 + 5;

const int N = 2e5 + 1;

// int a[N][N];



// int a[1][N], b[N][1];

int main(){

    speed;

    int n, m;

    cin >> n >> m;

    map<int, mii > v;

    int ok = 0;

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

        int x, y;

        cin >> x >> y;

        v[x][y] = 1;

        if(x == 1 && v[y][n]){

            ok = 1;

        }

        if(y == n && v[1][x]){

            ok = 1;

        }

    }

    if(ok){

        cout << "POSSIBLE";

    }

    else{

        cout << "IMPOSSIBLE";

    }

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

using namespace std;

queue<int>q;

int nedge=0,p[1000010],nex[1000010],head[1000010],rp[1000010];

int dist[200010],vis[200010],n,m,s,t,g,l;

inline void addedge(int x,int y){

	p[++nedge]=y;nex[nedge]=head[x];head[x]=nedge;

}

inline void spfa(){

	memset(dist,0x3f,sizeof dist);

	dist[1]=0;q.push(1);vis[1]=1;

	while(!q.empty()){

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

		for(int k=head[now];k;k=nex[k])if(dist[p[k]]>dist[now]+1){

			dist[p[k]]=dist[now]+1;

			if(!vis[p[k]]){vis[p[k]]=1;q.push(p[k]);}

		}vis[now]=0;

	}

}

int main()

{

	ios::sync_with_stdio(0);

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

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

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

		addedge(x,y);

	}

	spfa();

	if(dist[n]>2)puts("IMPOSSIBLE");

	else puts("POSSIBLE");

}

// Faster C++ solution for the same problem (measured speedup: 1.7772873573776014x):
// #define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

using namespace std;

#define uint unsigned int

#define ull  unsigned long long

typedef string str;

typedef long long ll;

typedef double db;

typedef pair<int, int> pii;

typedef map<int, int> mii;

typedef vector<int> vi;

typedef vector<bool> vb;

#define pb push_back

#define fi first

#define se second

#define in insert

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

#define rall(x) (x).rbegin(), (x).rend()

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

const int INF = 1e9 + 5;

const int N = 2e5 + 1;

// int a[N][N];



// int a[1][N], b[N][1];

int main(){

    speed;

    int n, m;

    cin >> n >> m;

    map<int, mii > v;

    int ok = 0;

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

        int x, y;

        cin >> x >> y;

        v[x][y] = 1;

        if(x == 1 && v[y][n]){

            ok = 1;

        }

        if(y == n && v[1][x]){

            ok = 1;

        }

    }

    if(ok){

        cout << "POSSIBLE";

    }

    else{

        cout << "IMPOSSIBLE";

    }

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

#define ll long long

#define ull unsigned long long

#define pii pair<int,int>

#define piii pair<int,pii>

#define pll pair<ll,ll>

#define plii pair<ll,pii>

#define vi vector<int>

#define ff first

#define ss second

#define mp make_pair

#define pb push_back

#define SORT(x) sort(x.begin(), x.end())

#define GSORT(x) sort(x.begin(), x.end(), greater<int>())

#define mx 100001

#define eps 0.00000000001

#define mod 1000000007

#define pi acos(-1)

#define inf 100000000

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

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

using namespace std;

int main()

{

    fio;

    int n,m,x,y;

    cin>>n>>m;

    int a1[n+1]={0};

	int a2[n+1]={0};

	bool chk=false;

	loop(i,0,m){

		cin>>x>>y;

		if(x==1) a1[y]=1;

		if(y==n) a2[x]=1;

		if(a1[x] && a2[x])

            chk = true;

		if(a1[y] && a2[y])

		 chk =true;

	}

    if(chk)

    cout<<"POSSIBLE";

	else

	cout<<"IMPOSSIBLE";

    return 0;

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

#define ll long long

#define ull unsigned long long

#define pii pair<int,int>

#define piii pair<int,pii>

#define pll pair<ll,ll>

#define plii pair<ll,pii>

#define vi vector<int>

#define ff first

#define ss second

#define mp make_pair

#define pb push_back

#define SORT(x) sort(x.begin(), x.end())

#define GSORT(x) sort(x.begin(), x.end(), greater<int>())

#define mx 100001

#define eps 0.00000000001

#define mod 1000000007

#define pi acos(-1)

#define inf 100000000

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

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

using namespace std;

int main()

{

    fio;

    int n,m,x,y;

    cin>>n>>m;

    int a1[n+1]={0};

	int a2[n+1]={0};

	bool chk=false;

	loop(i,0,m){

		cin>>x>>y;

		if(x==1) a1[y]=1;

		if(y==n) a2[x]=1;

		if(a1[x] && a2[x])

            chk = true;

		if(a1[y] && a2[y])

		 chk =true;

	}

    if(chk)

    cout<<"POSSIBLE";

	else

	cout<<"IMPOSSIBLE";

    return 0;

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

using namespace std;

queue<int>q;

int nedge=0,p[1000010],nex[1000010],head[1000010],rp[1000010];

int dist[200010],vis[200010],n,m,s,t,g,l;

inline void addedge(int x,int y){

	p[++nedge]=y;nex[nedge]=head[x];head[x]=nedge;

}

inline void spfa(){

	memset(dist,0x3f,sizeof dist);

	dist[1]=0;q.push(1);vis[1]=1;

	while(!q.empty()){

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

		for(int k=head[now];k;k=nex[k])if(dist[p[k]]>dist[now]+1){

			dist[p[k]]=dist[now]+1;

			if(!vis[p[k]]){vis[p[k]]=1;q.push(p[k]);}

		}vis[now]=0;

	}

}

int main()

{

	ios::sync_with_stdio(0);

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

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

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

		addedge(x,y);

	}

	spfa();

	if(dist[n]>2)puts("IMPOSSIBLE");

	else puts("POSSIBLE");

}

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

#define ll long long

#define ull unsigned long long

#define pii pair<int,int>

#define piii pair<int,pii>

#define pll pair<ll,ll>

#define plii pair<ll,pii>

#define vi vector<int>

#define ff first

#define ss second

#define mp make_pair

#define pb push_back

#define SORT(x) sort(x.begin(), x.end())

#define GSORT(x) sort(x.begin(), x.end(), greater<int>())

#define mx 100001

#define eps 0.00000000001

#define mod 1000000007

#define pi acos(-1)

#define inf 100000000

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

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

using namespace std;

int main()

{

    fio;

    int n,m,x,y;

    cin>>n>>m;

    int a1[n+1]={0};

	int a2[n+1]={0};

	bool chk=false;

	loop(i,0,m){

		cin>>x>>y;

		if(x==1) a1[y]=1;

		if(y==n) a2[x]=1;

		if(a1[x] && a2[x])

            chk = true;

		if(a1[y] && a2[y])

		 chk =true;

	}

    if(chk)

    cout<<"POSSIBLE";

	else

	cout<<"IMPOSSIBLE";

    return 0;

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

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

#define fr first

#define sc second

#define N 300009

#define inf 2e16

#define pi pair<ll,ll>

#define pb push_back

using namespace std;

typedef long long ll;

void slv()

{

}

vector<int>adj[N];

bool vis[N];

int dis[N];

void vfs(int s)

{

    queue<int>q;

    q.push(s);

    dis[s]=0;

    vis[s]=1;

    while (!q.empty())

    {

        int u=q.front();

        q.pop();

        for(auto v : adj[u])

        {

            if(!vis[v])

            {

                vis[v]=1;

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

                q.push(v);

            }

        }

    }

    

}

int main()

{

    int n,m;

    cin>>n>>m;

    while(m--)

    {

        int u,v;

        cin>>u>>v;

        adj[u].push_back(v);

        adj[v].push_back(u);

    }

    vfs(1);

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

    else puts("IMPOSSIBLE");

    return 0;

}


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

#define ll long long

#define ull unsigned long long

#define pii pair<int,int>

#define piii pair<int,pii>

#define pll pair<ll,ll>

#define plii pair<ll,pii>

#define vi vector<int>

#define ff first

#define ss second

#define mp make_pair

#define pb push_back

#define SORT(x) sort(x.begin(), x.end())

#define GSORT(x) sort(x.begin(), x.end(), greater<int>())

#define mx 100001

#define eps 0.00000000001

#define mod 1000000007

#define pi acos(-1)

#define inf 100000000

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

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

using namespace std;

int main()

{

    fio;

    int n,m,x,y;

    cin>>n>>m;

    int a1[n+1]={0};

	int a2[n+1]={0};

	bool chk=false;

	loop(i,0,m){

		cin>>x>>y;

		if(x==1) a1[y]=1;

		if(y==n) a2[x]=1;

		if(a1[x] && a2[x])

            chk = true;

		if(a1[y] && a2[y])

		 chk =true;

	}

    if(chk)

    cout<<"POSSIBLE";

	else

	cout<<"IMPOSSIBLE";

    return 0;

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

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

#define fr first

#define sc second

#define N 300009

#define inf 2e16

#define pi pair<ll,ll>

#define pb push_back

using namespace std;

typedef long long ll;

void slv()

{

}

vector<int>adj[N];

bool vis[N];

int dis[N];

void vfs(int s)

{

    queue<int>q;

    q.push(s);

    dis[s]=0;

    vis[s]=1;

    while (!q.empty())

    {

        int u=q.front();

        q.pop();

        for(auto v : adj[u])

        {

            if(!vis[v])

            {

                vis[v]=1;

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

                q.push(v);

            }

        }

    }

    

}

int main()

{

    int n,m;

    cin>>n>>m;

    while(m--)

    {

        int u,v;

        cin>>u>>v;

        adj[u].push_back(v);

        adj[v].push_back(u);

    }

    vfs(1);

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

    else puts("IMPOSSIBLE");

    return 0;

}


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

using namespace std;

const int mx = 2e5 + 9;



queue<int>q;

vector<int>adj[mx];

int vis[mx];

int dis[mx];



void bfs(int s){

dis[s] = 0;

vis[s] = 1;

q.push(s);

while(!q.empty()){

    int tmp = q.front();

    q.pop();

    for(auto u : adj[tmp]){

        if(vis[u] == 1) continue;

        vis[u] = 1;

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

        q.push(u);

    }

}

}



int main(){

int n , m;

cin>>n>>m;

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

    int u , v;

    cin>>u>>v;

    adj[u].push_back(v);

    adj[v].push_back(u);

}



bfs(1);



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

    cout<<dis[i]<<" ";

cout<<endl;*/

if(vis[n] && dis[n]==2){

    cout<<"POSSIBLE"<<endl;

}

else

cout<<"IMPOSSIBLE"<<endl;



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



using namespace std;

typedef long long ll;



vector<vector<int> > vec(200010, vector<int>());

int cnt[200010];



void s(int c, int to) {

  if (c > 2) {

    return;

  }

  cnt[to] = c;

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

    s(c + 1, vec[to][i]);

  }

}



int main() {

  int N, M;

  cin >> N >> M;



  int a, b;

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

    cin >> a >> b;

    vec[a].push_back(b);

  }



  s(0, 1);



  if (cnt[N] == 2) {

    cout << "POSSIBLE" << endl;

  } else {

    cout << "IMPOSSIBLE" << endl;

  }

  return 0;

}

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



using namespace std;

typedef long long ll;



int main() {

  int N, M;

  cin >> N >> M;



  bool from1[200000] = {}, to2[200000] = {};



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

    int a, b;

    cin >> a >> b;

    if (a == 1) {

      from1[b] = true;

    }

    if (b == N) {

      to2[a] = true;

    }

  }



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

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

      cout << "POSSIBLE" << endl;

      return 0;

    }

  }

  cout << "IMPOSSIBLE" << endl;

  return 0;

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



using namespace std;

typedef long long ll;



vector<vector<int> > vec(200010, vector<int>());

int cnt[200010];



void s(int c, int to) {

  if (c > 2) {

    return;

  }

  cnt[to] = c;

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

    s(c + 1, vec[to][i]);

  }

}



int main() {

  int N, M;

  cin >> N >> M;



  int a, b;

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

    cin >> a >> b;

    vec[a].push_back(b);

  }



  s(0, 1);



  if (cnt[N] == 2) {

    cout << "POSSIBLE" << endl;

  } else {

    cout << "IMPOSSIBLE" << endl;

  }

  return 0;

}

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



using namespace std;

typedef long long ll;



int main() {

  int N, M;

  cin >> N >> M;



  bool from1[200000] = {}, to2[200000] = {};



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

    int a, b;

    cin >> a >> b;

    if (a == 1) {

      from1[b] = true;

    }

    if (b == N) {

      to2[a] = true;

    }

  }



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

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

      cout << "POSSIBLE" << endl;

      return 0;

    }

  }

  cout << "IMPOSSIBLE" << endl;

  return 0;

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

using namespace std;



int s[200009];

int t[200009];



int main() {

    int n, m;

    cin >> n >> m;



    bool flag = false;

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

        int a, b;

        cin >> a >> b;

        if (a == 1) {

            s[b]++;

        }

        if (b == n) {

            t[a]++;

        }

    }



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

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

            flag = true;

        }

    }



    if (flag) {

        puts("POSSIBLE");

    } else {

        puts("IMPOSSIBLE");

    }



    return 0;

}

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

using namespace std;



int main() {

   int N, M;

   cin >> N >> M;

   map<int, int> mp;

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

      int a, b;

      cin >> a >> b;

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

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

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

   }



   for (auto x : mp) {

      if (x.second >= 2) {

         puts("POSSIBLE");

         return 0;

      }

   }



   puts("IMPOSSIBLE");



   return 0;

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

using namespace std;



#include <bits/stdc++.h>

using namespace std;



struct edge { int to, cost; };

typedef pair<int, int> P; // firstは最短距離、secondは頂点の番号



const int VV = 222222;

const int INF = 1e8;

int V, M;

vector<edge> G[VV];

int d[VV];



void dijkstra(int s) {

   // 最短距離firstが小さい順に取り出せるようにする

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

   fill(d, d + V, INF); // 距離全てをINFで初期化

   d[s] = 0; // スタート地点を0で初期化

   que.push(P(0, s)); // キューに初期位置のコスト、初期位置をpush



   while (que.size()) {

      P p = que.top(); que.pop(); // p: 今の{最短距離、頂点番号}

      int v = p.second; // 今の頂点番号

      if (d[v] < p.first) continue; // 今見ている頂点の歴代最小距離 < 今見ている頂点の最短距離

      for (int i = 0; i < G[v].size(); i++) { // 今の頂点に隣接する頂点を調べる

         edge e = G[v][i];

         if (d[e.to] > d[v] + e.cost) { // 遷移先の頂点の歴代最小距離 > 今の距離 + 遷移コスト

            d[e.to] = d[v] + e.cost; // 歴代最小距離の更新

            que.push(P(d[e.to], e.to)); // 更新した遷移先の頂点をキューに突っ込む

         }

      }

   }

}



int main() {

   cin >> V >> M;

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

      int a, b;

      cin >> a >> b;

      a--, b--;

      G[a].push_back({b, 1});

      G[b].push_back({a, 1});

   }



   dijkstra(0);



   if (d[V-1] == 2) {

      puts("POSSIBLE");

   } else {

      puts("IMPOSSIBLE");

   }



   return 0;

}


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

using namespace std;



int main() {

   int N, M;

   cin >> N >> M;

   map<int, int> mp;

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

      int a, b;

      cin >> a >> b;

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

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

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

   }



   for (auto x : mp) {

      if (x.second >= 2) {

         puts("POSSIBLE");

         return 0;

      }

   }



   puts("IMPOSSIBLE");



   return 0;

}