#include <bits/stdc++.h>
using namespace std;
const int maxm = 100010;
int n, m, d[maxm], h[maxm], ans, k1, k2;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) scanf("%d%d", &d[i], &h[i]);
  ans = h[1] + d[1] - 1;
  for (int i = 1; i < m; ++i) {
    k1 = (h[i + 1] - h[i] + d[i] + d[i + 1]) / 2;
    k2 = (h[i] + h[i + 1] + d[i + 1] - d[i]) / 2;
    if (k1 < d[i] || k1 > d[i + 1]) {
      puts("IMPOSSIBLE");
      return 0;
    }
    if (k2 > ans) ans = k2;
  }
  if (h[m] + n - d[m] > ans) ans = h[m] + n - d[m];
  printf("%d\n", ans);
  return 0;
}
