#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > last, now, volcano;
int lastcol, top, bot;
int n, m;
int comp(pair<int, int> l, pair<int, int> r) {
  if (l.second == r.second) return l.first < r.first;
  return l.second < r.second;
}
int main() {
  cin >> n >> m;
  volcano.clear();
  for (int i = 1; i <= m; i++) {
    int x, y;
    cin >> x >> y;
    volcano.push_back(pair<int, int>(x, y));
  }
  sort(volcano.begin(), volcano.end(), comp);
  last.clear();
  now.clear();
  lastcol = 0;
  top = 1;
  bot = n;
  now.push_back(pair<int, int>(1, 1));
  int j, ok;
  ok = 1;
  j = 0;
  for (int i = 0; i < m; i++) {
    if (volcano[i].second > lastcol) {
      if (i > 0) {
        now.push_back(pair<int, int>(volcano[i - 1].first + 1, n));
        if (now.back().second < now.back().first)
          now.pop_back();
        else {
          while (j < last.size() && last[j].second < now.back().first) j++;
          if (j == last.size())
            now.pop_back();
          else
            now.back().first = max(last[j].first, now.back().first);
          if (!now.empty() && now.back().second < now.back().first)
            now.pop_back();
        }
      }
      swap(last, now);
      j = 0;
      if (last.empty()) {
        ok = 0;
        break;
      }
      top = last[0].first;
      if (volcano[i].second > lastcol + 1) {
        last.clear();
        last.push_back(pair<int, int>(top, bot));
      }
      now.clear();
    }
    if (lastcol < volcano[i].second) {
      lastcol = volcano[i].second;
      now.push_back(pair<int, int>(top, volcano[i].first - 1));
    } else {
      now.push_back(
          pair<int, int>(volcano[i - 1].first + 1, volcano[i].first - 1));
    }
    if (now.back().second < now.back().first)
      now.pop_back();
    else {
      while (j < last.size() && last[j].second < now.back().first) j++;
      if (j == last.size())
        now.pop_back();
      else
        now.back().first = max(last[j].first, now.back().first);
      if (!now.empty() && now.back().second < now.back().first) now.pop_back();
    }
  }
  now.push_back(pair<int, int>(volcano.back().first + 1, n));
  if (now.back().second < now.back().first)
    now.pop_back();
  else {
    while (j < last.size() && last[j].second < now.back().first) j++;
    if (j == last.size())
      now.pop_back();
    else
      now.back().first = max(last[j].first, now.back().first);
    if (!now.empty() && now.back().second < now.back().first) now.pop_back();
  }
  if (now.empty() || (volcano.back().second == n && now.back().second < n))
    ok = 0;
  if (ok)
    cout << n * 2 - 2;
  else
    cout << -1;
  return 0;
}
