#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long a[1000005];
long long b[1000005];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  long long res = 0;
  for (long long i = 1; i <= m; i++) {
    cin >> a[i] >> b[i];
    res = max(res, b[i]);
  }
  res = max(res, a[1] - 1 + b[1]);
  for (long long i = 1; i < m; i++) {
    if (abs(b[i + 1] - b[i]) > abs(a[i + 1] - a[i])) {
      cout << "IMPOSSIBLE";
      return 0;
    }
    res = max(res, (a[i + 1] - a[i] + b[i + 1] + b[i]) / 2);
  }
  res = max(res, n - a[m] + b[m]);
  cout << res;
  return 0;
}
