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