#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
const int N = 2E5 + 5;
vector<pair<int, int>> vc;
bool valid(int x, int beg, int end) {
  int rem = vc[end].first - vc[beg].first;
  rem -= (x - vc[end].second);
  rem -= (x - vc[beg].second);
  return (rem >= 0);
}
int bs(int beg, int end) {
  int low = 1, high = 1e9, mid, res = -1;
  while (low <= high) {
    mid = (low + high) / 2;
    if (valid(mid, beg, end))
      res = mid, low = mid + 1;
    else
      high = mid - 1;
  }
  return res;
}
int main() {
  fast();
  int d, notes;
  cin >> d >> notes;
  while (notes--) {
    int day, h;
    cin >> day >> h;
    vc.push_back({day, h});
  }
  bool flag = true;
  int maxi = 0;
  for (int i = 0; i + 1 < vc.size(); i++) {
    int diff = abs(vc[i].second - vc[i + 1].second);
    int di = vc[i + 1].first - vc[i].first;
    if (di < diff) {
      flag = false;
      break;
    }
    maxi = max(maxi, bs(i, i + 1));
  }
  maxi = max(maxi, vc[vc.size() - 1].second + d - vc[vc.size() - 1].first);
  maxi = max(maxi, vc[0].second + vc[0].first - 1);
  if (flag)
    cout << maxi << "\n";
  else
    cout << "IMPOSSIBLE"
         << "\n";
}
