#include <bits/stdc++.h>
using namespace std;
int main() {
  int mx = 0, i, n, m, d, h, ld, lh;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> d >> h;
    if (i == 0) {
      ld = d;
      lh = h;
      mx = lh + ld - 1;
      continue;
    }
    if (abs(h - lh) > d - ld) {
      cout << "IMPOSSIBLE";
      return 0;
    }
    if (h - lh < 0)
      mx = max(mx, lh + (d - ld - abs(h - lh)) / 2);
    else
      mx = max(mx, h + (d - ld - abs(h - lh)) / 2);
    ld = d;
    lh = h;
  }
  mx = max(mx, lh + n - ld);
  cout << mx;
  return 0;
}
