#include <bits/stdc++.h>
using namespace std;
int N, M, d[100005], h[100005], temp, day, ans, displace;
bool bisa = true;
int main() {
  scanf("%d %d", &N, &M);
  for (int i = 0; i < M; i++) scanf("%d %d", &d[i], &h[i]);
  temp = h[0] + (d[0] - 1);
  if (temp > ans) ans = temp;
  for (int i = 1; i < M; i++) {
    day = d[i] - d[i - 1];
    if (abs(h[i] - h[i - 1]) > day) {
      bisa = false;
      break;
    }
    displace = abs(h[i] - h[i - 1]);
    if (displace == day)
      temp = max(h[i], h[i - 1]);
    else
      temp = max(h[i], h[i - 1]) + floor((day - displace) / 2.0);
    if (temp > ans) ans = temp;
  }
  temp = h[M - 1] + (N - d[M - 1]);
  if (temp > ans) ans = temp;
  if (bisa)
    printf("%d\n", ans);
  else
    printf("IMPOSSIBLE\n");
  return 0;
}
