#include <bits/stdc++.h>
using namespace std;
void checkMin(int &a, int b) {
  if (a > b) {
    a = b;
  }
}
const int N = 1 << 20;
const int INF = 1 << 26;
int main() {
  int n, i, j, k, m, d, h, preD, preH;
  while (cin >> n >> m) {
    preD = preH = 0;
    int ans = 0;
    bool ok = true;
    for (i = 1; i <= m; ++i) {
      cin >> d >> h;
      if (i == 1) {
        ans = max(ans, h + d - 1);
      } else {
        if (abs(d - preD) < abs(h - preH)) {
          ok = false;
        }
        int difH = abs(h - preH);
        int difD = abs(d - preD);
        ans = max(ans, (difD - difH) / 2 + max(h, preH));
      }
      preD = d;
      preH = h;
    }
    ans = max(ans, preH + n - preD);
    if (!ok) {
      puts("IMPOSSIBLE");
    } else {
      printf("%d\n", ans);
    }
  }
  return 0;
}
