#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
int n, m;
int d[100010];
int h[100010];
int find_h(int h1, int h2, int md) {
  int l = max(h1, h2), r = 1e9, m, res = h1;
  while (l <= r) {
    int m = (l + r) >> 1;
    int dd = abs(m - h1) + abs(m - h2);
    if (dd <= md) {
      res = m;
      l = m + 1;
    } else
      r = m - 1;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> d[i] >> h[i];
  }
  int prh = h[0] + d[0] - 1;
  int prd = 1;
  int ans = -1e9;
  for (int i = 0; i < m; i++) {
    if (d[i] - prd < abs(h[i] - prh)) {
      cout << "IMPOSSIBLE";
      return 0;
    }
    int mh = find_h(prh, h[i], abs(d[i] - prd));
    ans = max(ans, mh);
    prh = h[i];
    prd = d[i];
  }
  if (prd != n) {
    ans = max(ans, prh + n - prd);
  }
  cout << ans;
  return 0;
}
