#include <bits/stdc++.h>
using namespace std;
const int INF = numeric_limits<int>::max();
const long long LLINF = numeric_limits<long long>::max();
const unsigned long long ULLINF = numeric_limits<unsigned long long>::max();
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int prevD, prevH;
  cin >> prevD >> prevH;
  int ans = 0;
  if (prevD != 1) ans = max(ans, prevD + prevH - 1);
  int curD, curH;
  for (int t = 0; t < m - 1; t++) {
    cin >> curD >> curH;
    if (curD - prevD < abs(curH - prevH)) {
      cout << "IMPOSSIBLE";
      return 0;
    }
    int l = 0, r = curD - prevD, res = 0;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (prevH + mid - curH <= abs(curD - prevD) - mid) {
        res = prevH + mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }
    ans = max(ans, res);
    prevD = curD;
    prevH = curH;
  }
  ans = max(ans, n - prevD + prevH);
  cout << ans;
}
