#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, d[100005], h[100005], mxH, t;
  cin >> n >> m;
  for (int i = 1; i <= m; i++) cin >> d[i] >> h[i];
  for (int i = 2; i <= m; i++) {
    if (abs(h[i] - h[i - 1]) > d[i] - d[i - 1]) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }
  mxH = -1;
  for (int i = 2; i <= m; i++) {
    t = d[i] - d[i - 1];
    mxH = max(mxH, (t + h[i - 1] + h[i]) / 2);
    mxH = max(mxH, h[i - 1]);
    mxH = max(mxH, h[i]);
  }
  mxH = max(mxH, d[1] - 1 + h[1]);
  mxH = max(mxH, n - d[m] + h[m]);
  cout << mxH << endl;
  return 0;
}
