#include <bits/stdc++.h>
using namespace std;
long long int ABS(long long int a) {
  if (a < 0) return (-a);
  return a;
}
vector<long long int> p, q;
int main() {
  long long int n, t, mx = 0;
  cin >> n >> t;
  for (int i = (0); i < (t); ++i) {
    long long int a, b;
    cin >> a >> b;
    p.push_back(b);
    q.push_back(a);
    mx = max(mx, b);
  }
  long long int j = 0;
  for (int i = (1); i < (p.size()); ++i) {
    if (p[i] - p[i - 1] > q[i] - q[i - 1] ||
        p[i - 1] - p[i] > q[i] - q[i - 1]) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    } else
      mx = max(mx, min(p[i], p[i - 1]) +
                       (q[i] - q[i - 1] + abs(p[i] - p[i - 1])) / 2);
  }
  mx = max(mx, p[0] + q[0] - 1);
  cout << max(mx, p[t - 1] + (n - q[t - 1])) << endl;
  return 0;
}
