#include <bits/stdc++.h>
using namespace std;
int a[100005];
int h[100005];
int n, m;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    cin >> a[i] >> h[i];
  }
  int res = h[1] + a[1] - 1;
  res = max(res, n - a[m] + h[m]);
  bool ok = 1;
  int dh, da, dd;
  for (int i = 1; i <= m - 1; i++) {
    if (abs(h[i] - h[i + 1]) <= a[i + 1] - a[i]) {
      dh = abs(h[i] - h[i + 1]);
      da = a[i + 1] - a[i];
      dd = (da - dh) / 2;
      res = max(res, dd + max(h[i], h[i + 1]));
    } else
      ok = 0;
  }
  if (!ok)
    puts("IMPOSSIBLE");
  else
    cout << res << endl;
  return 0;
}
