#include <bits/stdc++.h>
using namespace std;
int computeMax(int h1, int h2, int d1, int d2) {
  return h1 + (h2 + d2 - d1 - h1) / 2;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int> > daysToHeights(m);
  for (int i = 0; i < m; i++) {
    int d, h;
    cin >> d >> h;
    daysToHeights[i] = make_pair(d, h);
  }
  for (int i = 1; i < m; i++) {
    int prevDay = daysToHeights[i - 1].first;
    int currDay = daysToHeights[i].first;
    int prevHeight = daysToHeights[i - 1].second;
    int currHeight = daysToHeights[i].second;
    if (abs(currHeight - prevHeight) > currDay - prevDay) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
  }
  int ans = -1;
  for (int i = 1; i < m; i++) {
    int prevDay = daysToHeights[i - 1].first;
    int currDay = daysToHeights[i].first;
    int prevHeight = daysToHeights[i - 1].second;
    int currHeight = daysToHeights[i].second;
    int x = computeMax(prevHeight, currHeight, prevDay, currDay);
    ans = max(ans, x);
  }
  ans = max(ans, n - daysToHeights[m - 1].first + daysToHeights[m - 1].second);
  ans = max(ans, daysToHeights[0].first - 1 + daysToHeights[0].second);
  cout << ans << endl;
  return 0;
}
