#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[1000000];
long long ans = 0;
bool check(long long k, pair<long long, long long> l,
           pair<long long, long long> r) {
  long long cur = abs(k - l.second) + abs(k - r.second);
  if (cur <= r.first - l.first) {
    return true;
  }
  return false;
}
int main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= m; ++i) {
    cin >> a[i].first >> a[i].second;
    ans = max(ans, a[i].second * 1LL);
  }
  if (a[m].first != n) {
    a[m + 1] = make_pair(n, a[m].second + n - a[m].first);
    ++m;
    ans = max(ans, a[m].second);
  }
  if (a[1].first != 1) {
    for (int i = m + 1; i >= 2; --i) {
      a[i] = a[i - 1];
    }
    a[1] = make_pair(1, a[2].second + a[2].first - 1);
    ans = max(ans, a[1].second);
    ++m;
  }
  for (long long i = 1; i <= m - 1; ++i) {
    if (abs(a[i + 1].second - a[i].second) > a[i + 1].first - a[i].first) {
      return 0 * printf("IMPOSSIBLE");
    }
    long long bot = min(a[i].second, a[i + 1].second);
    long long top = 22814882281488;
    while (top > bot + 1) {
      long long mid = (bot + top) / 2;
      if (check(mid, a[i], a[i + 1])) {
        bot = mid;
      } else {
        top = mid;
      }
    }
    ans = max(ans, bot);
  }
  cout << ans << endl;
}
