#include <bits/stdc++.h>
using namespace std;
int n, m;
int d[100005], h[100005];
int main() {
  scanf("%d %d", &n, &m);
  long long ans = 0;
  for (int i = 0; i < m; i++)
    scanf("%d %d", d + i, h + i), ans = max(ans, 1LL * h[i]);
  ans = max(ans, 1LL * max(h[0] + d[0] - 1, h[m - 1] + n - d[m - 1]));
  for (int i = 0; i + 1 < m; i++)
    if (abs(h[i + 1] - h[i]) <= d[i + 1] - d[i]) {
      long long lo = max(h[i], h[i + 1]), hi = 1234567891234, m;
      while (lo < hi) {
        m = (lo + hi + 1) / 2;
        if (2 * m - h[i] - h[i + 1] <= d[i + 1] - d[i])
          lo = m;
        else
          hi = m - 1;
      }
      ans = max(ans, lo);
    } else {
      printf("IMPOSSIBLE\n");
      return 0;
    }
  printf("%lld\n", ans);
  return 0;
}
