#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream& operator<<(ostream& o, pair<A, B>& p) {
  return o << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream& operator<<(ostream& o, const vector<T>& v) {
  o << "{";
  for (typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
    o << *it << ", ";
  return o << "}";
}
struct debugger {
  ostream& out;
  bool first;
  void start() { first = true; }
  debugger(ostream& out) : out(out) { start(); }
  void nl() {
    out << endl;
    start();
  }
  template <class T>
  debugger& operator,(T& v) {
    if (first)
      first = false;
    else
      out << ", ";
    out << v;
    return *this;
  }
  template <class T>
  debugger& operator,(pair<T*, int> arr) {
    out << "{";
    for (typeof((arr.second) - 1) i = (0); i <= ((arr.second) - 1); i++) {
      out << arr.first[i] << ", ";
    }
    out << "}";
    return *this;
  }
} dbg(cerr);
int d[111111], h[111111];
int main() {
  int n, m;
  cin >> n >> m;
  for (typeof(m) i = (1); i <= (m); i++) {
    cin >> d[i] >> h[i];
  }
  int mx = h[1];
  if (d[1] != 1) {
    mx = max(d[1] + h[1] - 1, mx);
  }
  if (d[m] != n) {
    mx = max(n - d[m] + h[m], mx);
  }
  for (typeof(m - 1) i = (1); i <= (m - 1); i++) {
    if (abs(d[i + 1] - d[i]) < abs(h[i + 1] - h[i])) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
    int x = max(h[i + 1], h[i]) +
            (abs(abs(d[i + 1] - d[i]) - abs(h[i + 1] - h[i]))) / 2;
    mx = max(mx, x);
  }
  cout << mx << endl;
  return 0;
}
