#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, m, res;
int day[N], height[N];
bool max_height(void) {
  res = max(height[0] + day[0] - 1, height[m - 1] + n - day[m - 1]);
  for (int i = 0; i < m - 1; i++) {
    if (abs(height[i + 1] - height[i]) > day[i + 1] - day[i]) return false;
    res = max(res, (day[i + 1] - day[i] + height[i + 1] + height[i]) >> 1);
  }
  return true;
}
int main(void) {
  while (scanf("%d %d", &n, &m) == 2) {
    for (int i = 0; i < m; i++) scanf("%d %d", &day[i], &height[i]);
    if (!max_height())
      puts("IMPOSSIBLE");
    else
      printf("%d\n", res);
  }
  return EXIT_SUCCESS;
}
