#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) {
  if (a == 0 || b == 0) return a + b;
  return a * (b / gcd(a, b));
}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
int ddx[] = {0, 0, 1, 1, 1, -1, -1, -1}, ddy[] = {1, -1, 1, 0, -1, 1, 0, -1};
int n, m;
pair<int, int> p[100000], q[100000];
bool chk[100000];
bool cmp(pair<int, int> p1, pair<int, int> p2) {
  if (p1.second != p2.second) return p1.second < p2.second;
  return p1.first < p2.first;
}
int find(int x, int y) {
  int r = lower_bound(p, p + m, make_pair(x, y)) - p;
  if (r == m || p[r] != make_pair(x, y)) return -1;
  return r;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int(i) = (0); (i) <= (m - 1); (i) += (1)) {
    scanf("%d%d", &p[i].first, &p[i].second);
    q[i] = p[i];
  }
  sort(p, p + m);
  sort(q, q + m, cmp);
  queue<int> Q;
  for (int(i) = (0); (i) <= (m - 1); (i) += (1)) {
    if (p[i].first == n || p[i].second == 1) {
      Q.push(i);
      chk[i] = 1;
    }
  }
  while (!Q.empty()) {
    int t = Q.front();
    Q.pop();
    if (p[t].first == 1 || p[t].second == n) return !printf("-1");
    for (int(i) = (-1); (i) <= (1); (i) += (1))
      for (int(j) = (-1); (j) <= (1); (j) += (1)) {
        if (i == 0 && j == 0) continue;
        int tt = find(p[t].first + i, p[t].second + j);
        if (tt != -1 && !chk[tt]) {
          chk[tt] = 1;
          Q.push(tt);
        }
      }
    int tt = upper_bound(p, p + m, make_pair(p[t].first - 1, p[t].second - 1)) -
             p - 1;
    if (tt == m)
      tt = -1;
    else if (p[tt].first != p[t].first - 1)
      tt = -1;
    if (tt != -1 && !chk[tt]) {
      Q.push(tt);
      chk[tt] = 1;
    }
    tt =
        lower_bound(q, q + m, make_pair(p[t].first + 1, p[t].second + 1), cmp) -
        q;
    if (tt == m)
      tt = -1;
    else {
      int y = q[tt].second;
      tt = lower_bound(p, p + m, make_pair(q[tt].first, q[tt].second)) - p;
      if (p[tt].second != p[t].second + 1) tt = -1;
    }
    if (tt != -1 && !chk[tt]) {
      Q.push(tt);
      chk[tt] = 1;
    }
  }
  printf("%d", 2 * n - 2);
}
