#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
long long n, m, ans = 0;
long long d[N], h[N];
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 1; i <= m; i++) cin >> d[i] >> h[i];
  for (long long i = 2; i <= m; i++) {
    long long maxdiff = abs(d[i] - d[i - 1]);
    if (abs(h[i] - h[i - 1]) > maxdiff) {
      cout << "IMPOSSIBLE";
      return 0;
    }
  }
  ans = max(h[1] + abs(d[1] - 1), h[m] + abs(n - d[m]));
  for (long long i = 1; i <= m - 1; i++) {
    long long extradays = d[i + 1] - d[i] - abs(h[i + 1] - h[i]);
    long long maxh = max(h[i], h[i + 1]);
    ans = max(ans, maxh + extradays / 2);
  }
  cout << ans;
  return 0;
}
