#include <bits/stdc++.h>
using namespace std;
int n, m;
struct Node {
  int d, h;
} bx[100010];
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &bx[i].d, &bx[i].h);
  }
  bool can = 1;
  int mx = bx[1].h + bx[1].d - 1;
  for (int i = 2; i <= m; i++) {
    int len = bx[i].d - bx[i - 1].d;
    if (bx[i - 1].h < bx[i].h) {
      if (bx[i - 1].h + len < bx[i].h) {
        can = 0;
        break;
      }
    } else if (bx[i - 1].h > bx[i].h) {
      if (bx[i - 1].h - len > bx[i].h) {
        can = 0;
        break;
      }
    }
    int l = bx[i - 1].h;
    int r = 1000000000;
    int mid, as;
    while (l <= r) {
      mid = l + r >> 1;
      int t = mid - bx[i - 1].h + abs(mid - bx[i].h);
      if (t <= len) {
        as = mid;
        l = mid + 1;
      } else
        r = mid - 1;
    }
    mx = max(mx, as);
  }
  mx = max(mx, bx[m].h + n - bx[m].d);
  if (can) {
    printf("%d\n", mx);
  } else {
    printf("IMPOSSIBLE\n");
  }
  return 0;
}
