Problem: Vasya lagged behind at the University and got to the battlefield. Just joking! He's simply playing some computer game. The field is a flat platform with n trenches dug on it. The trenches are segments on a plane parallel to the coordinate axes. No two trenches intersect.

There is a huge enemy laser far away from Vasya. The laser charges for a seconds, and then shoots continuously for b seconds. Then, it charges for a seconds again. Then it shoots continuously for b seconds again and so on. Vasya knows numbers a and b. He also knows that while the laser is shooting, Vasya must be in the trench, but while the laser is charging, Vasya can safely move around the field. The main thing is to have time to hide in the trench before the shot. If Vasya reaches the trench exactly at the moment when the laser starts shooting, we believe that Vasya managed to hide. Coincidentally, the length of any trench in meters numerically does not exceed b.

Initially, Vasya is at point A. He needs to get to point B. Vasya moves at speed 1 meter per second in either direction. You can get in or out of the trench at any its point. Getting in or out of the trench takes no time. It is also possible to move in the trench, without leaving it.

What is the minimum time Vasya needs to get from point A to point B, if at the initial time the laser has just started charging? If Vasya cannot get from point A to point B, print -1. If Vasya reaches point B at the moment when the laser begins to shoot, it is believed that Vasya managed to reach point B.

Input

The first line contains two space-separated integers: a and b (1 ≤ a, b ≤ 1000), — the duration of charging and the duration of shooting, in seconds.

The second line contains four space-separated integers: Ax, Ay, Bx, By ( - 104 ≤ Ax, Ay, Bx, By ≤ 104) — the coordinates of points А and B. It is guaranteed that points A and B do not belong to any trench.

The third line contains a single integer: n (1 ≤ n ≤ 1000), — the number of trenches. 

Each of the following n lines contains four space-separated integers: x1, y1, x2, y2 ( - 104 ≤ xi, yi ≤ 104) — the coordinates of ends of the corresponding trench.

All coordinates are given in meters. It is guaranteed that for any trench either x1 = x2, or y1 = y2. No two trenches intersect. The length of any trench in meters doesn't exceed b numerically.

Output

If Vasya can get from point A to point B, print the minimum time he will need for it. Otherwise, print number -1.

The answer will be considered correct if the absolute or relative error does not exceed 10 - 4

Examples

Input

2 4
0 5 6 5
3
0 0 0 4
1 1 4 1
6 0 6 4


Output

19.0000000000


Input

5 10
0 0 10 10
1
5 0 5 9


Output

-1

Solution (in JAVA):

Solution:

// Problem : A. Battlefield
// Contest : Codeforces - Codeforces Round #117 (Div. 2)
// URL : https://codeforces.com/contest/182/problem/A
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

import java.io.*;
import java.util.*;
import java.util.stream.*;

public class a implements Runnable{
	
    public static void main(String[] args) {
        new Thread(null, new a(), "process", 1<<26).start();
    }
	public void run() {
		FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		//PrintWriter out = new PrintWriter("file.out");
		Task solver = new Task();
		//int t = scan.nextInt();
		int t = 1;
		for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
		out.close();
	}

	static class Task {
		static final int inf = Integer.MAX_VALUE;

		public void solve(int testNumber, FastReader sc, PrintWriter pw) {
			//CHECK FOR QUICKSORT TLE
			//***********************//
			//CHECK FOR INT OVERFLOW
			//***********************//
			int a = sc.nextInt();
			int b = sc.nextInt();
			int ax = sc.nextInt();
			int ay = sc.nextInt();
			int bx = sc.nextInt();
			int by = sc.nextInt();
			int tr = sc.nextInt();
			int[][] tren = new int[tr + 2][4];
			for(int i = 0; i < tr; i++) {
				for(int j = 0; j < 4; j++) {
					tren[i][j] = sc.nextInt();
				}
				if(tren[i][2] < tren[i][0]) {
					int temp = tren[i][2];
					tren[i][2] = tren[i][0];
					tren[i][0] = temp;
				}
				if(tren[i][3] < tren[i][1]) {
					int temp = tren[i][3];
					tren[i][3] = tren[i][1];
					tren[i][1] = temp;
				}
			}
			tren[tr][0] = ax;
			tren[tr][1] = ay;
			tren[tr][2] = ax;
			tren[tr][3] = ay;
			tren[tr+1][0] = bx;
			tren[tr+1][1] = by;
			tren[tr+1][2] = bx;
			tren[tr+1][3] = by;
			List<tup>[] adjl = Stream.generate(ArrayList::new).limit(tr + 2).toArray(List[]::new);
			for(int i = 0; i < tr + 2; i++) {
				for(int j = i + 1; j < tr + 2; j++) {
					double wei = inf;
					if(tren[i][0] >= tren[j][0] && tren[i][0] <= tren[j][2] ||
					tren[i][2] >= tren[j][0] && tren[i][2] <= tren[j][2] ||
					tren[i][2] >= tren[j][2] && tren[i][0] <= tren[j][0]) {
						wei = Math.min(Math.abs(tren[i][1] - tren[j][1]), Math.abs(tren[i][1] - tren[j][3]));
						wei = Math.min(wei, Math.abs(tren[i][3] - tren[j][3]));
						wei = Math.min(wei, Math.abs(tren[i][3] - tren[j][1]));
					}
					else if(tren[i][1] >= tren[j][1] && tren[i][1] <= tren[j][3] ||
					tren[i][3] >= tren[j][1] && tren[i][3] <= tren[j][3] ||
					tren[i][3] >= tren[j][3] && tren[i][1] <= tren[j][1]) {
						wei = Math.min(Math.abs(tren[i][0] - tren[j][2]), Math.abs(tren[i][0] - tren[j][2]));
						wei = Math.min(wei, Math.abs(tren[i][2] - tren[j][2]));
						wei = Math.min(wei, Math.abs(tren[i][2] - tren[j][0]));
					}
					else {
						wei = Math.min(dist(tren[i][0], tren[i][1], tren[j][0], tren[j][1]), dist(tren[i][0], tren[i][1], tren[j][2], tren[j][3]));
						wei = Math.min(wei, dist(tren[i][2], tren[i][3], tren[j][2], tren[j][3]));
						wei = Math.min(wei, dist(tren[i][2], tren[i][3], tren[j][0], tren[j][1]));
					}
					if(wei <= a) {
						adjl[i].add(new tup(j, wei));
						adjl[j].add(new tup(i, wei));
					}
				}
			}
			for(int i = 0; i < tr + 2; i++) {
				for(tup c : adjl[i]) {
					//pw.println(i + " " + c.a + " " + c.b);
				}
			}
			int[] djik = new int[tr + 2];
			double ans = inf; 
			Arrays.fill(djik, inf);
			PriorityQueue<tup2> pq = new PriorityQueue<>();
			pq.add(new tup2(tr, 0));
			while(!pq.isEmpty()) {
				tup2 c = pq.poll();
				for(tup x : adjl[c.a]) {
					if(djik[x.a] > c.b + 1) {
						djik[x.a] = c.b + 1;
						pq.add(new tup2(x.a, djik[x.a]));
					}
					if(x.a == tr + 1) {
						ans = Math.min(c.b * (a + b) + x.b, ans);
					}
				}
			}
			if(ans == inf) {
				pw.println(-1);return;
			}
			pw.println(ans);
		}
		double dist(int a, int b, int c, int d) {
			return Math.sqrt((c-a-0l)*(c-a) + (d-b-0l) * (d-b));
		}
	}
	static long binpow(long a, long b, long m) {
		a %= m;
		long res = 1;
		while (b > 0) {
			if ((b & 1) == 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
	}
	static void sort(int[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static void sort(long[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static class tup implements Comparable<tup>{
		int a;double b;
		tup(int a,double b){
			this.a=a;
			this.b=b;
		}
		@Override
		public int compareTo(tup o){
			return Double.compare(b,o.b);
		}
	}
	static class tup2 implements Comparable<tup2>{
		int a;int b;
		tup2(int a,int b){
			this.a=a;
			this.b=b;
		}
		@Override
		public int compareTo(tup2 o){
			return Integer.compare(b,o.b);
		}
	}
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(i + 1);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(i + 1);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}