Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<int> ab, ba;
  
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    if(a == 1) ab.push_back(b);
    if(b == 1) ab.push_back(a);
    if(a == N) ba.push_back(b);
    if(b == N) ba.push_back(a);
  }
  
  sort(ab.begin(), ab.end());
  sort(ab.begin(), ab.end());
  
  bool flag = false;
  int i ,j = 0;
  while(i < ab.size() && j < ba.size()){
    if(ab[i] == ba[j]){
      flag = true;
      break
    }else if(ab[i] > ba[j]){
      j++;
    }else if(ab[i] < ba[j]){
      i++;
    }
  }
  if(flag) cout << "POSSIBLE";
  else cout << "IMPOSSIBLE";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    7 |   cin >> N >> M;
      |   ^~~
      |   std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:9:3: error: 'vector' was not declared in this scope
    9 |   vector<int> ab, ba;
      |   ^~~~~~
a.cc:9:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:9:10: error: expected primary-expression before 'int'
    9 |   vector<int> ab, ba;
      |          ^~~
a.cc:14:16: error: 'ab' was not declared in this scope; did you mean 'b'?
   14 |     if(a == 1) ab.push_back(b);
      |                ^~
      |                b
a.cc:15:16: error: 'ab' was not declared in this scope; did you mean 'b'?
   15 |     if(b == 1) ab.push_back(a);
      |                ^~
      |                b
a.cc:16:16: error: 'ba' was not declared in this scope; did you mean 'b'?
   16 |     if(a == N) ba.push_back(b);
      |                ^~
      |                b
a.cc:17:16: error: 'ba' was not declared in this scope; did you mean 'b'?
   17 |     if(b == N) ba.push_back(a);
      |                ^~
      |                b
a.cc:20:8: error: 'ab' was not declared in this scope; did you mean 'abs'?
   20 |   sort(ab.begin(), ab.end());
      |        ^~
      |        abs
a.cc:20:3: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   20 |   sort(ab.begin(), ab.end());
      |   ^~~~
      |   std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
a.cc:25:30: error: 'ba' was not declared in this scope
   25 |   while(i < ab.size() && j < ba.size()){
      |                              ^~
a.cc:28:12: error: expected ';' before '}' token
   28 |       break
      |            ^
      |            ;
   29 |     }else if(ab[i] > ba[j]){
      |     ~       
a.cc:35:12: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   35 |   if(flag) cout << "POSSIBLE";
      |            ^~~~
      |            std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:36:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   36 |   else cout << "IMPOSSIBLE";
      |        ^~~~
      |        std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~