#include <bits/stdc++.h>
using namespace std;
int x[100100], y[100100];
int main() {
  int n, m, i, j, ans = 0, flag = 1;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) scanf("%d%d", &x[i], &y[i]);
  for (i = 2; i <= m; i++) {
    if (abs(y[i] - y[i - 1]) > x[i] - x[i - 1]) {
      flag = 0;
      break;
    }
    ans = max(ans, (x[i] + abs(y[i] - y[i - 1]) - x[i - 1]) / 2 +
                       min(y[i], y[i - 1]));
  }
  ans = max(y[1] + x[1] - 1, ans);
  ans = max(y[m] + n - x[m], ans);
  if (flag)
    printf("%d\n", ans);
  else
    puts("IMPOSSIBLE");
  return 0;
}
