#include <bits/stdc++.h>
using namespace std;
void no() {
  cout << "IMPOSSIBLE" << endl;
  exit(0);
}
int main() {
  cin.sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int answer = 0;
  int last_day = 0, last_h = 0;
  for (int i = 0; i < m; i++) {
    int cur, h;
    cin >> cur >> h;
    if (i == 0) {
      answer = h + cur - 1;
    } else {
      answer = max(answer, h);
      int dif = abs(h - last_h);
      int days = cur - last_day;
      if (dif > days) no();
      if (h >= last_h) {
        answer = max(answer, h + (days - dif) / 2);
      } else {
        answer = max(answer, last_h + (days - dif) / 2);
      }
    }
    last_day = cur;
    last_h = h;
  }
  answer = max(answer, last_h + n - last_day);
  cout << answer << endl;
  return 0;
}
