#include <bits/stdc++.h>
using namespace std;
const int maxm = 100005;
int n, m, d[maxm], h[maxm], ans[maxm];
int a(int x) {
  if (x > 0)
    return x;
  else
    return -x;
}
int mm(int x, int y) {
  if (x > y)
    return y;
  else
    return x;
}
int main() {
  cin >> n >> m;
  d[0] = 0;
  h[0] = 0;
  for (int i = 1; i <= m; i++) cin >> d[i] >> h[i];
  for (int i = 2; i <= m; i++) {
    if (a(h[i] - h[i - 1]) > d[i] - d[i - 1]) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }
  int ma = 0;
  for (int i = 1; i < m; i++) {
    ans[i] = (d[i + 1] - d[i] + a(h[i + 1] - h[i])) / 2 + mm(h[i + 1], h[i]);
    if (ans[i] > ma) ma = ans[i];
  }
  ans[m] = n - d[m] + h[m];
  if (ans[m] > ma) ma = ans[m];
  ans[0] = d[1] - 1 + h[1];
  if (ans[0] > ma) ma = ans[0];
  cout << ma << endl;
  return 0;
}
