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