#include <bits/stdc++.h>
using namespace std;
int n, m;
inline bool comp(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first || (a.first == b.first && a.second > b.second))
    return 0;
  return 1;
}
vector<std::pair<int, int> > getrange(vector<std::pair<int, int> >& goable1,
                                      vector<std::pair<int, int> >& goable2) {
  vector<std::pair<int, int> > temp;
  vector<std::pair<int, int> >::iterator j = goable1.begin();
  for (vector<std::pair<int, int> >::iterator i = goable2.begin();
       i != goable2.end(); ++i) {
    for (; j != goable1.end() && j->first <= i->second; ++j) {
      if (j->second >= i->first) {
        if (j->first > i->first)
          temp.push_back(make_pair(j->first, i->second));
        else
          temp.push_back(make_pair(i->first, i->second));
        break;
      }
    }
  }
  goable2.clear();
  return temp;
}
int main() {
  vector<pair<int, int> > vol;
  cin >> n >> m;
  for (int x, y; m != 0; --m) {
    scanf("%d %d", &x, &y);
    vol.push_back(make_pair(x, y));
  }
  sort(vol.begin(), vol.end(), comp);
  vector<std::pair<int, int> > goable1, goable2;
  int ltd = vol.begin()->first;
  if (ltd == 1)
    goable1.push_back(make_pair(1, 1));
  else
    goable1.push_back(make_pair(1, n));
  vol.push_back(make_pair(n + 1, 1));
  if (vol.begin()->second != 1)
    goable2.push_back(make_pair(1, vol.begin()->second - 1));
  for (vector<std::pair<int, int> >::iterator i = vol.begin();
       i != vol.end() - 1; ++i) {
    int m = (i + 1)->first;
    if ((m == ltd && (i + 1)->second != (i->second + 1)))
      goable2.push_back(make_pair(i->second + 1, (i + 1)->second - 1));
    else if (m != ltd) {
      if (i->second != n) goable2.push_back(make_pair(i->second + 1, n));
      goable1 = getrange(goable1, goable2);
      if (m != ltd + 1) {
        vector<std::pair<int, int> > empty(1, make_pair(1, n));
        goable1 = getrange(goable1, empty);
      }
      if ((i + 1)->second != 1)
        goable2.push_back(make_pair(1, (i + 1)->second - 1));
      ltd = m;
    }
  }
  if (goable1.empty() || (goable1.end() - 1)->second < n)
    cout << -1 << endl;
  else
    cout << 2 * n - 2 << endl;
}
