#include <bits/stdc++.h>
using namespace std;
int node[100005][2];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) scanf("%d%d", &node[i][0], &node[i][1]);
  int ans = node[0][1] + node[0][0] - 1;
  bool flag = 0;
  for (int i = 1; i < m; i++) {
    int d_val = node[i][0] - node[i - 1][0];
    if (abs(node[i][1] - node[i - 1][1]) > d_val) {
      flag = 1;
      break;
    }
    ans = max(ans, node[i][1]);
    ans = max(ans, max(node[i][1], node[i - 1][1]) +
                       (d_val - abs(node[i][1] - node[i - 1][1])) / 2);
  }
  int syday = n - node[m - 1][0];
  ans = max(ans, node[m - 1][1] + syday);
  if (flag)
    cout << "IMPOSSIBLE" << endl;
  else
    cout << ans << endl;
  return 0;
}
