#include <bits/stdc++.h>
using namespace std;
template <class T>
string tostring(T x) {
  ostringstream out;
  out << x;
  return out.str();
}
long long toint(string s) {
  istringstream in(s);
  long long x;
  in >> x;
  return x;
}
struct cmp {
  bool operator()(const pair<int, int> &a, const pair<int, int> &b) const {
    return a.second > b.second;
  }
};
long long n, k;
vector<pair<long, long> > vec;
int main() {
  long long a, b, a1 = 1, b1 = 0;
  cin >> n >> k;
  long long ans = 0, t, t1;
  cin >> a >> b;
  a1 = a;
  b1 = b;
  t = b1 + (a1 - 1);
  ans = (ans < t) ? t : ans;
  for (int i = 1; i < k; i++) {
    cin >> a >> b;
    if (a - a1 < (((b - b1) > (0)) ? (b - b1) : (-(b - b1)))) {
      cout << "IMPOSSIBLE";
      return 0;
    }
    if (b1 < b) {
      t = (a - a1 - 1) - (b - b1);
      t = (t + 1) / 2;
      t1 = b + t;
      ans = (ans < t1) ? t1 : ans;
    } else {
      t = (a - a1 - 1) - (b1 - b);
      t = (t + 1) / 2;
      t1 = b1 + t;
      ans = (ans < t1) ? t1 : ans;
    }
    a1 = a;
    b1 = b;
  }
  t = b1 + (n - a1);
  ans = (ans < t) ? t : ans;
  cout << ans;
  return 0;
}
