#include <bits/stdc++.h>
using namespace std;
int n, m;
map<int, set<int> > yy;
map<int, set<int> > xx;
set<pair<int, int> > s, vis, start;
bool good(int x, int y) {
  if (x < 1 || x > n || y < 1 || y > n || s.find(make_pair(x, y)) == s.end() ||
      vis.find(make_pair(x, y)) != vis.end())
    return false;
  return true;
}
void dfs(int x, int y) {
  if (x == n || y == 1) {
    puts("-1");
    exit(0);
  }
  vis.insert(make_pair(x, y));
  for (int i = -1; i <= 1; i++) {
    for (int j = -1; j <= 1; j++) {
      if (i == 0 && j == 0 || !good(x + i, y + j)) continue;
      dfs(x + i, y + j);
    }
  }
  if (y > 1 && yy[y - 1].size() > 0) {
    for (auto it = yy[y - 1].begin(); it != yy[y - 1].end(); it++) {
      if (*it > x) break;
      if (good(*it, y - 1)) dfs(*it, y - 1);
    }
  }
  if (x < n && xx[x + 1].size() > 0) {
    for (auto it = xx[x + 1].rbegin(); it != xx[x + 1].rend(); it++) {
      if (*it < y) break;
      if (good(x + 1, *it)) dfs(x + 1, *it);
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  int x, y;
  for (int i = 0; i < m; i++) {
    scanf("%d%d", &x, &y);
    if (x == 1 || y == n) start.insert(make_pair(x, y));
    xx[x].insert(y);
    yy[y].insert(x);
    s.insert(make_pair(x, y));
  }
  for (auto it = start.begin(); it != start.end(); it++)
    if (good(it->first, it->second)) dfs(it->first, it->second);
  printf("%d", n + n - 2);
  return 0;
}
