#include <bits/stdc++.h>
int l, i, n, m, a, mx, b, ld;
int main() {
  scanf("%d %d", &n, &m);
  mx = 0;
  for (i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    if (i == 0) {
      mx = b + a - 1;
    } else {
      if (a - ld < abs(b - l)) {
        printf("IMPOSSIBLE\n");
        return 0;
      }
      if (b >= l && b + ((a - ld) - abs(b - l)) / 2 > mx)
        mx = b + ((a - ld) - abs(b - l)) / 2;
      if (b < l && l + ((a - ld) - abs(b - l)) / 2 > mx)
        mx = l + ((a - ld) - abs(b - l)) / 2;
    }
    l = b;
    ld = a;
  }
  if (mx < (n - ld) + b) mx = (n - ld) + b;
  printf("%d\n", mx);
  return 0;
}
