#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m, mx = 0;
  cin >> n >> m;
  pair<long long, long long> arr[m];
  for (int i = 0; i < m; ++i)
    cin >> arr[i].first >> arr[i].second, mx = max(mx, arr[i].second);
  mx = max({arr[0].second + arr[0].first - 1,
            n - arr[m - 1].first + arr[m - 1].second, mx});
  for (int i = 1; i < m; ++i) {
    long long lo = arr[i].second, hi = 1e18, mid, ans = -1;
    long long dist = arr[i].first - arr[i - 1].first;
    while (lo <= hi) {
      mid = (lo + hi) >> 1;
      long long blocks =
          abs(mid - arr[i - 1].second) + abs(mid - arr[i].second);
      if (blocks <= dist)
        ans = mid, lo = mid + 1;
      else
        hi = mid - 1;
    }
    if (ans == -1) return cout << "IMPOSSIBLE", 0;
    mx = max(mx, ans);
  }
  cout << mx;
  return 0;
}
