#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int a, ha;
  scanf("%d%d", &a, &ha);
  int ans = ha + a - 1;
  for (int i = 1; i < m; ++i) {
    int b, hb;
    scanf("%d%d", &b, &hb);
    if (b - a < abs(hb - ha)) {
      printf("IMPOSSIBLE");
      return 0;
    }
    ans = max(ans, max(ha, hb) + ((b - a) - abs(hb - ha)) / 2);
    a = b;
    ha = hb;
  }
  ans = max(ans, ha + n - a);
  printf("%d", ans);
  return 0;
}
