#include <bits/stdc++.h>
using namespace std;
const int maxn = 100000 + 5;
struct state {
  int x, y;
  bool operator<(const state& rhs) const {
    if (y == rhs.y) return x < rhs.x;
    return y < rhs.y;
  }
} block[maxn], pre[maxn], cur[maxn];
int n, m;
bool judge() {
  int cnt = 1;
  pre[0].x = 1;
  if (block[0].y == 1)
    pre[0].y = 1;
  else
    pre[0].y = n;
  for (int i = 0; i < m; i++) {
    if (i && block[i].y != block[i - 1].y + 1) {
      cnt = 1;
      pre[0].y = n;
    }
    int k, tmp = 0, c = 0;
    for (k = i + 1; block[k].y == block[i].y; k++)
      ;
    k--;
    for (int j = i; j <= k; j++) {
      if (block[j].x > tmp + 1) {
        cur[c].x = tmp + 1;
        cur[c].y = block[j].x - 1;
        c++;
      }
      tmp = block[j].x;
    }
    if (n > tmp) {
      cur[c].x = tmp + 1;
      cur[c].y = n;
      c++;
    }
    int t = 0;
    for (int i = 0; i < cnt; i++) {
      while (cur[t].x <= pre[i].y && t < c) {
        if (cur[t].y >= pre[i].x) {
          cur[t].x = max(pre[i].x, cur[t].x);
        } else {
          cur[t].x = cur[t].y = -1;
        }
        t++;
      }
      if (t == c) break;
    }
    cnt = 0;
    for (int i = 0; i < t; i++)
      if (cur[i].x != -1 && cur[i].y != -1) {
        pre[cnt].x = cur[i].x;
        pre[cnt].y = cur[i].y;
        cnt++;
      }
    if (cnt == 0) return false;
    i = k;
  }
  if (block[m - 1].y != n) return true;
  if (pre[cnt - 1].y == n) return true;
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < m; i++) scanf("%d%d", &block[i].x, &block[i].y);
  sort(block, block + m);
  if (judge())
    printf("%d\n", 2 * n - 2);
  else
    printf("-1\n");
  return 0;
}
