#include <bits/stdc++.h>
using namespace std;
int d[100010];
int h[100010];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) cin >> d[i] >> h[i];
  bool flag = false;
  int rpta = 0;
  for (int i = 1; i < m; i++) {
    if (abs(h[i] - h[i - 1]) > d[i] - d[i - 1]) {
      flag = true;
      break;
    }
  }
  if (flag) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    for (int i = 0; i < m; i++) rpta = max(rpta, h[i]);
    for (int i = 1; i < m; i++) {
      if (abs(h[i] - h[i - 1]) < d[i] - d[i - 1]) {
        int aux = max(h[i], h[i - 1]);
        int aux2 = d[i] - d[i - 1] - abs(h[i] - h[i - 1]);
        rpta = max(rpta, aux + aux2 / 2);
      }
    }
    rpta = max(d[0] - 1 + h[0], rpta);
    rpta = max(n - d[m - 1] + h[m - 1], rpta);
    cout << rpta << endl;
  }
  return 0;
}
