#include <bits/stdc++.h>
using namespace std;
struct Tpoint {
  int x, y;
} p[200050], e, f;
struct node {
  int l, r;
} cur[200050], s[200050];
bool cmp(Tpoint a, Tpoint b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
int n, m;
bool gao() {
  int tail, i, j, k;
  scanf("%d%d", &n, &m);
  for (i = 0; i < m; i++) scanf("%d%d", &p[i].x, &p[i].y);
  sort(p, p + m, cmp);
  s[0].l = 1;
  if (p[0].x == 1)
    s[0].r = p[0].y - 1;
  else
    s[0].r = n;
  tail = 1;
  for (i = 0; i < m; i++) {
    if (i != 0 && p[i].x != p[i - 1].x + 1) {
      s[0].r = n;
      tail = 1;
    }
    for (k = i; p[k].x == p[i].x && k < m; k++)
      ;
    k--;
    int cnt = 0, tmp = 0;
    for (j = i; j <= k; j++) {
      if (p[j].y - 1 < tmp + 1) {
        tmp = p[j].y;
        continue;
      }
      cur[cnt].l = tmp + 1;
      cur[cnt].r = p[j].y - 1;
      tmp = p[j].y;
      cnt++;
    }
    if (tmp != n) {
      cur[cnt].l = tmp + 1;
      cur[cnt].r = n;
      cnt++;
    }
    int now = 0;
    for (j = 0; j < tail; j++) {
      for (; now < cnt; now++) {
        if (cur[now].l > s[j].r) break;
        if (cur[now].r < s[j].l) {
          cur[now].l = cur[now].r = -1;
          continue;
        }
        if (cur[now].l < s[j].l) {
          cur[now].l = s[j].l;
        }
      }
    }
    while (now < cnt) {
      cur[now].l = cur[now].r = -1;
      now++;
    }
    tail = 0;
    for (j = 0; j < cnt; j++) {
      if (cur[j].l != -1) {
        s[tail].l = cur[j].l;
        s[tail++].r = cur[j].r;
      }
    }
    i = k;
    if (tail == 0) return false;
  }
  if (p[m - 1].x != n) return true;
  if (s[tail - 1].r == n) return true;
  return false;
}
int main() {
  if (gao())
    printf("%d\n", (n - 1) * 2);
  else
    printf("-1\n");
}
