#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  bool flag = true;
  cin >> n >> m;
  using ll = long long;
  ll d, h;
  cin >> d >> h;
  ll mh = h + d - 1;
  for (ll i = 1; i < m; i++) {
    ll _d = d, _h = h;
    cin >> d >> h;
    _d = d - _d, _h = h - _h;
    if (abs(_h) > _d) {
      flag = false;
    } else {
      if (abs(_d - _h) % 2 != 0) {
        _d--;
      }
      mh = max(mh, h + (_d - _h) / 2);
    }
  }
  mh = max(mh, h + ll(n - d));
  if (flag) {
    cout << mh << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}
