#include <bits/stdc++.h>
int day[100005], heigh[100005];
int main() {
  int n, m, i, j, k, h, p, r, max;
  while (scanf("%d%d", &n, &m) != EOF) {
    day[0] = heigh[0] = 0;
    max = 0;
    k = 1;
    for (i = 1; i <= m; i++) scanf("%d%d", &day[i], &heigh[i]);
    r = heigh[m] + n - day[m];
    for (i = 2; i <= m; i++) {
      if (day[i] - day[i - 1] >= abs(heigh[i] - heigh[i - 1]))
        continue;
      else {
        k = 0;
        break;
      }
    }
    if (k == 0)
      printf("IMPOSSIBLE\n");
    else {
      max = day[1] + heigh[1] - 1;
      max = max > r ? max : r;
      for (i = 2; i <= m; i++) {
        k = heigh[i] > heigh[i - 1] ? heigh[i] : heigh[i - 1];
        p = (day[i] - day[i - 1]) - abs(heigh[i] - heigh[i - 1]);
        if ((p / 2 + k) > max) max = p / 2 + k;
      }
      printf("%d\n", max);
    }
  }
  return 0;
}
