#include <bits/stdc++.h>
int dx[] = {0, -1, 0, 1, -1, 1, -1, 1};
int dy[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int MOD = 1e9 + 7, N = 2e5 + 5, oo = 2e9;
const double pi = acos(-1);
using namespace std;
long long day[N], h[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, m;
  cin >> n >> m;
  long long ans = -1;
  for (int i = 0; i < m; i++) {
    cin >> day[i] >> h[i];
    ans = max(ans, h[i]);
    if (i and day[i] - day[i - 1] < abs(h[i] - h[i - 1]))
      return cout << "IMPOSSIBLE", 0;
  }
  ans = max(ans, h[0] + day[0] - 1);
  ans = max(ans, h[m - 1] + (n - day[m - 1]));
  for (int i = 1; i < m; i++) {
    long long dif = day[i] - day[i - 1], cur = h[i - 1];
    if (h[i] > h[i - 1])
      ans = max(ans, h[i] + (day[i] - day[i - 1] - abs(h[i] - h[i - 1])) / 2);
    else
      ans =
          max(ans, h[i - 1] + (day[i] - day[i - 1] - abs(h[i] - h[i - 1])) / 2);
  }
  cout << ans;
  return 0;
}
