#include <bits/stdc++.h>
int dx[] = {0, 1, -1, 0, 1, -1, 1, -1, -2, 2, 0, 0},
    dy[] = {1, 0, 0, -1, -1, 1, 1, -1, 0, 0, -2, 2};
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  queue<pair<int, int> > q;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    q.push(make_pair(a, b));
  }
  bool first = 1;
  int ans = 0;
  pair<int, int> last;
  while (q.size()) {
    pair<int, int> top = q.front();
    q.pop();
    int d = top.first, h = top.second;
    if (first) {
      ans = max(ans, h + (d - 1));
      first = 0;
    } else {
      int days = d - last.first - 1;
      days -= abs(h - last.second) - 1;
      if (days < 0) {
        printf("IMPOSSIBLE\n");
        exit(0);
      }
      int hmx = max(h, last.second);
      ans = max(ans, (int)(hmx + floor(days / 2.0)));
    }
    last = top;
  }
  ans = max(ans, n - last.first + last.second);
  cout << ans << endl;
}
