#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 7;
string s;
int n, m;
int a[200000], b[200000];
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  int ans = b[0] + a[0] - 1;
  for (int i = 0; i < m - 1; i++) {
    if (abs(a[i] - a[i + 1]) < abs(b[i] - b[i + 1]))
      return cout << "IMPOSSIBLE" << endl, 0;
    int hi = max(b[i], b[i + 1]), x = a[i + 1] - a[i] - abs(b[i] - b[i + 1]);
    ans = max(ans, hi + x / 2);
  }
  ans = max(ans, b[m - 1] + n - a[m - 1]);
  cout << ans << endl;
}
