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