#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100110;
const int INF = 1000000000;
const long long oo = (1LL << 40);
int n, m;
typedef struct {
  int x, y;
} Point;
Point p[MAXN];
vector<pair<int, int> > pr;
vector<pair<int, int> > cr;
bool cmp(const Point &a, const Point &b) {
  if (a.x != b.x)
    return a.x < b.x;
  else
    return a.y < b.y;
}
int can_reach(int l, int r) {
  int low = 0, high = pr.size() - 1;
  if (pr.size() == 0) return false;
  int ret = 0;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (pr[mid].second >= l) {
      ret = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  if (pr[ret].first <= r && pr[ret].second >= l) {
    return max(pr[ret].first, l);
  }
  return 0;
}
void print_range(int row) {
  int sz = cr.size();
  cout << "row = " << row << endl;
  for (int i = 0; i < sz; i++)
    cout << "(" << cr[i].first << "," << cr[i].second << "), ";
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  while (cin >> n >> m) {
    for (int i = 0; i < m; i++) {
      cin >> p[i].x >> p[i].y;
    }
    sort(p, p + m, cmp);
    pr.clear();
    cr.clear();
    int pre_col = 1, pre_row = p[0].x;
    p[m].x = n + 1;
    if (p[0].x > 1) {
      pr.push_back(make_pair(1, n));
    } else {
      pr.push_back(make_pair(1, p[0].y - 1));
    }
    for (int i = 0; i <= m; i++) {
      int t;
      if (p[i].x == pre_row) {
        if (p[i].y != pre_col) {
          if (t = can_reach(pre_col, p[i].y - 1)) {
            cr.push_back(make_pair(t, p[i].y - 1));
          }
        }
        pre_col = p[i].y + 1;
      } else {
        if (pre_col <= n) {
          if (t = can_reach(pre_col, n)) {
            cr.push_back(make_pair(t, n));
          }
        }
        if (i == m) break;
        if (p[i].x != pre_row + 1) {
          if (cr.size() > 0) {
            int lmin = cr[0].first;
            cr.clear();
            cr.push_back(make_pair(lmin, n));
          }
        }
        pre_col = 1;
        pre_row = p[i].x;
        i--;
        pr = cr;
        cr.clear();
      }
    }
    if (p[m - 1].x != n && cr.size() > 0) {
      cout << 2 * n - 2 << endl;
    } else {
      if (cr.size() > 0 && cr[cr.size() - 1].second == n) {
        cout << 2 * n - 2 << endl;
      } else {
        cout << "-1" << endl;
      }
    }
  }
  return 0;
}
