#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, d, h, prev, prevh, diffd, diffh, mx = INT_MIN, i, f = 0, base, diff;
  cin >> n >> m;
  cin >> d >> h;
  mx = h + d - 1;
  prev = d;
  prevh = h;
  for (i = 1; i < m; i++) {
    cin >> d >> h;
    diffd = d - prev;
    diffh = abs(h - prevh);
    if (diffd < diffh) {
      f = 1;
      break;
    }
    base = h > prevh ? h : prevh;
    if (h != prevh) {
      diffd -= diffh;
    }
    diff = diffd / 2;
    if (base + diff > mx) mx = base + diff;
    prev = d;
    prevh = h;
  }
  if (prevh + n - prev > mx) mx = prevh + n - prev;
  if (f == 1)
    cout << "IMPOSSIBLE";
  else
    cout << mx;
  return 0;
}
