#include <bits/stdc++.h>
using namespace std;
pair<int, int> arr[200000];
int vAbs(int x) {
  if (x < 0)
    return -x;
  else
    return x;
}
int main() {
  int n, m, d, h, maxi, x, y;
  scanf("%d%d", &n, &m);
  maxi = 0;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &d, &h);
    arr[i] = make_pair(d, h);
    maxi = max(maxi, h);
  }
  maxi = max(maxi, arr[0].second + (arr[0].first - 1));
  maxi = max(maxi, arr[m - 1].second + (n - arr[m - 1].first));
  for (int i = 1; i < m; i++) {
    if (vAbs(arr[i].second - arr[i - 1].second) >
        (arr[i].first - arr[i - 1].first)) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    } else {
      int dif = arr[i].first - arr[i - 1].first;
      int a = arr[i - 1].second;
      int b = arr[i].second;
      if ((b - a + dif) % 2 == 0) {
        x = (b - a + dif) / 2 + a;
        y = dif - x + b;
      } else {
        x = (b - a + dif) / 2 + a;
        y = dif - x - 1 + b;
      }
      maxi = max(maxi, max(x, y));
    }
  }
  cout << maxi << endl;
  return 0;
}
