#include <bits/stdc++.h>
using namespace std;
int d[100 * 1024];
int h[100 * 1024];
int main() {
  int n, m;
  cin >> n >> m;
  int i;
  for (i = 0; i < m; i++) cin >> d[i] >> h[i];
  int maxh = max(h[0] + d[0] - 1, h[m - 1] + n - d[m - 1]);
  for (i = 0; i < m - 1; i++) {
    int toeq = max(h[i], h[i + 1]) - min(h[i], h[i + 1]);
    if (toeq > d[i + 1] - d[i]) {
      cout << "IMPOSSIBLE";
      return 0;
    }
    int v = max(h[i], h[i + 1]) + (d[i + 1] - d[i] - toeq) / 2;
    if (v > maxh) maxh = v;
  }
  cout << maxh;
}
