#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, dlow, dhigh = 0, hlow, hhigh = 0, ans;
  cin >> n >> m;
  m--;
  cin >> dhigh >> hhigh;
  ans = hhigh + (dhigh - 1);
  while (m--) {
    dlow = dhigh;
    hlow = hhigh;
    cin >> dhigh >> hhigh;
    if (abs(hhigh - hlow) > dhigh - dlow) {
      cout << "IMPOSSIBLE";
      return 0;
    } else
      ans = max(ans, max(hlow, hhigh) +
                         (int((dhigh - dlow) - abs(hhigh - hlow)) / 2));
  }
  ans = max(ans, hhigh + (n - dhigh));
  cout << ans;
  return 0;
}
