#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1.01e9;
const long double EPS = 1e-9;
void precalc() {}
int n, m;
struct Segment {
  int x, y;
  Segment() {}
  Segment(int _x, int _y) : x(_x), y(_y) {}
  inline bool operator<(const Segment &s) const { return y > s.y; }
};
const int maxm = (int)1e5 + 10;
Segment segm0[maxm];
bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return 0;
  }
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    segm0[i] = Segment(x, y);
  }
  return 1;
}
bool pointComp(const Segment &s1, const Segment &s2) {
  if (s1.x + s1.y != s2.x + s2.y) {
    return s1.x + s1.y < s2.x + s2.y;
  }
  return s1 < s2;
}
Segment blocked[maxm];
Segment nblocked[maxm];
void solve() {
  sort(segm0, segm0 + m, pointComp);
  int cnt = 0;
  blocked[cnt++] = Segment(0, n);
  blocked[cnt++] = Segment(n, 0);
  for (int i = 0; i < m;) {
    int i0 = i;
    int nxy = segm0[i0].x + segm0[i0].y;
    while (i < m && segm0[i].x + segm0[i].y == nxy) {
      ++i;
    }
    int cnt0 = 0;
    for (int i = 0; i < cnt; ++i) {
      if (blocked[i].x + blocked[i].y < nxy) {
        continue;
      }
      nblocked[cnt0++] = blocked[i];
    }
    cnt = 0;
    for (int y = 0, j = i0; y < cnt0 || j < i;) {
      Segment cur;
      if (y == cnt0 || (j < i && segm0[j] < nblocked[y])) {
        cur = segm0[j++];
      } else {
        cur = nblocked[y++];
      }
      if (cnt && blocked[cnt - 1].x + 1 >= nxy - cur.y) {
        blocked[cnt - 1].x = max(blocked[cnt - 1].x, cur.x);
        blocked[cnt - 1].y = max(blocked[cnt - 1].y, cur.y);
      } else {
        blocked[cnt++] = cur;
      }
    }
  }
  bool ok = 1;
  for (int i = 0; i < cnt; ++i) {
    if (blocked[i].x == n && blocked[i].y == n) {
      ok = 0;
    }
  }
  if (ok) {
    printf("%d\n", 2 * n - 2);
  } else {
    printf("-1\n");
  }
}
int main() {
  srand(rdtsc());
  precalc();
  while (1) {
    if (!read()) {
      break;
    }
    solve();
  }
  return 0;
}
