#include <bits/stdc++.h>
using namespace std;
const long long int N = 1e6 + 2, inf = 1e9 + 7;
void _run();
void no() { cout << "IMPOSSIBLE\n", exit(0); }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  _run();
  return 0;
}
void _run() {
  int n, m;
  cin >> n >> m;
  pair<int, int> p[m + 1];
  for (int i = 0; i < m; i++) cin >> p[i].first >> p[i].second;
  sort(p, p + m);
  for (int i = 1; i < m; i++) {
    if (p[i].first - p[i - 1].first < abs(p[i].second - p[i - 1].second)) no();
  }
  int rs = p[0].first - 1 + p[0].second;
  rs = max(rs, p[0].second);
  for (int i = 1; i < m; i++) {
    int x =
        p[i].first - p[i - 1].first - 1 - abs(p[i].second - p[i - 1].second);
    if (x < 0) x = 0;
    int nw = x / 2 + (x & 1) + max(p[i].second, p[i - 1].second);
    rs = max(rs, nw);
    rs = max(rs, p[i].second);
  }
  int x = n - p[m - 1].first;
  rs = max(rs, x + p[m - 1].second);
  cout << rs << "\n";
}
