#include <bits/stdc++.h>
using namespace std;
void Suhaib_Sawalha() {
  int m, n;
  cin >> m >> n;
  pair<int, int> p[n];
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    cin >> p[i].first >> p[i].second;
    ans = max(ans, p[i].second);
  }
  for (int i = 1; i < n; ++i) {
    if (p[i].first - p[i - 1].first < abs(p[i].second - p[i - 1].second)) {
      cout << "IMPOSSIBLE";
      return;
    }
  }
  ans = max(ans, p[0].second + p[0].first - 1);
  ans = max(ans, p[n - 1].second + m - p[n - 1].first);
  for (int i = 1; i < n; ++i) {
    int dis = p[i].first - p[i - 1].first - 1;
    int l = p[i - 1].second, r = 1e9;
    while (l < r) {
      int mid = (l + r + 1) / 2;
      if (mid - p[i - 1].second - 1 + abs(p[i].second - mid) <= dis)
        l = mid;
      else
        r = mid - 1;
    }
    ans = max(ans, l);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  Suhaib_Sawalha();
  return 0;
}
