#include <bits/stdc++.h>
using namespace std;
long long max(long long x, long long y) { return x < y ? y : x; }
struct node {
  long long d, h;
} day[100000];
int main() {
  long long n, m;
  cin >> n >> m;
  long long ans = 0;
  bool mark = false;
  for (int i = 0; i < m; i++) {
    cin >> day[i].d >> day[i].h;
  }
  ans = max(n - day[m - 1].d + day[m - 1].h, day[0].d + day[0].h - 1);
  for (int i = 0; i < m - 1; i++) {
    if (day[i + 1].d - day[i].d < abs(day[i + 1].h - day[i].h))
      mark = true;
    else
      ans = max(ans,
                (day[i + 1].d - day[i].d - abs(day[i + 1].h - day[i].h)) / 2 +
                    max(day[i].h, day[i + 1].h));
  }
  if (mark)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << ans << endl;
  return 0;
}
