#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int ans = 0;
  vector<pair<long long int, long long int> > v;
  long long int mm = m;
  long long int mi = 0;
  while (m--) {
    long long int a, b;
    cin >> a >> b;
    mi = max(mi, b);
    ans = max(ans, b);
    v.push_back(make_pair(a, b));
  }
  sort(v.begin(), v.end());
  ans = max(ans, v[0].second + v[0].first - 1);
  for (long long int i = 1; i < v.size(); i++) {
    if (v[i].first - v[i - 1].first < abs(v[i].second - v[i - 1].second) ||
        v[i].first == v[i - 1].first) {
      cout << "IMPOSSIBLE\n";
      return 0;
    }
    long long int nod = v[i].first - v[i - 1].first;
    nod -= abs(v[i].second - v[i - 1].second);
    nod /= 2;
    ans = max(ans, v[i].second + nod);
    ans = max(ans, v[i - 1].second + nod);
  }
  ans = max(ans, n - v[mm - 1].first + v[mm - 1].second);
  cout << ans << endl;
}
