#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double PI = acos(-1);
const long long MOD = 1000000007;
const long long FMOD = 998244353;
const long double eps = 1e-9;
mt19937 RNG(chrono::steady_clock::now().time_since_epoch().count());
signed main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, long long> > v(m);
  for (long long i = 0; i < m; i++) {
    long long a, b;
    cin >> a >> b;
    v[i] = make_pair(a, b);
  }
  for (long long i = 0; i < m - 1; i++) {
    if (v[i + 1].first - v[i].first < abs(v[i + 1].second - v[i].second)) {
      cout << "IMPOSSIBLE";
      return 0;
    }
  }
  long long ans = v[0].first - 1 + v[0].second;
  for (long long i = 0; i < m - 1; i++) {
    ans = max(
        ans,
        ((v[i + 1].first - v[i].first) + (v[i + 1].second + v[i].second)) / 2);
  }
  ans = max(ans, n - v[m - 1].first + v[m - 1].second);
  cout << ans;
}
