#include <bits/stdc++.h>
using namespace std;
constexpr long long MAXN = 1e5 + 15;
int n, m, Ans, d[MAXN], h[MAXN];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> d[i] >> h[i];
    (Ans) = max((Ans), (h[i]));
    if (!i)
      (Ans) = max((Ans), (d[i] + h[i] - 1));
    else {
      int r = abs(h[i] - h[i - 1]);
      if (d[i] - d[i - 1] < r) return cout << "IMPOSSIBLE\n", false;
      int x = d[i] - d[i - 1];
      x -= r;
      x /= 2;
      (Ans) = max((Ans), (x + max(h[i], h[i - 1])));
    }
    if (i + 1 == m) (Ans) = max((Ans), (n - d[i] + h[i]));
  }
  return cout << Ans << '\n', false;
}
