#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x, y;
  Point(int u = 0, int v = 0) : x(u), y(v) {}
  bool operator<(const Point &p) const {
    if (x == p.x) return y < p.y;
    return x < p.x;
  }
};
int g_n, g_pn;
vector<Point> vp_in;
map<int, vector<int>> mivi_x;
map<int, vector<int>> mivi_y;
map<Point, bool> mpb_mark;
queue<Point> qp;
bool input() {
  cin >> g_n >> g_pn;
  if (cin.eof()) return false;
  vp_in.clear();
  mivi_x.clear();
  mivi_y.clear();
  mpb_mark.clear();
  while (!qp.empty()) qp.pop();
  Point p;
  for (int i = 0; i < g_pn; ++i) {
    scanf("%d%d", &p.x, &p.y);
    vp_in.push_back(p);
    mivi_x[p.x].push_back(p.y);
    mivi_y[p.y].push_back(p.x);
    if (p.x == 1) {
      qp.push(p);
      mpb_mark[p] = true;
    }
    if (p.y == g_n) {
      qp.push(p);
      mpb_mark[p] = true;
    }
  }
  return true;
}
void solve() {
  bool f = false;
  for (auto &m : mivi_x) sort(m.second.begin(), m.second.end());
  for (auto &m : mivi_y) sort(m.second.begin(), m.second.end());
  while (!qp.empty()) {
    Point p = qp.front();
    qp.pop();
    mpb_mark[p] = true;
    if (p.x == g_n || p.y == 1) {
      f = true;
      break;
    }
    auto mivit_x = mivi_x.find(p.x + 1);
    if (mivit_x != mivi_x.end()) {
      auto &vy = mivit_x->second;
      for (int i = vy.size() - 1; i >= 0; --i) {
        if (vy[i] < p.y - 1) break;
        auto tp = Point(p.x + 1, vy[i]);
        if (!mpb_mark[tp]) {
          mpb_mark[tp] = true;
          qp.push(tp);
        }
      }
    }
    auto mivit_y = mivi_y.find(p.y - 1);
    if (mivit_y != mivi_y.end()) {
      auto &vx = mivit_y->second;
      for (int i = 0; i < vx.size(); ++i) {
        if (vx[i] > p.x + 1) break;
        auto tp = Point(vx[i], p.y - 1);
        if (!mpb_mark[tp]) {
          mpb_mark[tp] = true;
          qp.push(tp);
        }
      }
    }
  }
  if (!f)
    printf("%d\n", 2 * g_n - 2);
  else
    puts("-1");
}
int main() {
  while (input()) {
    solve();
  }
  return 0;
}
