#include <bits/stdc++.h>
using namespace std;
const bool distribute = true;
int main() {
  istream *in = distribute ? (&cin) : (new ifstream("in.txt"));
  int n, b;
  *in >> n >> b;
  int day[b];
  int height[b];
  for (int i = 0; i < b; i++) *in >> day[i] >> height[i];
  int best = day[0] - 1 + height[0];
  for (int i = 0; i < b - 1; i++) {
    int cur = day[i + 1] - day[i];
    cur -= abs(height[i] - height[i + 1]);
    if (cur < 0) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
    best = max(best, max(height[i], height[i + 1]) + cur / 2);
  }
  best = max(best, height[b - 1] + n - day[b - 1]);
  cout << best << endl;
  return 0;
}
