#include <bits/stdc++.h>
using namespace std;
string imp = "IMPOSSIBLE";
int getmax(int x, int y, int d) {
  int minAns = max(x, y) - min(x, y);
  if (minAns > d) return -1;
  return max(x, y) + (d - minAns) / 2;
}
int main() {
  ios::sync_with_stdio(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  while (cin >> n >> m) {
    vector<int> d(m);
    vector<int> h(m);
    for (int i = 0; i < m; i++) cin >> d[i] >> h[i];
    int ans = max(d[0] + h[0] - 1, n - d[m - 1] + h[m - 1]);
    bool can = 1;
    for (int i = 0; i < m - 1; i++) {
      int temp = getmax(h[i], h[i + 1], d[i + 1] - d[i]);
      if (temp == -1) {
        can = 0;
        break;
      }
      ans = max(ans, temp);
    }
    if (!can)
      cout << imp << endl;
    else
      cout << ans << endl;
  }
  return 0;
}
