#include <bits/stdc++.h>
using namespace std;
int calcmaxheight(int day1, int height1, int day2, int height2) {
  int l = day2 - day1;
  int d = height2 - height1;
  if (((d < 0) ? -d : d) > l) return -1;
  int peak = d + (l - d) * 0.5;
  int peak_height = peak + height1;
  return peak_height;
};
int main(int argc, char** argv) {
  int a, b, c, d;
  int days;
  int records;
  cin >> days;
  cin >> records;
  cin >> c >> d;
  int maxheight = c + (d - 1);
  for (int i = 0; i != records - 1; ++i) {
    a = c;
    b = d;
    cin >> c >> d;
    int buf = calcmaxheight(a, b, c, d);
    if (buf == -1) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    };
    maxheight = max(buf, maxheight);
  };
  maxheight = max(maxheight, days - c + d);
  cout << maxheight << endl;
  return 0;
};
