#include <bits/stdc++.h>
struct coor {
  int x, y;
  bool operator<(const coor &l) const {
    if (x != l.x) return x < l.x;
    return y < l.y;
  }
};
bool comp0(coor x, coor y) {
  if (x.x != y.x) return x.x < y.x;
  return x.y < y.y;
}
bool comp1(coor x, coor y) {
  if (x.y != y.y) return x.y < y.y;
  return x.x < y.x;
}
int n, m;
int f, r;
coor data[2][100005];
coor que[100005];
std::set<coor> check;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &data[0][i].x, &data[0][i].y);
    data[1][i] = data[0][i];
    if (data[0][i].x == 1 || data[0][i].y == n) {
      que[f++] = data[0][i];
      check.insert(data[0][i]);
    }
  }
  std::sort(data[0] + 1, data[0] + m + 1, comp0);
  std::sort(data[1] + 1, data[1] + m + 1, comp1);
  while (f != r) {
    if (que[r].x == n || que[r].y == 1) {
      printf("-1");
      return 0;
    }
    coor tmp = que[r];
    tmp.x++;
    tmp.y--;
    int ad =
        std::lower_bound(data[0] + 1, data[0] + m + 1, tmp, comp0) - data[0];
    if (data[0][ad].x == tmp.x && check.find(data[0][ad]) == check.end()) {
      que[f++] = data[0][ad];
      check.insert(data[0][ad]);
    }
    ad = std::upper_bound(data[1] + 1, data[1] + m + 1, tmp, comp1) - data[1] -
         1;
    if (data[1][ad].y == tmp.y && check.find(data[1][ad]) == check.end()) {
      que[f++] = data[1][ad];
      check.insert(data[1][ad]);
    }
    tmp = que[r];
    ad = std::lower_bound(data[0] + 1, data[0] + m + 1, tmp, comp0) - data[0];
    if (data[0][ad].x == tmp.x && check.find(data[0][ad]) == check.end()) {
      que[f++] = data[0][ad];
      check.insert(data[0][ad]);
    }
    ad = std::upper_bound(data[1] + 1, data[1] + m + 1, tmp, comp1) - data[1] -
         1;
    if (data[1][ad].y == tmp.y && check.find(data[1][ad]) == check.end()) {
      que[f++] = data[1][ad];
      check.insert(data[1][ad]);
    }
    r++;
  }
  printf("%d", n * 2 - 2);
  return 0;
}
