#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> left(m);
  int max_height = 0;
  for (int i = 0; i < m; i++) {
    cin >> left[i].first >> left[i].second;
    if (i == 0) {
      int cur_height = left[i].second + left[i].first - 1;
      max_height = max(max_height, cur_height);
    }
    if (i >= 1) {
      int time_gone = left[i].first - left[i - 1].first;
      int dist = left[i].second - left[i - 1].second;
      if (abs(dist) > time_gone) {
        cout << "IMPOSSIBLE" << endl;
        return 0;
      }
      int cur_height = left[i - 1].second + time_gone;
      cur_height = cur_height - abs(cur_height - left[i].second) / 2 -
                   abs(cur_height - left[i].second) % 2;
      max_height = max(max_height, cur_height);
    }
  }
  max_height = max(max_height, left[m - 1].second + (n - left[m - 1].first));
  cout << max_height << endl;
  return 0;
}
