#include <bits/stdc++.h>
using namespace std;
struct day {
  int d, h;
} days[100005];
int main() {
  int n, m, i, j, k;
  cin >> n >> m;
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &days[i].d, &days[i].h);
    if (i > 1 && abs(days[i].h - days[i - 1].h) > days[i].d - days[i - 1].d) {
      puts("IMPOSSIBLE");
      return 0;
    }
  }
  int maxn = 0;
  for (i = 1; i < m; i++) {
    int d = days[i + 1].d - days[i].d;
    d -= abs(days[i + 1].h - days[i].h);
    int t = max(days[i + 1].h, days[i].h) + d / 2;
    maxn = max(maxn, t);
  }
  maxn = max(maxn, days[1].d - 1 + days[1].h);
  maxn = max(maxn, n - days[m].d + days[m].h);
  cout << maxn << endl;
  return 0;
}
