#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  long curd = 0;
  long curh = 0;
  long maxm = 0;
  for (int i = 0; i < m; i++) {
    long d, h;
    cin >> d >> h;
    if (i == 0) {
      curd = 1;
      curh = h + (d - 1);
      maxm = max(curh, maxm);
    }
    if (curh > maxm) {
      maxm = curh;
    }
    if (d - curd < abs(h - curh)) {
      cout << "IMPOSSIBLE\n";
      return 0;
    }
    int buf;
    if (curh > h) {
      buf = curh;
    } else {
      buf = h;
    }
    if (maxm < (((d - curd) - (abs(curh - h))) / 2 + buf))
      maxm = ((d - curd) - abs(curh - h)) / 2 + buf;
    curd = d;
    curh = h;
  }
  if (n - curd + curh > maxm) maxm = curh + (n - curd);
  cout << maxm << endl;
  return 0;
}
