#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (~scanf("%d%d", &n, &m)) {
    bool flag = true;
    int a, b;
    int prea = 0, preb = 0;
    int res = 0;
    int ans = 0;
    scanf("%d%d", &prea, &preb);
    ans = preb + prea - 1;
    m--;
    while (m--) {
      scanf("%d%d", &a, &b);
      if (abs(b - preb) > a - prea) flag = false;
      if (flag) {
        int disd = a - prea;
        int dish = b - preb;
        if (dish >= 0) {
          res = preb + dish;
          disd -= dish;
          res += disd / 2;
          ans = max(ans, res);
        } else {
          disd += dish;
          res = preb + disd / 2;
          ans = max(ans, res);
        }
      }
      prea = a;
      preb = b;
    }
    if (flag) {
      preb += n - prea;
      ans = max(ans, preb);
    }
    if (flag)
      printf("%d\n", ans);
    else
      puts("IMPOSSIBLE");
  }
}
