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