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

#include<vector>

using namespace std;

vector<int>v[200001];

int arr[200001];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

		int a,b;

		cin>>a>>b;

		v[a].push_back(b);

		v[b].push_back(a);

		if(a==n)

		{

			arr[b]=1;

		}

		else if(b==n)

		{

			arr[a]=1;

		}

	}

	for(int i=0;i<v[1].size();i++)

	{

		if(arr[v[1][i]]==1)

		{

			cout<<"POSSIBLE";

			return 0;

		}

	}

				cout<<"IMPOSSIBLE";



	return 0;

}

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

#include<cstdio>

using namespace std;

int i,j,n,m,x[200003]= {0},a,b,num=0,num1=0;

int main()

{

    cin>>n>>m;

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

    {

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

        if(a==1)

            x[b]++;

        if(b==n)

            x[a]++;

    }

    int flag=0;

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

    {

        if(x[i]==2)

        {

            flag=1;

            break;

        }

    }

    if(flag==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;

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

#include<iostream>

using namespace std;

#define ll long long

int isb[200005];

int ise[200005];

int main()

{

    int n,m,a,b;

    while(cin >> n >> m)

    {

        memset(isb,0,sizeof(isb));

        memset(ise,0,sizeof(ise));

        while(m--)

        {

            cin >> a >> b;

            if(a == 1)

                isb[b] = 1;

            else if(a == n)

                ise[b] = 1;

            if(b == 1)

                isb[a] = 1;

            else if(b == n)

                ise[a] = 1;

        }

        int i;

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

        {

            if(isb[i] && ise[i])

            {

                cout << "POSSIBLE" << endl;

                break;

            }

        }

        if(i == n + 1)

        cout << "IMPOSSIBLE" << endl;

    }

    return 0;

}


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

using namespace std;

#define N 1000001



int arrr1[N+5],arrr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arrr1[b]=1;//第一次的终点

        if(b==n)

            arrr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arrr1[i]&&arrr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

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

using namespace std;

int a[200010];

int flag;

int n,m;

int main() {

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

	flag=0;

	int u,v;

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

		a[i]=0;

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

		scanf("%d%d",&u,&v);

		if(flag)

			continue;

		if(u==1) {

			if(a[v]) {

				flag=1;

			}

			a[v]=1;

		}



		else if(v==n) {

			if(a[u]) {

				flag=1;

			}

			a[u]=1;

		}



	}

	if(flag)

		printf("POSSIBLE\n");

	else printf("IMPOSSIBLE\n");



	return 0;

}




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

using namespace std;

#define N 1000001



int arrr1[N+5],arrr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arrr1[b]=1;//第一次的终点

        if(b==n)

            arrr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arrr1[i]&&arrr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

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

#include<vector>

using namespace std;

vector<int>v[200001];

int arr[200001];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

		int a,b;

		cin>>a>>b;

		v[a].push_back(b);

		v[b].push_back(a);

		if(a==n)

		{

			arr[b]=1;

		}

		else if(b==n)

		{

			arr[a]=1;

		}

	}

	for(int i=0;i<v[1].size();i++)

	{

		if(arr[v[1][i]]==1)

		{

			cout<<"POSSIBLE";

			return 0;

		}

	}

				cout<<"IMPOSSIBLE";



	return 0;

}

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

using namespace std;

#define N 1000001



int arrr1[N+5],arrr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arrr1[b]=1;//第一次的终点

        if(b==n)

            arrr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arrr1[i]&&arrr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

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

#include<cstdio>

using namespace std;

int i,j,n,m,x[200003]= {0},a,b,num=0,num1=0;

int main()

{

    cin>>n>>m;

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

    {

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

        if(a==1)

            x[b]++;

        if(b==n)

            x[a]++;

    }

    int flag=0;

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

    {

        if(x[i]==2)

        {

            flag=1;

            break;

        }

    }

    if(flag==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;

}


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

using namespace std;

#define N 1000001



int arrr1[N+5],arrr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arrr1[b]=1;//第一次的终点

        if(b==n)

            arrr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arrr1[i]&&arrr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

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

#include<iostream>

using namespace std;

#define ll long long

int isb[200005];

int ise[200005];

int main()

{

    int n,m,a,b;

    while(cin >> n >> m)

    {

        memset(isb,0,sizeof(isb));

        memset(ise,0,sizeof(ise));

        while(m--)

        {

            cin >> a >> b;

            if(a == 1)

                isb[b] = 1;

            else if(a == n)

                ise[b] = 1;

            if(b == 1)

                isb[a] = 1;

            else if(b == n)

                ise[a] = 1;

        }

        int i;

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

        {

            if(isb[i] && ise[i])

            {

                cout << "POSSIBLE" << endl;

                break;

            }

        }

        if(i == n + 1)

        cout << "IMPOSSIBLE" << endl;

    }

    return 0;

}


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

using namespace std;

#define int long long

#define pb push_back

#define fi first

#define se second

#define mp make_pair

#define pii pair<int,int>

#define endl '\n'

#define fr(i, a, b) for(int i = a; i <= b; i++)

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

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

 

typedef long long ll;

typedef long double f80;

 

const int mod = 1e9 + 7;



mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r){

    uniform_int_distribution<int> uid(l, r);

    return uid(rng);

}



ll pwr(ll a, ll b) {

    a %= mod;

    ll ans = 1;

    while(b) {

        if(b & 1) ans = (ans * a) % mod;

        a = (a * a) % mod;

        b >>= 1;

    }

    return ans;

}



set<int> g[2];

 

signed main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);

    #ifdef LOCAL

        freopen("inp.txt", "r", stdin);

        freopen("out.txt", "w", stdout);

    #endif

    int n, m;

    cin >> n >> m;

    fr(i, 1, m) {

        int u, v;

        cin >> u >> v;

        if(u == 1 || v == 1)

            g[0].insert(v);

        if(u == n || v == n)

            g[1].insert(u);

    }

    for(int x : g[0]) {

        if(g[1].count(x)) {

            cout << "POSSIBLE";

            return 0;

        }

    }

    cout << "IMPOSSIBLE";

    return 0;

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

#include<vector>

using namespace std;

vector<int>v[200001];

int arr[200001];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

		int a,b;

		cin>>a>>b;

		v[a].push_back(b);

		v[b].push_back(a);

		if(a==n)

		{

			arr[b]=1;

		}

		else if(b==n)

		{

			arr[a]=1;

		}

	}

	for(int i=0;i<v[1].size();i++)

	{

		if(arr[v[1][i]]==1)

		{

			cout<<"POSSIBLE";

			return 0;

		}

	}

				cout<<"IMPOSSIBLE";



	return 0;

}

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

using namespace std;

#define int long long

#define pb push_back

#define fi first

#define se second

#define mp make_pair

#define pii pair<int,int>

#define endl '\n'

#define fr(i, a, b) for(int i = a; i <= b; i++)

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

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

 

typedef long long ll;

typedef long double f80;

 

const int mod = 1e9 + 7;



mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r){

    uniform_int_distribution<int> uid(l, r);

    return uid(rng);

}



ll pwr(ll a, ll b) {

    a %= mod;

    ll ans = 1;

    while(b) {

        if(b & 1) ans = (ans * a) % mod;

        a = (a * a) % mod;

        b >>= 1;

    }

    return ans;

}



set<int> g[2];

 

signed main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);

    #ifdef LOCAL

        freopen("inp.txt", "r", stdin);

        freopen("out.txt", "w", stdout);

    #endif

    int n, m;

    cin >> n >> m;

    fr(i, 1, m) {

        int u, v;

        cin >> u >> v;

        if(u == 1 || v == 1)

            g[0].insert(v);

        if(u == n || v == n)

            g[1].insert(u);

    }

    for(int x : g[0]) {

        if(g[1].count(x)) {

            cout << "POSSIBLE";

            return 0;

        }

    }

    cout << "IMPOSSIBLE";

    return 0;

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

#include<cstdio>

using namespace std;

int i,j,n,m,x[200003]= {0},a,b,num=0,num1=0;

int main()

{

    cin>>n>>m;

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

    {

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

        if(a==1)

            x[b]++;

        if(b==n)

            x[a]++;

    }

    int flag=0;

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

    {

        if(x[i]==2)

        {

            flag=1;

            break;

        }

    }

    if(flag==1)

        cout<<"POSSIBLE"<<endl;

    else

        cout<<"IMPOSSIBLE"<<endl;

}


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

using namespace std;

#define int long long

#define pb push_back

#define fi first

#define se second

#define mp make_pair

#define pii pair<int,int>

#define endl '\n'

#define fr(i, a, b) for(int i = a; i <= b; i++)

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

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

 

typedef long long ll;

typedef long double f80;

 

const int mod = 1e9 + 7;



mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int rand(int l, int r){

    uniform_int_distribution<int> uid(l, r);

    return uid(rng);

}



ll pwr(ll a, ll b) {

    a %= mod;

    ll ans = 1;

    while(b) {

        if(b & 1) ans = (ans * a) % mod;

        a = (a * a) % mod;

        b >>= 1;

    }

    return ans;

}



set<int> g[2];

 

signed main()

{

    ios_base::sync_with_stdio(0);

    cin.tie(NULL);

    cout.tie(NULL);

    #ifdef LOCAL

        freopen("inp.txt", "r", stdin);

        freopen("out.txt", "w", stdout);

    #endif

    int n, m;

    cin >> n >> m;

    fr(i, 1, m) {

        int u, v;

        cin >> u >> v;

        if(u == 1 || v == 1)

            g[0].insert(v);

        if(u == n || v == n)

            g[1].insert(u);

    }

    for(int x : g[0]) {

        if(g[1].count(x)) {

            cout << "POSSIBLE";

            return 0;

        }

    }

    cout << "IMPOSSIBLE";

    return 0;

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

#include<iostream>

using namespace std;

#define ll long long

int isb[200005];

int ise[200005];

int main()

{

    int n,m,a,b;

    while(cin >> n >> m)

    {

        memset(isb,0,sizeof(isb));

        memset(ise,0,sizeof(ise));

        while(m--)

        {

            cin >> a >> b;

            if(a == 1)

                isb[b] = 1;

            else if(a == n)

                ise[b] = 1;

            if(b == 1)

                isb[a] = 1;

            else if(b == n)

                ise[a] = 1;

        }

        int i;

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

        {

            if(isb[i] && ise[i])

            {

                cout << "POSSIBLE" << endl;

                break;

            }

        }

        if(i == n + 1)

        cout << "IMPOSSIBLE" << endl;

    }

    return 0;

}


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

using namespace std;



typedef long long ll;

const ll INF = 1e18;

const int BIG = 1e9 + 555;

const int maxN = 2e5 + 55;



int n, m;

bool to1[maxN], ton[maxN];



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);



	cin >> n >> m;



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

		int u, v;	cin >> u >> v;

		if(u == 1){

			to1[v] = true;

		}

		if(v == 1){

			to1[u] = true;

		}

		if(u == n){

			ton[v] = true;

		}

		if(v == n){

			ton[u] = true;

		}

	}



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

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

			cout << "POSSIBLE\n";

			return 0;

		}

	}



	cout << "IMPOSSIBLE\n";

	return 0;

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

#include<vector>

using namespace std;

vector<int>v[200001];

int arr[200001];

int main()

{

	int n,m;

	cin>>n>>m;

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

	{

		int a,b;

		cin>>a>>b;

		v[a].push_back(b);

		v[b].push_back(a);

		if(a==n)

		{

			arr[b]=1;

		}

		else if(b==n)

		{

			arr[a]=1;

		}

	}

	for(int i=0;i<v[1].size();i++)

	{

		if(arr[v[1][i]]==1)

		{

			cout<<"POSSIBLE";

			return 0;

		}

	}

				cout<<"IMPOSSIBLE";



	return 0;

}

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

using namespace std;



typedef long long ll;

const ll INF = 1e18;

const int BIG = 1e9 + 555;

const int maxN = 2e5 + 55;



int n, m;

bool to1[maxN], ton[maxN];



int main(){

	ios::sync_with_stdio(false);

	cin.tie(0);

	cout.tie(0);



	cin >> n >> m;



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

		int u, v;	cin >> u >> v;

		if(u == 1){

			to1[v] = true;

		}

		if(v == 1){

			to1[u] = true;

		}

		if(u == n){

			ton[v] = true;

		}

		if(v == n){

			ton[u] = true;

		}

	}



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

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

			cout << "POSSIBLE\n";

			return 0;

		}

	}



	cout << "IMPOSSIBLE\n";

	return 0;

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

#include <vector>

#include <cmath>

#include <algorithm>

#include <cstring>

#include <string>

#include <map>

#include <stack>

#define ll long long

#define pii pair<int, int>

using namespace std;

int n,m;

int a1[200004],a2[200004];

int main()

{

    cin>>n>>m;int f=0;

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

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

    {

        int x,y;

        cin>>x>>y;

        if(x==1 )

        {

            a1[y]=1;

        }

        else if(y == 1)

        {

            a1[x]=1;

        }

        else if (y==n)

        {

            a2[x]=1;

        }

        else if( x == n)

        {

            a2[y] = 1;

        }



    }

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

        if(a1[i] == 1 && a2[i] == 1){

            cout<<"POSSIBLE" << endl;

            return 0;

        }

    }



  if(a2[1] || a1[n] == 1){

      cout<<"POSSIBLE" << endl;

            return 0;

       

  }

 cout<<"IMPOSSIBLE"<<endl;



    return 0;

}

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

#include <iostream>

#include <stack>

#include <set>

#include <cstdio>

#include <cstring>



using namespace std;



int ans[100005];

int res[100005];

int kun[100005];



int a[200005][2]={0};



int main(){

    int n,m;

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





    int ca=0,cb=0;

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

        int aa,bb;

        scanf("%d%d",&aa,&bb);

        if(aa==1){

            a[bb][0]=1;

        }

        if(bb==n){

            a[aa][1]=1;

        }

    }

    int f=1;

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

        if(a[i][0]==1&&a[i][1]==1){

            cout<<"POSSIBLE";

            f=0;

            break;

        }



    }

    if(f){

        cout<<"IMPOSSIBLE";

    }

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

#include<queue>

using namespace std;



typedef pair<int,int> P;



int a[200005];

vector<int>v[200005];



queue<P>q;

bool vis[200005];





int main()

{

    int n,m;

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

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

    {

        int q,w;

        scanf("%d%d",&q,&w);

        v[q].push_back(w);

        v[w].push_back(q);

    }

    vis[1]=true;

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

    int ans=0x3f3f3f3f;

    while(!q.empty())

    {

        P pai=q.front();

        q.pop();

        if(pai.second==3)

            break;

        if(pai.first==n)

        {

            ans=pai.second;

            break;

        }

        for(int i=0;i<v[pai.first].size();i++)

            if(vis[v[pai.first][i]]==false)

        {

            vis[v[pai.first][i]]=true;

            q.push(make_pair(v[pai.first][i],pai.second+1));

        }

    }

    if(ans>2)

        puts("IMPOSSIBLE");

    else

        puts("POSSIBLE");

    return 0;

}


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

#include <iostream>

#include <stack>

#include <set>

#include <cstdio>

#include <cstring>



using namespace std;



int ans[100005];

int res[100005];

int kun[100005];



int a[200005][2]={0};



int main(){

    int n,m;

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





    int ca=0,cb=0;

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

        int aa,bb;

        scanf("%d%d",&aa,&bb);

        if(aa==1){

            a[bb][0]=1;

        }

        if(bb==n){

            a[aa][1]=1;

        }

    }

    int f=1;

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

        if(a[i][0]==1&&a[i][1]==1){

            cout<<"POSSIBLE";

            f=0;

            break;

        }



    }

    if(f){

        cout<<"IMPOSSIBLE";

    }

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

#include <vector>

#include <cmath>

#include <algorithm>

#include <cstring>

#include <string>

#include <map>

#include <stack>

#define ll long long

#define pii pair<int, int>

using namespace std;

int n,m;

int a1[200004],a2[200004];

int main()

{

    cin>>n>>m;int f=0;

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

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

    {

        int x,y;

        cin>>x>>y;

        if(x==1 )

        {

            a1[y]=1;

        }

        else if(y == 1)

        {

            a1[x]=1;

        }

        else if (y==n)

        {

            a2[x]=1;

        }

        else if( x == n)

        {

            a2[y] = 1;

        }



    }

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

        if(a1[i] == 1 && a2[i] == 1){

            cout<<"POSSIBLE" << endl;

            return 0;

        }

    }



  if(a2[1] || a1[n] == 1){

      cout<<"POSSIBLE" << endl;

            return 0;

       

  }

 cout<<"IMPOSSIBLE"<<endl;



    return 0;

}

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

using namespace std;

#define N 1000001



int arr1[N+5],arr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arr1[b]=1;//第一次的终点

        if(b==n)

            arr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arr1[i]&&arr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

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

#include<queue>

using namespace std;



typedef pair<int,int> P;



int a[200005];

vector<int>v[200005];



queue<P>q;

bool vis[200005];





int main()

{

    int n,m;

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

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

    {

        int q,w;

        scanf("%d%d",&q,&w);

        v[q].push_back(w);

        v[w].push_back(q);

    }

    vis[1]=true;

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

    int ans=0x3f3f3f3f;

    while(!q.empty())

    {

        P pai=q.front();

        q.pop();

        if(pai.second==3)

            break;

        if(pai.first==n)

        {

            ans=pai.second;

            break;

        }

        for(int i=0;i<v[pai.first].size();i++)

            if(vis[v[pai.first][i]]==false)

        {

            vis[v[pai.first][i]]=true;

            q.push(make_pair(v[pai.first][i],pai.second+1));

        }

    }

    if(ans>2)

        puts("IMPOSSIBLE");

    else

        puts("POSSIBLE");

    return 0;

}


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

using namespace std;

#define N 1000001



int arr1[N+5],arr2[N+5];

int main()

{

    int n,m,a,b;



    cin>>n>>m;

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

    {

        cin>>a>>b;

        if(a==1)

            arr1[b]=1;//第一次的终点

        if(b==n)

            arr2[a]=1;//第二次的起点

    }



    int p=0;

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

    {

        if(arr1[i]&&arr2[i])

        {

            cout<<"POSSIBLE"<<endl;

            p=1;

        }

    }



    if(p==0)

        cout<<"IMPOSSIBLE"<<endl;



    return 0;

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

#include <cstring>

using namespace std;

int a[200005];

int b[200005];

bool vis[200005];

int main(){

	int N,M,i;

	cin>>N>>M;

	memset(vis,false,sizeof(vis));

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

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

		if(a[i]==1)

			vis[b[i]]=true;

	}

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

		if(b[i]==N){

			if(vis[a[i]]==true){

				cout<<"POSSIBLE"<<endl;

				break;

			}

		}

	}

	if(i==M)

		cout<<"IMPOSSIBLE"<<endl;

	return 0;

} 

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

#include<vector>

#include<set>

using namespace std;

const int maxn = 200005;

int num[2][maxn];

int mm[maxn];

int main()

{

	int n, m;

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

	int len1 = 0, len2 = 0;

	while (m--)

	{

		int a, b;

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

		if (a == 1)

		{

			num[0][len1++] = b;

		}

		if (a == n){

			num[1][len2++] = b;

		}

		if (b == n){

			num[1][len2++] = a;

		}

		if (b == 1){

			num[0][len1++] = a;

		}

	}

	bool flag = 0;

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

	{

		mm[num[0][i]] = 1;

		if (num[0][i] == n){

			flag = 1;  break;

		}

	}

	if (!flag)

	for (int j = 0; j < len2;++j)

	if (mm[num[1][j]]){ flag = 1; break; }





	if (flag){

		printf("POSSIBLE\n");

	}

	else

	{

		printf("IMPOSSIBLE\n");

		}

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

#include <cstring>

using namespace std;

int a[200005];

int b[200005];

bool vis[200005];

int main(){

	int N,M,i;

	cin>>N>>M;

	memset(vis,false,sizeof(vis));

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

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

		if(a[i]==1)

			vis[b[i]]=true;

	}

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

		if(b[i]==N){

			if(vis[a[i]]==true){

				cout<<"POSSIBLE"<<endl;

				break;

			}

		}

	}

	if(i==M)

		cout<<"IMPOSSIBLE"<<endl;

	return 0;

} 

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

using namespace std;

const int MC = 200010;

int N,M;

bool x[MC] , y[MC];



bool judge(){

	for (int v=0;v<N;v++)

		if(x[v] && y[v]) return 1;

	return 0;

}



int main(){

	cin>>N>>M;

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

		int a,b;

		cin>>a>>b;

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

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

	}

	if (judge()==true)

        cout<<"POSSIBLE";

    else

        cout<<"IMPOSSIBLE";

	return 0;

}