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



using namespace std;



int main() {

  //cin.tie(0);

  //ios::sync_with_stdio(false);



  int n, m;

  bool s[200001] = {false};

  bool e[200001] = {false};

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



  int cnt = 0;

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

    int a, b;

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

    if (a == 1) {

      s[b] = true;

      cnt++;

    }

    else if (b == n) {

      e[a] = true;

    }

  }



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

    if (s[i] == true && e[i] == true) {

      printf("POSSIBLE\n");

      return 0;

    }

  }





  printf("IMPOSSIBLE\n");



  return 0;

}


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

using namespace std;



#define INF 0x3f3f3f3f



typedef long long ll;

typedef pair<int, int> P;



int n, m;

int to[200010], from[200010];



int main(){

	cin.tie(0);

  ios::sync_with_stdio(false);



	cin >> n >> m;

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

		int a, b;

		cin >> a >> b;

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

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

	}



	if (to[n] == 1) {

		cout << "POSSIBLE" << endl;

		return 0;

	}



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

		if (to[i] == 1 && from[i] == 1) {

			cout << "POSSIBLE" << endl;

			return 0;

		}

	}



	cout << "IMPOSSIBLE" << endl;



	return 0;

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

using namespace std;



int main(){

  int n,m;

  cin >> n >> m;

  int c[200001]={},d[200001]={};

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

    int a,b;

    cin >> a >> b;

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

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

  }

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

    if(c[i]&&d[i]) {

      cout << "POSSIBLE" << endl;

      return 0;

    }   

  }

 cout << "IMPOSSIBLE" << endl;

}


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

using namespace std;

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



int main(){

    int n,m;

    cin >> n >> m;

    vector<vector<int>> g(n);

    rep(i,m){

        int a,b;

        cin >> a >> b;

        a--;b--;

        g[a].push_back(b);

    } 

    int now = 0,flag = 0;

    for(auto i:g[now]){

        for(auto j :g[i]){

            if(j==n-1) flag = 1;

        }

    }

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

    else cout << "IMPOSSIBLE" << endl;

    

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

#include<cstring>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

const int maxn=2e5;

int pre[maxn+5],last[maxn+5],other[maxn+5],vis[maxn+5],a[maxn+5],b[maxn+5];

int all=-1,n,m,flag=0,ans=0;



void build(int u,int v)

{

	pre[++all]=last[u];

	last[u]=all;

	other[all]=v;

}



 void dfs(int ds,int cnt)

 {



 	 if(cnt>2) return;

 	 if(ds==n&&cnt<=2) ans++;

 	 int dt,de;

 	 dt=last[ds];

 	 while(dt!=-1){

	 	 de=other[dt];

	 	 if(vis[de]==0)

		 {

		 	 vis[de]=1;

		 	 dfs(de,cnt+1);

		 }

		 dt=pre[dt];

	 }

 }



int main(){

	memset(last,-1,sizeof(last));

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

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

		scanf("%d %d",&a[i],&b[i]);

		build(a[i],b[i]);

	}

	dfs(1,0);

	if(ans!=0) printf("POSSIBLE\n");

	else printf("IMPOSSIBLE\n");

}


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

#include<cstring>

#include<cmath>

#include<iostream>

#include<algorithm>

using namespace std;

const int maxn=2e5;

int a[maxn+5],b[maxn+5],vis[maxn+5];



int main(){

	int n,m,flag=0;

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

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

		scanf("%d %d",&a[i],&b[i]);

	}

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

		if(a[i]==1) vis[b[i]]=1;

	}

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

		if(b[i]==n&&vis[a[i]]==1) 

		{

			flag=1;

			break;

		}

	}

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

	else printf("IMPOSSIBLE\n");

}
// Slower C++ solution:
//周♂雨扬是最强的！！！

//大佬祝您AK

//沈哲♂贝是最强的！！！

#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<fstream>

using namespace std;

int n,m;

int head[2000003],nxt[2000003],to[2000003],tot;

inline void add(int a,int b){

	to[++tot]=b;  nxt[tot]=head[a];  head[a]=tot;

}

bool yes=false;

void dfs(int x,int len){

	if(len>=3||yes){

		return;

	}

	if(x==n){

		yes=true;

		return;

	}

	for(int i=head[x];i;i=nxt[i]){

		dfs(to[i],len+1);

	}

}

int main(){

	cin>>n>>m;

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

		int a,b;

		cin>>a>>b;

		add(a,b);

	}

	dfs(1,0);

	if(yes){

		cout<<"POSSIBLE"<<endl;

	}else{

		cout<<"IMPOSSIBLE"<<endl;

	}

	return 0;

}

//沈♂哲贝是最强的！！！

//大佬祝您AK

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

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

int main()

{

    int n,m,vis[200001];

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

        break;

    }

    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: 30.489031478785577x):
#include<stdio.h>

int main()

{

    int n,m,vis[200001];

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

        break;

    }

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

  

using namespace std;

  

template<class T> void ckmin(T &a, T b) { a = min(a, b); }

template<class T> void ckmax(T &a, T b) { a = max(a, b); }

  

#define pb push_back

#define mp make_pair

#define cotu cout

#define itn int

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

#define F first

#define S second

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

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

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

#define repr(i,n) for(int i = n - 1; i >= 0; --i)

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

#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)

#define Repr(i, a, n) for(int i = (n); i >= (a); --i)

#define sp(x) fixed << setprecision(x)

#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 

  

#include <ext/pb_ds/assoc_container.hpp> 

#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 

  

typedef long long ll;

typedef pair<ll, ll> pll;

typedef pair<int, int> pii;

  

const int inf = int(1e9);

const int mod = inf + 7;

const int N = 1e6 + 555; // TL MB

const double PI = acos(-1.0);

void mul(ll &x, ll y){

	x *= y;

	if(x >= mod) x %= mod;

}

 

void add(ll &x, ll y){

	x += y;

	if(x >= mod) x -= mod;

	if(x < 0) x += mod;

}

ll bp(ll a, ll n){

	ll r = 1;

	while(n){

		if(n & 1) mul(r, a);

		mul(a, a);

		n >>= 1;

	}

 

}







void solve()

{

	int n, m;

	cin >> n >> m;

	bool good = 0;

	map<pii, bool> z;

	rep(i, m){

		int x, y;

		cin >> x >> y;

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

		if(x == 1 && z.count({y, n})) good = 1;

		if(y == n && z.count({1, x})) good = 1;

		z[{x, y}] = 1;

	}

	if(!good) cout << "IM";

	cout << "POSSIBLE";



}



 

int main()

{

	// freopen("crosses.in", "r", stdin);

	// freopen("crosses.out", "w", stdout);

    Red;

  	int T = 1;

  	// cin >> T;

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

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

using namespace std;

int main()

{

    long long m,n,i,j,x,y,z,a[300000],k=0,cnt=0,b[300000];

    cin>>n>>m;

    memset(a,0,sizeof(a));

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

    {

        cin>>x>>y;

        a[x]=y;

        if(x==1)

        {

            b[k]=y;

            k++;

        }

    }

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

    {

        if(a[b[i]]==n)

        {

            cnt=1;

            break;

        }

    }

    if(cnt==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





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

using namespace std;

vector<int> a[200500];

int main() {

	int n, m;

	cin >> n >> m;

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

		int u, v;

		cin >> u >> v;

		a[u].push_back(v);

		a[v].push_back(u);

	}

	bool ok = false;

	for (auto f : a[1]) {

		if (f == n) {

			ok = true;

		}

		for (auto ff : a[f]) {

			if (ff == n) {

				ok = true;

			}

		}

	}

	if (ok)

		cout << "POSSIBLE";

	else

		cout << "IMPOSSIBLE";

	return 0;

}

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

using namespace std;

int main()

{

    long long m,n,i,j,x,y,z,a[300000],k=0,cnt=0,b[300000];

    cin>>n>>m;

    memset(a,0,sizeof(a));

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

    {

        cin>>x>>y;

        a[x]=y;

        if(x==1)

        {

            b[k]=y;

            k++;

        }

    }

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

    {

        if(a[b[i]]==n)

        {

            cnt=1;

            break;

        }

    }

    if(cnt==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





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



using namespace std;



const int mx = 200000 + 9;



bitset <mx> mark;

int d[mx];

vector <int> adj[mx];



int main() {

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

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

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

        adj[a].push_back(b);

        adj[b].push_back(a);

    }



    mark[1] = 1;

    queue <int> q;

    q.push(1);



    while (!q.empty()) {

        auto u = q.front();

        q.pop();

        for (auto v : adj[u]) {

            if (mark[v]) continue;

            mark[v] = 1;

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

            q.push(v);

        }

    }



    if (d[n] == 2) cout << "POSSIBLE" << endl;

    else cout << "IMPOSSIBLE" << endl;

}


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

using namespace std;

int main()

{

    long long m,n,i,j,x,y,z,a[300000],k=0,cnt=0,b[300000];

    cin>>n>>m;

    memset(a,0,sizeof(a));

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

    {

        cin>>x>>y;

        a[x]=y;

        if(x==1)

        {

            b[k]=y;

            k++;

        }

    }

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

    {

        if(a[b[i]]==n)

        {

            cnt=1;

            break;

        }

    }

    if(cnt==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





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



using namespace std;



#define ll long long

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

#define endl '\n'

#define Endl '\n'

#define cont continue

#define gcd(a,b) __gcd(a,b)

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

#define pb push_back

#define mp make_pair

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



const ll inf=1e18;

const int mod=1e9+7;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

const int mxn = 2e5+10;

vector<int>adj[mxn];



	

	

int main(){

    fast;



    int tt = 1;

    //cin>>tt;

    for(int tc = 1; tc <= tt; tc++) {

        int n,m;

        cin>>n>>m;

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

			int x,y;

			cin>>x>>y;

			//adj[x].pb(y);

			adj[y].pb(x);

		}

		for(int x : adj[n]) {

			sort(adj[x].begin(),adj[x].end());

			if(binary_search(adj[x].begin(),adj[x].end(),1)) return cout<<"POSSIBLE\n",0;

		}

        cout<<"IMPOSSIBLE\n";

        

    }







return 0;

}


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

using namespace std;

int main()

{

    long long m,n,i,j,x,y,z,a[300000],k=0,cnt=0,b[300000];

    cin>>n>>m;

    memset(a,0,sizeof(a));

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

    {

        cin>>x>>y;

        a[x]=y;

        if(x==1)

        {

            b[k]=y;

            k++;

        }

    }

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

    {

        if(a[b[i]]==n)

        {

            cnt=1;

            break;

        }

    }

    if(cnt==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





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

using namespace std;



int main(){

    int n,m;

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

    vector<vector<int>> g(n);

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

        int a,b;

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

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

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

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

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

using namespace std;

vector<int> a[200500];

int main() {

	int n, m;

	cin >> n >> m;

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

		int u, v;

		cin >> u >> v;

		a[u].push_back(v);

		a[v].push_back(u);

	}

	bool ok = false;

	for (auto f : a[1]) {

		if (f == n) {

			ok = true;

		}

		for (auto ff : a[f]) {

			if (ff == n) {

				ok = true;

			}

		}

	}

	if (ok)

		cout << "POSSIBLE";

	else

		cout << "IMPOSSIBLE";

	return 0;

}

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

using namespace std;



int main(){

    int n,m;

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

    vector<vector<int>> g(n);

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

        int a,b;

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

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

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

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

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



using namespace std;



const int mx = 200000 + 9;



bitset <mx> mark;

int d[mx];

vector <int> adj[mx];



int main() {

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

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

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

        adj[a].push_back(b);

        adj[b].push_back(a);

    }



    mark[1] = 1;

    queue <int> q;

    q.push(1);



    while (!q.empty()) {

        auto u = q.front();

        q.pop();

        for (auto v : adj[u]) {

            if (mark[v]) continue;

            mark[v] = 1;

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

            q.push(v);

        }

    }



    if (d[n] == 2) cout << "POSSIBLE" << endl;

    else cout << "IMPOSSIBLE" << endl;

}


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

using namespace std;



int main(){

    int n,m;

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

    vector<vector<int>> g(n);

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

        int a,b;

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

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

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

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

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



using namespace std;



#define ll long long

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

#define endl '\n'

#define Endl '\n'

#define cont continue

#define gcd(a,b) __gcd(a,b)

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

#define pb push_back

#define mp make_pair

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



const ll inf=1e18;

const int mod=1e9+7;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

const int mxn = 2e5+10;

vector<int>adj[mxn];



	

	

int main(){

    fast;



    int tt = 1;

    //cin>>tt;

    for(int tc = 1; tc <= tt; tc++) {

        int n,m;

        cin>>n>>m;

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

			int x,y;

			cin>>x>>y;

			//adj[x].pb(y);

			adj[y].pb(x);

		}

		for(int x : adj[n]) {

			sort(adj[x].begin(),adj[x].end());

			if(binary_search(adj[x].begin(),adj[x].end(),1)) return cout<<"POSSIBLE\n",0;

		}

        cout<<"IMPOSSIBLE\n";

        

    }







return 0;

}


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

using namespace std;



int main(){

    int n,m;

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

    vector<vector<int>> g(n);

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

        int a,b;

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

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

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

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

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

using namespace std;

int main()

{

    long long m,n,i,j,x,y,z,a[300000],k=0,cnt=0,b[300000];

    cin>>n>>m;

    memset(a,0,sizeof(a));

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

    {

        cin>>x>>y;

        a[x]=y;

        if(x==1)

        {

            b[k]=y;

            k++;

        }

    }

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

    {

        if(a[b[i]]==n)

        {

            cnt=1;

            break;

        }

    }

    if(cnt==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;





}


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

using namespace std;



int main(){

    int n,m;

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

    vector<vector<int>> g(n);

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

        int a,b;

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

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

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

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

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

using namespace std;

#define lli long long int

#define pii pair<int,int>

#define pll pair<lli,lli>

#define vi  vector<int>

#define vii vector<pair<int,int>>

#define vll vector<lli>

#define pb  push_back

#define mp  make_pair

#define ss  second

#define ff  first

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

const lli mod = 1e9+7;

//#ifndef ONLINE_JUDGE

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

//    freopen("output.txt", "w", stdout);

//    #endif

lli p2(lli n){lli ans=0;while(n>=1){n=n/2;ans++;}return ans;}

lli b_ex(lli n,lli a){lli res=1;while(n){if(n%2==1)res*=a;n>>=1;a=a*a;}return res;}

lli ncr(lli n,lli k){lli ans=1;if(k>n-k)k=n-k;for(lli i=1;i<=k;i++){ans*=(n-i+1),ans=ans/i;}return ans;}

lli add(lli a,lli b){return(a+b)%mod;}

lli mul(lli a,lli b){return (a*b)%mod;}

lli power(lli a , lli n){lli ans = 1;while(n){if(n % 2)ans = (ans * a) % mod;n /= 2;a = (a * a) % mod;}return ans;}

lli lcm(lli a,lli b)

{

    lli ans=(a*b)/(__gcd(a,b));

    return ans;

}

int n,m;

vi adj[200001];

int vis[200001];

bool f;

void dfs(int curr,int c=0)

{

    vis[curr]=1;

    if(curr==n){f=true;return;}

    if(c==2)return;

    for(int i:adj[curr])

    {

        if(vis[i]==0)dfs(i,c+1);

    }



}

int main()

{

    cin>>n>>m;

    while(m--)

    {

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

        adj[a].pb(b);

        adj[b].pb(a);

    }

    dfs(1);

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

    else cout<<"IMPOSSIBLE\n";

}








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

using namespace std;



int main(){

    int n,m;

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

    vector<vector<int>> g(n);

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

        int a,b;

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

        --a,--b;

        g[a].push_back(b);

        g[b].push_back(a);

    }

    int dist[n];

    memset(dist,-1,sizeof(dist));

    queue<int> q;

    q.push(0);

    dist[0] = 0;

    while(q.size()){

        int dad = q.front();

        q.pop();

        for(auto va:g[dad]){

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

                dist[va] = dist[dad]+1;

                q.push(va);

            }

        }

    }

    if(dist[n-1] != -1 && dist[n-1] < 3)

        puts("POSSIBLE");

    else

        puts("IMPOSSIBLE");

    return 0;

}