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