#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<pair<int, int> > w;
int algo(int i, bool &f) {
  int dist = -w[i].first + w[i + 1].first;
  int h1 = w[i].second, h2 = w[i + 1].second;
  if (dist < abs(h1 - h2)) {
    f = false;
    return 0;
  }
  return h1 + (h2 - h1 + dist) / 2;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < (int)m; i++) {
    int d, h;
    cin >> d >> h;
    w.push_back(make_pair(d, h));
  }
  int m_h = max((w[0].first - 1) + w[0].second,
                (n - w[m - 1].first) + w[m - 1].second);
  bool f = true;
  for (int i = 0; i < m - 1; i++) {
    m_h = max(max(w[i].second, m_h), algo(i, f));
    if (!f) break;
  }
  if (f)
    cout << m_h;
  else
    cout << "IMPOSSIBLE";
  return 0;
}
