#include <bits/stdc++.h>
using namespace std;
int doit() {
  int n, m;
  scanf("%d%d", &n, &m);
  int lastd, lasth, ans = -1;
  for (int i = 1; i <= m; i++) {
    int d, h;
    scanf("%d%d", &d, &h);
    if (i != 1) {
      if (abs(h - lasth) > abs(d - lastd))
        return -1;
      else {
        ans = max(ans, h);
        int rest = abs(d - lastd) - abs(h - lasth);
        ans = max(ans, max(lasth, h) + rest / 2);
      }
    } else {
      ans = max(ans, h + d - 1);
    }
    lastd = d;
    lasth = h;
  }
  ans = max(ans, lasth + n - lastd);
  return ans;
}
int main() {
  int ans = doit();
  if (ans == -1)
    printf("IMPOSSIBLE\n");
  else
    printf("%d\n", ans);
}
