Iahub got lost in a very big desert. The desert can be represented as a n × n square matrix, where each cell is a zone of the desert. The cell (i, j) represents the cell at row i and column j (1 ≤ i, j ≤ n). Iahub can go from one cell (i, j) only down or right, that is to cells (i + 1, j) or (i, j + 1). 

Also, there are m cells that are occupied by volcanoes, which Iahub cannot enter. 

Iahub is initially at cell (1, 1) and he needs to travel to cell (n, n). Knowing that Iahub needs 1 second to travel from one cell to another, find the minimum time in which he can arrive in cell (n, n).

Input

The first line contains two integers n (1 ≤ n ≤ 109) and m (1 ≤ m ≤ 105). Each of the next m lines contains a pair of integers, x and y (1 ≤ x, y ≤ n), representing the coordinates of the volcanoes.

Consider matrix rows are numbered from 1 to n from top to bottom, and matrix columns are numbered from 1 to n from left to right. There is no volcano in cell (1, 1). No two volcanoes occupy the same location. 

Output

Print one integer, the minimum time in which Iahub can arrive at cell (n, n). If no solution exists (there is no path to the final cell), print -1.

Examples

Input

4 2
1 3
1 4


Output

6


Input

7 8
1 6
2 6
3 5
3 6
4 3
5 1
5 2
5 3


Output

12


Input

2 2
1 2
2 1


Output

-1

Note

Consider the first sample. A possible road is: (1, 1) →  (1, 2) →  (2, 2) →  (2, 3) →  (3, 3) →  (3, 4) →  (4, 4).
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;


public class B {

    static StringTokenizer st;
    static BufferedReader br;
    static PrintWriter pw;
    static class Sort implements Comparable<Sort> {
        int x, y;
        public int compareTo(Sort arg0) {
            if (this.x+this.y > arg0.x+arg0.y)
                return 1;
            if (this.x+this.y < arg0.x+arg0.y)
                return -1;
            if (this.y > arg0.y)
                return 1;
            if (this.y < arg0.y)
                return -1;
            return 0;
        }
    }
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        int n = nextInt();
        int m = nextInt();
        int[]x = new int[m+2], y = new int[m+2];
        Sort[]a = new Sort[m+2];
        for (int i = 1; i <= m; i++) {
            a[i] = new Sort();
            a[i].x = nextInt();
            a[i].y = nextInt();
        }
        Arrays.sort(a, 1, m+1);
        for (int i = 1; i <= m; i++) {
            x[i] = a[i].x;
            y[i] = a[i].y;
            if (x[i]==n && y[i]==n) {
                System.out.println(-1);
                return;
            }
        }
        m++;
        a[m] = new Sort();
        a[m].x = n;
        a[m].y = n;
        int begin = 1;
        int[]x1 = new int[2*m+10], y1 = new int[2*m+10];
        int[]x2 = new int[2*m+10], y2 = new int[2*m+10];
        int[]x1_new = new int[2*m+10], y1_new = new int[2*m+10];
        int[]x2_new = new int[2*m+10], y2_new = new int[2*m+10];
        int cnt = 1;
        x1[1] = x2[1] = 1;
        y1[1] = y2[1] = 1;
        for (int i = 2; i <= m; i++) {
            if (x[i]+y[i] != x[i-1]+y[i-1]) {
                int curd = x[begin]+y[begin];
                int cntnew = 0;
                for (int j = 1; j <= cnt; j++) {
                    cntnew++;
                    x1_new[cntnew] = curd-y1[j];
                    y1_new[cntnew] = y1[j];
                    x2_new[cntnew] = x2[j];
                    y2_new[cntnew] = curd-x2[j];
                    if (cntnew != 1 && y1_new[cntnew] <= y2_new[cntnew-1]+1) {
                        cntnew--;
                        x2_new[cntnew] = x2[j];
                        y2_new[cntnew] = curd-x2[j];
                    }
                }
                cnt = 0;
                int ind = begin;
                int lastx = 1, lasty = 1;
                for (int j = 1; j <= cntnew; j++) {
                    lastx = x1_new[j];
                    lasty = y1_new[j];
                    while (ind < i && y[ind] < y1_new[j])
                        ind++;
                    while (ind < i && y[ind] <= y2_new[j]) {
                        if (y[ind]-1 >= lasty) {
                            cnt++;
                            x1[cnt] = lastx;
                            y1[cnt] = lasty;
                            x2[cnt] = x[ind]+1;
                            y2[cnt] = y[ind]-1;
                        }
                        lastx = x[ind]-1;
                        lasty = y[ind]+1;
                        ind++;
                    }
                    if (y2_new[j] >= lasty) {
                        cnt++;
                        x1[cnt] = lastx;
                        y1[cnt] = lasty;
                        x2[cnt] = x2_new[j];
                        y2[cnt] = y2_new[j];
                    }
                }
                begin = i;
            }
        }
        int ans = -1;
        for (int i = 1; i <= cnt; i++) {
            int x11 = 2*n-y1[i], y11 = y1[i], x22 = x2[i], y22 = 2*n-x2[i];
            if (x11 >= n && x22 <= n && y11 <= n && y22 >= n) {
                ans = 2*n-2;
            }
        }
        System.out.println(ans);
        pw.close();
    }
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
    private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
    private static String next() throws IOException {
        while (st==null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}
