#include <bits/stdc++.h>
using namespace std;
const int N = 1000001;
int main() {
  long long n, m;
  cin >> n >> m;
  long long p1, p2;
  long long c1, c2;
  bool flag = false;
  cin >> p1 >> p2;
  long long h1 = p2 + p1 - 1;
  long long maximo = h1;
  for (long long count = 1; count < m; count++) {
    cin >> c1 >> c2;
    long long d2 = abs(c2 - p2);
    long long d1 = c1 - p1;
    if (d1 < d2)
      flag = true;
    else {
      d1 -= d2;
      long long maxi = max(c2, p2);
      maximo = max(maximo, maxi + d1 / 2);
    }
    p1 = c1;
    p2 = c2;
  }
  long long hn = p2 + n - p1;
  maximo = max(hn, maximo);
  if (flag)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << maximo << endl;
  return 0;
}
