#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static const long long L = 233333;
  static char sxd[L], *sss = sxd, *ttt = sxd;
  if (sss == ttt) {
    ttt = (sss = sxd) + fread(sxd, 1, L, stdin);
    if (sss == ttt) {
      return EOF;
    }
  }
  return *sss++;
}
inline char readalpha() {
  char c = getchar();
  for (; !isalpha(c); c = getchar())
    ;
  return c;
}
inline char readchar() {
  char c = getchar();
  for (; c == ' '; c = getchar())
    ;
  return c;
}
template <class T>
inline bool read(T& x) {
  bool flg = false;
  char c = getchar();
  x = 0;
  for (; !isdigit(c); c = getchar()) {
    if (c == '-') {
      flg = true;
    } else if (c == EOF) {
      return false;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = (x << 1) + (x << 3) + (c ^ 48);
  }
  if (flg) {
    x = -x;
  }
  return true;
}
template <class T>
inline void write(T x) {
  if (x < 0) {
    putchar('-');
    x = -x;
  }
  if (x < 10) {
    putchar(x | 48);
    return;
  }
  write(x / 10);
  putchar((x % 10) | 48);
}
const int maxn = 100005;
int dirx[] = {0, 0, -1, -1, -1, 1, 1, 1};
int diry[] = {1, -1, 0, -1, 1, 0, -1, 1};
int n, m;
map<int, map<int, int> > mp, mp2;
struct Node {
  int x, y;
} no[maxn];
bool vis[maxn];
int main() {
  read(n), read(m);
  queue<int> q;
  for (int i = 1; i <= m; ++i) {
    read(no[i].x);
    read(no[i].y);
    mp[no[i].x][no[i].y] = i;
    mp2[no[i].y][no[i].x] = i;
    if (no[i].x == n || no[i].y == 1) {
      q.push(i);
      vis[i] = true;
    }
  }
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    if (no[now].x == 1 || no[now].y == n) {
      puts("-1");
      return 0;
    }
    for (int i = 0; i < 8; ++i) {
      int xx = no[now].x + dirx[i];
      int yy = no[now].y + diry[i];
      if (mp.count(xx) && mp[xx].count(yy) && !vis[mp[xx][yy]]) {
        q.push(mp[xx][yy]);
        vis[mp[xx][yy]] = true;
      }
    }
    if (mp.count(no[now].x - 1) && !mp[no[now].x - 1].empty()) {
      auto xx = mp[no[now].x - 1].upper_bound(no[now].y + 1);
      if (xx != mp[no[now].x - 1].begin() && !vis[(--xx)->second]) {
        q.push(xx->second);
        vis[xx->second] = true;
      }
    }
    if (mp2.count(no[now].y + 1) && !mp2[no[now].y + 1].empty()) {
      auto xx = mp2[no[now].y + 1].lower_bound(no[now].x - 1);
      if (xx != mp2[no[now].y + 1].end() && !vis[xx->second]) {
        q.push(xx->second);
        vis[xx->second] = true;
      }
    }
  }
  printf("%d\n", (n - 1) << 1);
  return 0;
}
