#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
pair<int, int> p[100005];
int main() {
  int n, m, maxa = INT_MIN;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> (p[i].first) >> (p[i].second);
    p[i].first--;
  }
  bool ans = true;
  for (int i = 0; i < m - 1; i++) {
    if (abs(p[i + 1].second - p[i].second) > p[i + 1].first - p[i].first)
      ans = false;
  }
  if (ans == false) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  maxa =
      max(p[0].second + p[0].first, p[m - 1].second + n - p[m - 1].first - 1);
  for (int i = 0; i < m - 1; i++) {
    int x = (p[i + 1].first + p[i].first + p[i + 1].second - p[i].second);
    x /= 2;
    maxa = max(maxa, p[i].second + x - p[i].first);
  }
  cout << maxa << endl;
  return 0;
}
