#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:666000000")
using namespace std;
const int INF = (1 << 30) - 1;
const long double EPS = 1e-9;
void ML(const bool v) {
  if (v) return;
  int *ass;
  for (;;) {
    ass = new int[2500000];
    for (int i = 0; i < 2500000; i++) ass[i] = rand();
  }
}
void TL(const bool v) {
  if (v) return;
  for (;;) cout << rand() % (rand() % 1000 + 1) << endl;
}
void PE(const bool v) {
  if (v) return;
  for (int i = 0; i < 10000; i++) printf("%c", rand() % 256);
  exit(0);
}
int dmax, n;
vector<int> d, h;
bool LoAd() {
  if (!(2 == scanf("%d%d", &dmax, &n))) return false;
  h.resize(n);
  d.resize(n);
  for (int i = 0; i < (int)(n); i++) (2 == scanf("%d%d", &d[i], &h[i]));
  return true;
}
void SoLvE() {
  int res = h[0] + d[0] - 1;
  res = max(res, h.back() + dmax - d.back());
  for (int i = 0; i < (int)(n); i++) res = max(res, h[i]);
  for (int i = 0; i < (int)(n - 1); i++) {
    int d1 = d[i];
    int d2 = d[i + 1];
    int h1 = h[i];
    int h2 = h[i + 1];
    if (abs(h2 - h1) > d2 - d1) {
      puts("IMPOSSIBLE");
      return;
    }
    if (h1 > h2) swap(h1, h2);
    d1 += (h2 - h1);
    h1 = h2;
    int tr = h1 + (d2 - d1) / 2;
    res = max(res, tr);
  }
  cout << res << endl;
}
int main() {
  srand((int)time(NULL));
  LoAd();
  SoLvE();
  return 0;
}
