#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long BINF = 1000000000000000000ll;
const int N = 100001;
int n, q, l[N], r[N], ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> q;
  for (int i = 1; i <= q; ++i) {
    cin >> l[i] >> r[i];
    ans = max(ans, r[i]);
    if (i > 1) {
      if (l[i] - l[i - 1] < abs(r[i] - r[i - 1])) {
        cout << "IMPOSSIBLE";
        return 0;
      }
      ans = max(ans, ((l[i] - l[i - 1] + -abs(r[i] - r[i - 1])) >> 1) +
                         max(r[i - 1], r[i]));
    }
  }
  ans = max(ans, max(r[1] + l[1] - 1, n - l[q] + r[q]));
  cout << ans;
  return 0;
}
