#include <bits/stdc++.h>
using namespace std;
struct block {
  int x, y;
  inline bool operator<(const block &cpr) const {
    if (x != cpr.x) return x < cpr.x;
    return y < cpr.y;
  }
  inline bool operator==(const block &cpr) const {
    return ((x == cpr.x) && (y == cpr.y));
  }
};
struct nblock {
  int x, y, id;
  inline bool operator<(const nblock &cpr) const {
    if (y != cpr.y) return y < cpr.y;
    return x < cpr.x;
  }
};
block bl[100005];
nblock nbl[100005];
int vis[100005];
int n, m;
queue<int> pq;
int mov[8][2]{
    1, 1, 1, 0, 1, -1, 0, -1, 0, 1, -1, 1, -1, 0, -1, -1,
};
int main() {
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= m; i++) scanf("%d%d", &bl[i].x, &bl[i].y);
  sort(bl + 1, bl + 1 + m);
  for (int i = 1; i <= m; i++) {
    nbl[i].x = bl[i].x;
    nbl[i].y = bl[i].y;
    nbl[i].id = i;
  }
  sort(nbl + 1, nbl + 1 + m);
  for (int i = 1; i <= m; i++)
    if (bl[i].x == n || bl[i].y == 1) {
      vis[i] = 1;
      pq.push(i);
    }
  while (pq.size()) {
    block cur;
    int cid;
    cid = pq.front();
    cur = bl[cid];
    pq.pop();
    if (cur.x > 1) {
      block nw;
      nw = cur;
      nw.x--;
      int top, bot, tr;
      top = m;
      bot = 1;
      while (top > bot) {
        tr = (top + bot + 1) / 2;
        if (bl[tr] < nw)
          bot = tr;
        else
          top = tr - 1;
      }
      if (bl[top].x == nw.x)
        if (bl[top].y < nw.y)
          if (vis[top] == 0) {
            vis[top] = 1;
            pq.push(top);
          }
    }
    if (cur.y < n) {
      nblock nw;
      nw.x = cur.x;
      nw.y = cur.y + 1;
      int top, bot, tr;
      top = m;
      bot = 1;
      while (top > bot) {
        tr = (top + bot) / 2;
        if (nw < nbl[tr])
          top = tr;
        else
          bot = tr + 1;
      }
      if (nbl[top].y == nw.y)
        if (nbl[top].x > nw.x)
          if (vis[nbl[top].id] == 0) {
            vis[nbl[top].id] = 1;
            pq.push(nbl[top].id);
          }
    }
    for (int dr = 0; dr < 8; dr++) {
      block nw;
      nw = cur;
      nw.x += mov[dr][0];
      nw.y += mov[dr][1];
      int top, bot, tr;
      top = m;
      bot = 1;
      while (top > bot) {
        tr = (top + bot + 1) / 2;
        if (nw < bl[tr])
          top = tr - 1;
        else
          bot = tr;
      }
      if (nw == bl[top])
        if (vis[top] == 0) {
          vis[top] = 1;
          pq.push(top);
        }
    }
  }
  for (int i = 1; i <= m; i++)
    if (vis[i] == 1)
      if (bl[i].x == 1 || bl[i].y == n) {
        printf("-1\n");
        return 0;
      }
  printf("%d\n", 2 * (n - 1));
}
