#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128777216")
const int null = 0;
using namespace std;
template <class T>
int size(const T &a) {
  return int(a.size());
}
template <class T>
T abs(const T &a) {
  return (a < 0 ? -a : a);
}
template <class T>
T sqr(const T &a) {
  return a * a;
}
const double pi = acos(-1.0);
const int max_n = 100010;
struct Point {
  int r, c;
  void scan() {
    scanf("%d %d", &r, &c);
    r--, c--;
  }
  inline int dig() const { return r + c; }
  bool operator<(const Point &p) const {
    return dig() < p.dig() || dig() == p.dig() && c < p.c;
  }
} a[max_n];
struct Segment {
  int l, r;
  void init(int l, int r) {
    this->l = l;
    this->r = r;
  }
  void extend(int a, int ml, int mr) {
    r += a;
    l = max(l, ml);
    r = min(r, mr);
  }
} s[2][max_n];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    a[i].scan();
  }
  sort(a, a + m);
  int u = 1;
  Segment *cur = s[0], *next = s[1];
  cur[0].init(0, 0);
  int d = 0;
  for (int i = 0; i < m;) {
    int j = i + 1;
    while (j < n && a[j].dig() == a[i].dig()) {
      j++;
    }
    int e = a[i].dig() - d;
    d = a[i].dig();
    int l = max(0, d - (n - 1));
    int r = min((n - 1), d);
    for (int k = 0; k < u; k++) {
      cur[k].extend(e, l, r);
    }
    int nu = 0;
    for (int k = 0; k < u;) {
      int l = cur[k].l;
      int r = cur[k].r;
      k++;
      while (k < u && r >= cur[k].l - 1) {
        r = cur[k].r;
        k++;
      }
      while (i < j && a[i].c < l) {
        i++;
      }
      while (i < j && l <= r && a[i].c <= r) {
        if (a[i].c > l) {
          next[nu++].init(l, a[i].c - 1);
        }
        l = a[i].c + 1;
        i++;
      }
      if (l <= r) {
        next[nu++].init(l, r);
      }
    }
    swap(next, cur);
    u = nu;
    i = j;
  }
  if (u) {
    cout << n + n - 2 << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
