#include <bits/stdc++.h>
using namespace std;
vector<int> d;
vector<int> hd;
string numbers[] = {
    "zero",        "one",        "two",          "three",        "four",
    "five",        "six",        "seven",        "eight",        "nine",
    "ten",         "eleven",     "twelve",       "thirteen",     "fourteen",
    "fifteen",     "sixteen",    "seventeen",    "eighteen",     "nineteen",
    "twenty",      "twenty one", "twenty two",   "twenty three", "twenty four",
    "twenty five", "twenty six", "twenty seven", "twenty eight", "twenty nine"};
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int dd, hdd;
    cin >> dd >> hdd;
    d.push_back(dd);
    hd.push_back(hdd);
  }
  if (d[0] != 1) {
    int mm = d[0] - 1 + hd[0];
    d.insert(d.begin(), 1);
    hd.insert(hd.begin(), mm);
  }
  int maxh = hd[0];
  for (int i = 1; i < d.size(); i++) {
    if (d[i] - d[i - 1] < abs(hd[i] - hd[i - 1])) {
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
    int tempmax =
        max(hd[i], hd[i - 1]) + (d[i] - d[i - 1] - abs(hd[i] - hd[i - 1])) / 2;
    if (tempmax > maxh) maxh = tempmax;
  }
  cout << max(maxh, hd[hd.size() - 1] + (n - d[d.size() - 1])) << endl;
  return 0;
}
