#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
struct point {
  int x, y;
  int id;
  point(int _x, int _y, int i) : x(_x), y(_y), id(i) {}
};
bool cmp1(point A, point B) {
  if (A.x == B.x) return A.y < B.y;
  return A.x < B.x;
}
bool cmp2(point A, point B) {
  if (A.y == B.y) return A.x < B.x;
  return A.y < B.y;
}
bool cmpid(point A, point B) { return A.id < B.id; }
map<int, vector<int> > X_list;
map<int, vector<int> > Y_list;
vector<point> points;
int n, m;
queue<int> q;
int vis[MAXN];
int isBlock;
void push_y(int minx, int y) {
  for (int i = 0; i < Y_list[y].size(); i++) {
    int id = Y_list[y][i];
    if (points[id].x >= minx) {
      if ((points[id].x == 1 && y > 1) || (y == n && points[id].x != n)) {
        isBlock = 1;
        return;
      }
      if (!vis[id]) {
        q.push(id);
        vis[id] = 1;
      }
    }
  }
}
void push_x(int x, int mxy) {
  if (x <= 0) return;
  for (int i = 0; i < X_list[x].size(); i++) {
    int id = X_list[x][i];
    if (points[id].y <= mxy) {
      if ((x == 1 && points[id].y != 1) || (points[id].y == n && x != n)) {
        isBlock = 1;
        return;
      }
      if (!vis[id]) {
        q.push(id);
        vis[id] = 1;
      }
    }
  }
}
void compute() {
  memset(vis, 0, sizeof(vis));
  while (!q.empty()) q.pop();
  isBlock = 0;
  push_y(1, 1);
  push_x(n, n);
  while (!q.empty()) {
    int curid = q.front();
    q.pop();
    int x = points[curid].x, y = points[curid].y;
    push_y(x - 1, y + 1);
    push_x(x - 1, y + 1);
    if (isBlock == 1) break;
  }
  if (isBlock)
    cout << "-1" << endl;
  else
    cout << 2 * n - 2 << endl;
}
int main() {
  int tmp = 0;
  points.clear();
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    points.push_back(point(x, y, i));
    if (x == n && y == n) {
      tmp = 1;
    }
  }
  if (tmp == 1) {
    cout << "-1" << endl;
    return 0;
  }
  sort(points.begin(), points.end(), cmp2);
  for (int i = 0; i < m; i++) {
    int x = points[i].x;
    X_list[x].push_back(points[i].id);
  }
  sort(points.begin(), points.end(), cmp1);
  for (int i = 0; i < m; i++) {
    int y = points[i].y;
    Y_list[y].push_back(points[i].id);
  }
  sort(points.begin(), points.end(), cmpid);
  compute();
  return 0;
}
