Yura has been walking for some time already and is planning to return home. He needs to get home as fast as possible. To do this, Yura can use the instant-movement locations around the city.

Let's represent the city as an area of $n \times n$ square blocks. Yura needs to move from the block with coordinates $(s_x,s_y)$ to the block with coordinates $(f_x,f_y)$. In one minute Yura can move to any neighboring by side block; in other words, he can move in four directions. Also, there are $m$ instant-movement locations in the city. Their coordinates are known to you and Yura. Yura can move to an instant-movement location in no time if he is located in a block with the same coordinate $x$ or with the same coordinate $y$ as the location.

Help Yura to find the smallest time needed to get home.


-----Input-----

The first line contains two integers $n$ and $m$ — the size of the city and the number of instant-movement locations ($1 \le n \le 10^9$, $0 \le m \le 10^5$).

The next line contains four integers $s_x$ $s_y$ $f_x$ $f_y$ — the coordinates of Yura's initial position and the coordinates of his home ($ 1 \le s_x, s_y, f_x, f_y \le n$).

Each of the next $m$ lines contains two integers $x_i$ $y_i$ — coordinates of the $i$-th instant-movement location ($1 \le x_i, y_i \le n$).


-----Output-----

In the only line print the minimum time required to get home.


-----Examples-----
Input
5 3
1 1 5 5
1 2
4 1
3 3

Output
5

Input
84 5
67 59 41 2
39 56
7 2
15 3
74 18
22 7

Output
42



-----Note-----

In the first example Yura needs to reach $(5, 5)$ from $(1, 1)$. He can do that in $5$ minutes by first using the second instant-movement location (because its $y$ coordinate is equal to Yura's $y$ coordinate), and then walking $(4, 1) \to (4, 2) \to (4, 3) \to (5, 3) \to (5, 4) \to (5, 5)$.

Difficulty: interview

Starter code:

Solutions:
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

import heapq as hq
import math

def dijkstra(G, s):
    n = len(G)
    visited = [False]*n
    weights = [math.inf]*n
    path = [None]*n
    queue = []
    weights[s] = 0
    hq.heappush(queue, (0, s))
    while len(queue) > 0:
        g, u = hq.heappop(queue)
        visited[u] = True
        for v, w in G[u]:
            if not visited[v]:
                f = g + w
                if f < weights[v]:
                    weights[v] = f
                    path[v] = u
                    hq.heappush(queue, (f, v))
    return path, weights


def solve(grid,sx,sy,ex,ey):  # fix inputs here
    console("----- solving ------")
    # console(grid,sx,sy,ex,ey)

    minres = abs(sx-ex) + abs(sy-ey)
    console(minres)
    if grid == []:
        return minres

    d = defaultdict(list)
    grid = [(i,x,y) for i,(x,y) in enumerate(grid)]

    # x-order
    grid = sorted(grid, key=lambda x: x[1])
    for (i1,x1,y1),(i2,x2,y2) in zip(grid, grid[1:]):
        d[i1].append((i2,x2-x1))
        d[i2].append((i1,x2-x1))

    grid = sorted(grid, key=lambda x: x[2])
    for (i1,x1,y1),(i2,x2,y2) in zip(grid, grid[1:]):
        d[i1].append((i2,y2-y1))
        d[i2].append((i1,y2-y1))

    for i,x,y in grid:
        # start to x-axis
        d[-2].append((i,abs(x-sx)))

        # start to y-axis
        d[-2].append((i,abs(y-sy)))

        # point to destination
        d[i].append((-1, abs(x-ex) + abs(y-ey)))

    d[-1] = []
    console(list(d.keys()))

    idxs = {k:i for i,k in enumerate(d.keys())}
    G = [[] for _ in range(len(idxs))]

    for e,vrr in list(d.items()):
        for v,cost in vrr:
            G[idxs[e]].append((idxs[v],cost))
    # console(G)

    _,costs = dijkstra(G, idxs[-2])
    

    res = costs[idxs[-1]]

    return min(minres, res)


def console(*args):  # the judge will not read these print statement
    # print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
inp = sys.stdin.readlines()
for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    # k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    _, nrows = list(map(int,inp[0].split()))
    sx,sy,ex,ey = list(map(int,inp[1].split()))

    currow = 2
    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    grid = []
    for _ in range(nrows):
        grid.append(list(map(int,inp[currow].split())))
        currow += 1

    res = solve(grid,sx,sy,ex,ey)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


# V: 頂点数
# g[v] = {(w, cost)}:
#     頂点vから遷移可能な頂点(w)とそのコスト(cost)
# r: 始点の頂点

from heapq import heappush, heappop
import sys;input=sys.stdin.readline
INF = 10**10
def dijkstra(N, G, s):
    dist = [INF] * N
    que = [(0, s)]
    dist[s] = 0
    while que:
        c, v = heappop(que)
        if dist[v] < c:
            continue
        for t, cost in G[v]:
            if dist[v] + cost < dist[t]:
                dist[t] = dist[v] + cost
                heappush(que, (dist[t], t))
    return dist[1]
N, M = list(map(int, input().split()))
sx, sy, fx, fy = list(map(int, input().split()))
vs = []
g = [set() for _ in range(M+2)]
for i in range(M):
    x, y = list(map(int, input().split()))
    g[0].add((i+2, min(abs(x-sx), abs(y-sy))))
    g[i+2].add((1, abs(x-fx)+abs(y-fy)))
    vs.append((i+2, x, y))

#tg = [dict() for _ in range(M+2)]
vs.sort(key=lambda x:(x[1],x[2]))
for (b, bx, by), (i, x, y) in zip(vs, vs[1:]):
    c = min(x-bx, abs(y-by))
    g[i].add((b, c))
    g[b].add((i, c))

vs.sort(key=lambda x:(x[2],x[1]))
for (b, bx, by), (i, x, y) in zip(vs, vs[1:]):
    c = min(abs(x-bx), y-by)
    g[i].add((b, c))
    g[b].add((i, c))

#print(g)
print(min(dijkstra(M+2, g, 0), abs(fy-sy)+abs(fx-sx)))


import sys
input = sys.stdin.readline
import heapq
from operator import itemgetter

n,m=list(map(int,input().split()))
sx,sy,fx,fy=list(map(int,input().split()))
W=[list(map(int,input().split()))+[i] for i in range(m)]+[[sx,sy,m]]

ANS=[n**2]

def ans(time,x,y):
    ANS[0]=min(ANS[0],time+abs(fx-x)+abs(fy-y))

WX=sorted(W,key=itemgetter(0))
WY=sorted(W,key=itemgetter(1))

EDGE=[[] for i in range(m+1)]
TIME=[1<<60]*(m+1)
TIME[m]=0

for i in range(1,m+1):
    x0,y0,m0=WX[i-1]
    x1,y1,m1=WX[i]

    EDGE[m0].append((m1,min(abs(x0-x1),abs(y0-y1))))
    EDGE[m1].append((m0,min(abs(x0-x1),abs(y0-y1))))

    x0,y0,m0=WY[i-1]
    x1,y1,m1=WY[i]

    EDGE[m0].append((m1,min(abs(x0-x1),abs(y0-y1))))
    EDGE[m1].append((m0,min(abs(x0-x1),abs(y0-y1))))

Q=[(0,m)]
while Q:
    time,town=heapq.heappop(Q)
    if time>TIME[town]:
        continue
    ans(time,W[town][0],W[town][1])

    for to,cost in EDGE[town]:
        if TIME[to]>TIME[town]+cost:
            TIME[to]=TIME[town]+cost
            heapq.heappush(Q,(TIME[to],to))

print(ANS[0])


import sys, io, os
import math
import heapq as hq
import random
from collections import defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

import sys
from os import path

def console(*args):  # the judge will not read these print statement
    # print('\033[36m', *args, '\033[0m', file=sys.stderr)
    pass

# if Codeforces environment
if path.exists('input.txt'):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")

    def console(*args):
        pass

inp = sys.stdin.readlines()
# inp = io.BytesIO(os.read(0,os.fstat(0).st_size)).readlines()


def solve(*args):
    console("----- solving ------")
    console(*args)
    console("----- ------- ------")
    return solve_(*args)


def solve_(grid,sx,sy,ex,ey):  # fix inputs here
    console("----- solving ------")
    # console(grid,sx,sy,ex,ey)

    minres = abs(sx-ex) + abs(sy-ey)
    console(minres)
    if grid == []:
        return minres

    d = defaultdict(list)
    grid = [(i,x,y) for i,(x,y) in enumerate(grid)]

    # x-order
    grid = sorted(grid, key=lambda x: x[1])
    for (i1,x1,y1),(i2,x2,y2) in zip(grid, grid[1:]):
        d[i1].append((i2,x2-x1))
        d[i2].append((i1,x2-x1))

    grid = sorted(grid, key=lambda x: x[2])
    for (i1,x1,y1),(i2,x2,y2) in zip(grid, grid[1:]):
        d[i1].append((i2,y2-y1))
        d[i2].append((i1,y2-y1))

    for i,x,y in grid:
        # start to x-axis
        d[-2].append((i,abs(x-sx)))

        # start to y-axis
        d[-2].append((i,abs(y-sy)))

        # point to destination
        d[i].append((-1, abs(x-ex) + abs(y-ey)))

    d[-1] = []
    console(list(d.keys()))

    idxs = {k:i for i,k in enumerate(d.keys())}
    G = [[] for _ in range(len(idxs))]

    for e,vrr in list(d.items()):
        for v,cost in vrr:
            G[idxs[e]].append((idxs[v],cost))

    return min(minres, dijkstra_with_preprocessing(d, -2, -1))


def dijkstra_with_preprocessing(map_from_node_to_nodes_and_costs, source, target):
    d = map_from_node_to_nodes_and_costs
    if target not in d:
        d[-1] = []

    # assign indexes
    idxs = {k:i for i,k in enumerate(d.keys())}

    # population array of nodes and costs
    G = [[] for _ in range(len(idxs))]
    for e,vrr in list(d.items()):
        for v,cost in vrr:
            G[idxs[e]].append((idxs[v],cost))

    _,costs = dijkstra(G, idxs[source])
    return costs[idxs[target]]


def dijkstra(G, s):
    n = len(G)
    visited = [False]*n
    weights = [math.inf]*n
    path = [None]*n
    queue = []
    weights[s] = 0
    hq.heappush(queue, (0, s))
    while len(queue) > 0:
        g, u = hq.heappop(queue)
        visited[u] = True
        for v, w in G[u]:
            if not visited[v]:
                f = g + w
                if f < weights[v]:
                    weights[v] = f
                    path[v] = u
                    hq.heappush(queue, (f, v))
    return path, weights



# fast read all
for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    # k = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    _, nrows = list(map(int,inp[0].split()))
    sx,sy,ex,ey = list(map(int,inp[1].split()))

    # currow = 2
    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    grid = []
    for z in range(nrows):
        grid.append(list(map(int,inp[z+2].split())))

    res = solve(grid,sx,sy,ex,ey)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)







import sys
input = sys.stdin.readline

import heapq

def dijkstra(n, s, edges):
    hq = [(0, s)]
    cost = [float('inf')] * n
    cost[s] = 0
    while hq:
        c, v = heapq.heappop(hq)
        if c > cost[v]:
            continue
        for d, u in edges[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(hq, (tmp, u))
    return cost[1]

def main():
    n, m = map(int, input().split())
    sx, sy, fx, fy = map(int, input().split())
    xy = [list(map(int, input().split())) + [i + 2] for i in range(m)]
    edges = [[] for _ in range(m + 2)]
    
    xy.sort(key = lambda x:x[0])
    for i in range(m - 1):
        dx = abs(xy[i][0] - xy[i + 1][0])
        dy = abs(xy[i][1] - xy[i + 1][1])
        d = min(dx, dy)
        pos1 = xy[i][2]
        pos2 = xy[i + 1][2]
        edges[pos1].append((d, pos2))
        edges[pos2].append((d, pos1))
        
    xy.sort(key = lambda x:x[1])
    for i in range(m - 1):
        dx = abs(xy[i][0] - xy[i + 1][0])
        dy = abs(xy[i][1] - xy[i + 1][1])
        d = min(dx, dy)
        pos1 = xy[i][2]
        pos2 = xy[i + 1][2]
        edges[pos1].append((d, pos2))
        edges[pos2].append((d, pos1))
        
    for x, y, i in xy:
        d1 = min(abs(x - sx), abs(y - sy))
        d2 = abs(x - sx) + abs(y - sy)
        edges[0].append((d1, i))
        edges[i].append((d2, 0))
        
        d1 = min(abs(x - fx), abs(y - fy))
        d2 = abs(x - fx) + abs(y - fy)
        edges[1].append((d1, i))
        edges[i].append((d2, 1))
    
    d = abs(sx - fx) + abs(sy - fy)
    edges[0].append((d, 1))
    edges[1].append((d, 0))
    
    ans = dijkstra(m + 2, 0, edges)
    print(ans)
    
    
main()