#include <bits/stdc++.h>
using namespace std;
template <class T>
T min_(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
T max_(T a, T b) {
  return (a > b ? a : b);
}
const int MAX_N = 1e5 + 1;
vector<pair<unsigned long long, unsigned long long> > notes;
int main(int argc, char *argv[]) {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int days, nnotes;
  cin >> days >> nnotes;
  notes.resize(nnotes);
  int day, h;
  int max_h = 0;
  for (int i = 0; i < nnotes; ++i) {
    cin >> day >> h;
    max_h = max(max_h, h);
    notes[i] = {day, h};
  }
  int new_h;
  int day1, day2, h1, h2;
  day1 = notes[0].first;
  if (day1 != 1) {
    h1 = notes[0].second;
    new_h = h1 + day1 - 1;
    max_h = max(max_h, new_h);
  }
  for (int i = 0; i < nnotes; ++i) {
    day1 = notes[i].first;
    h1 = notes[i].second;
    if (i == nnotes - 1) {
      day2 = days;
      new_h = h1 + (day2 - day1);
      max_h = max(max_h, new_h);
      break;
    }
    day2 = notes[i + 1].first;
    h2 = notes[i + 1].second;
    int ddiff = day2 - day1;
    int hdiff = abs(h2 - h1);
    if (hdiff > ddiff) {
      cout << "IMPOSSIBLE\n";
      return 0;
    } else {
      if (h1 < h2) {
        day1 = day1 + hdiff;
        ddiff = day2 - day1;
        h1 = h2;
      } else if (h1 > h2) {
        day2 = day2 - hdiff;
        ddiff = day2 - day1;
        h2 = h1;
      }
      new_h = h1 + (ddiff / 2);
      max_h = max(max_h, new_h);
    }
  }
  cout << max_h << '\n';
  return 0;
}
