#include <bits/stdc++.h>
using namespace std;
void FastIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long modpow(long long a, long long p, long long mod) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a) % mod;
    a = (a * a) % mod;
    p /= 2;
  }
  return ret;
}
long long power(long long a, long long p) {
  long long ret = 1;
  while (p) {
    if (p & 1) ret = (ret * a);
    a = (a * a);
    p /= 2;
  }
  return ret;
}
long long maxh = 0;
vector<pair<long long, long long> > vec;
int main() {
  FastIO();
  long long n, m, x, y;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> x >> y;
    vec.push_back(make_pair(x, y));
  }
  maxh = max(maxh, vec[0].second + vec[0].first - 1);
  for (int i = 1; i < m; i++) {
    long long d = vec[i].first, h = vec[i].second, pd = vec[i - 1].first,
              ph = vec[i - 1].second;
    if (abs(h - ph) > (d - pd)) {
      cout << "IMPOSSIBLE\n";
      return 0;
    }
    maxh = max(maxh, h);
    maxh = max(maxh, (h + ph + d - pd) / 2);
  }
  maxh = max(maxh, vec[m - 1].second + n - vec[m - 1].first);
  cout << maxh << '\n';
  return 0;
}
