Problem: One warm and sunny day king Copa decided to visit the shooting gallery, located at the Central Park, and try to win the main prize — big pink plush panda. The king is not good at shooting, so he invited you to help him.

The shooting gallery is an infinite vertical plane with Cartesian coordinate system on it. The targets are points on this plane. Each target is described by it's coordinates xi, and yi, by the time of it's appearance ti and by the number pi, which gives the probability that Copa hits this target if he aims at it.

A target appears and disappears instantly, so Copa can hit the target only if at the moment ti his gun sight aimed at (xi, yi). Speed of movement of the gun sight on the plane is equal to 1. Copa knows all the information about the targets beforehand (remember, he is a king!). He wants to play in the optimal way, which maximizes the expected value of the amount of hit targets. He can aim at any target at the moment 0.

Input

The first line contains integer n (1 ≤ n ≤ 1000) — amount of targets in the shooting gallery. Then n lines follow, each describing one target. Each description consists of four numbers xi, yi, ti, pi (where xi, yi, ti — integers,  - 1000 ≤ xi, yi ≤ 1000, 0 ≤ ti ≤ 109, real number pi is given with no more than 6 digits after the decimal point, 0 ≤ pi ≤ 1). No two targets may be at the same point.

Output

Output the maximum expected value of the amount of targets that was shot by the king. Your answer will be accepted if it differs from the correct answer by not more than 10 - 6.

Examples

Input

1
0 0 0 0.5


Output

0.5000000000


Input

2
0 0 0 0.6
5 0 5 0.7


Output

1.3000000000

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.Arrays;
import java.util.Locale;

public class C {

	static {
		final Locale us = Locale.US;
		if (!Locale.getDefault().equals(us)) {
			Locale.setDefault(us);
		}
	}

	static boolean file = false;
	static boolean isLocal = true;

	private static int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	private static double nextDouble() throws IOException {
		in.nextToken();
		return in.nval;
	}

	static StreamTokenizer in;
	static {
		try {
			// in = new Scanner(file ? new
			// FileInputStream("f:\\var\\tmp\\in.txt")
			// : System.in);

			// in = new BufferedReader(new InputStreamReader(
			// file ? new FileInputStream("f:\\var\\tmp\\in.txt")
			// : System.in));

			in = new StreamTokenizer(new BufferedReader(new InputStreamReader(
					file ? new FileInputStream("f:\\var\\tmp\\in.txt")
							: System.in)));
		} catch (final FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	static PrintWriter out;
	static {
		try {
			out = file ? new PrintWriter(
					new FileWriter("f:\\var\\tmp\\out.txt")) : new PrintWriter(
					System.out);
		} catch (final IOException e) {
			e.printStackTrace();
		}
	}

	static PrintStream err;
	private static double[] cache;
	private static int n;
	private static int[] xs;
	private static int[] ys;
	private static long[] ts;
	private static double[] ps;
	static {
		err = System.err;
	}

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(final String[] args) throws IOException {
		try {
			final long startTime = System.nanoTime();
			final long t = 1;// nextInt();
			for (long i = 0; i < t; ++i) {
				solve(i + 1);
				if (file) {
					err.println(i + 1 + "/" + t);
				}
				if (!file) {
					out.flush();
				}
			}
			if (isLocal) {
				err.println(String.format("Completed after %d ms.",
						(System.nanoTime() - startTime) / 1000000));
			}
		} finally {
			out.flush();
		}
	}

	private static void solve(final long testId) throws IOException {
		n = nextInt();

		xs = new int[n];
		ys = new int[n];

		ts = new long[n];

		ps = new double[n];

		cache = new double[n];
		Arrays.fill(cache, -1.0);

		for (int i = 0; i < n; ++i) {
			xs[i] = nextInt();
			ys[i] = nextInt();
			ts[i] = nextInt();
			ps[i] = nextDouble();
		}

		double ans = 0.0;

		for (int i = 0; i < n; ++i) {
			final double candidate = value(i);

			if (candidate > ans) {
				ans = candidate;
			}
		}

		out.printf("%.6f\n", ans);
	}

	private static double value(final int q) {

		if (cache[q] == -1.0) {

			double best = 0.0;

			for (int i = 0; i < n; ++i) {
				if (ts[i] > ts[q]) {

					final long dt = ts[i] - ts[q];

					final long dx = xs[i] - xs[q];
					final long dy = ys[i] - ys[q];

					if (dx * dx + dy * dy <= dt * dt) {
						best = Math.max(best, value(i));
					}

				}
			}

			cache[q] = ps[q] + best;
		}

		return cache[q];

	}
}