#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:255000000")
bool firstout = 1;
template <class T>
T &minn(T &a, T b) {
  if (b < a) a = b;
  return a;
}
template <class T>
T &maxx(T &a, T b) {
  if (a < b) a = b;
  return a;
}
int &madd(int &a, int b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
  return a;
}
int &msub(int &a, int b) {
  a -= b;
  if (a < 0) a += 1000000007;
  return a;
}
int &mmult(int &a, int b) { return a = (long long)a * b % 1000000007; }
int mdiv(long long a, long long b, long long m) {
  a = (a % m + m) % m;
  b = (b % m + m) % m;
  if (a % b == 0) return a / b;
  return (a + m * mdiv(-a, m, b)) / b;
}
int n, m, q;
int A[1012];
int main() {
  int i, j, k;
  char c;
  int a, d;
  int ts;
  for (ts = 1; scanf("%"
                     "d",
                     &(n)) > 0;
       ++ts) {
    int res = 0;
    int p = -1;
    scanf(
        "%"
        "d",
        &(q));
    for (; q--;) {
      scanf(
          "%"
          "d",
          &(i));
      scanf(
          "%"
          "d",
          &(a));
      --i;
      if (p < 0) {
        if (res >= 0) maxx(res, i + a);
      } else {
        int l = i - j;
        l -= max(a, p) - min(a, p);
        if (l < 0)
          res = -1;
        else if (res >= 0)
          maxx(res, max(a, p) + l / 2);
      }
      p = a;
      j = i;
    }
    if (res >= 0) maxx(res, p + n - 1 - j);
    if (res < 0)
      printf(
          "%"
          "s",
          ("IMPOSSIBLE"));
    else
      printf(
          "%"
          "d",
          (res));
    printf("\n"), firstout = 1;
  }
  return 0;
}
