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.IOException;
import java.util.*;

public class Main {
    private static List<Target> targetList = new ArrayList<Target>();

    private static class Target {
        int x;
        int y;
        int t;
        float p;

        public Target(int x, int y, int t, float p) {
            this.x = x;
            this.y = y;
            this.t = t;
            this.p = p;
        }

        @Override
        public String toString() {
            return x + ", " + y + ", " + t + " => " + p;
        }

        @Override
        public int hashCode() {
            int hash = 1;
            hash = hash * 17 + x;
            hash = hash * 31 + y;
            hash = hash * 13 + t;
            return hash;
        }

        public static boolean isHittable(Target current, Target next) {
            int t = Math.abs(next.t - current.t);
            int x = Math.abs(next.x - current.x);
            int y = Math.abs(next.y - current.y);

            if ((Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))) > t) {
                return false;
            }


            return true;
        }
    }

    static class TimeAscCompare implements Comparator<Target> {

        @Override
        public int compare(Target t1, Target t2) {
            return t1.t - t2.t;
        }
    }

    private static void test() {
        Target t;
        t = new Target(3, -8, 6, 0.859061f);
        targetList.add(t);

        t = new Target(-7, 8, 12, 0.121809f);
        targetList.add(t);

        t = new Target(10, -7, 14, 0.926305f);
        targetList.add(t);

        t = new Target(-7, 7, 14, 0.413446f);
        targetList.add(t);

//        t = new Target(4, 10, 1, 0.246686f);
//        targetList.add(t);
//        t = new Target(-3, -8, 16, 0.685997f);
//        targetList.add(t);
//        t = new Target(-7, 2, 19, 0.488637f);
//        targetList.add(t);
//        t = new Target(6, -4, 21, 0.526054f);
//        targetList.add(t);
//        t = new Target(-9, -2, 25, 0.541029f);
//        targetList.add(t);
//        t = new Target(-2, -8, 27, 0.976475f);
//        targetList.add(t);
//        t = new Target(-4, 7, 39, 0.921693f);
//        targetList.add(t);
//        t = new Target(-7, 3, 39, 0.987596f);
//        targetList.add(t);
//        t = new Target(-6, -5, 50, 0.819011f);
//        targetList.add(t);
//        t = new Target(3, -1, 50, 0.111185f);
//        targetList.add(t);


//        System.out.println(Target.isHittable(targetList.get(5), targetList.get(7)));

    }

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int c = sc.nextInt();
        for (int i = 1; i <= c; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            int t = sc.nextInt();
            float p = sc.nextFloat();

            Target target = new Target(x, y, t, p);
            targetList.add(target);
        }

//        test();
        Collections.sort(targetList, new TimeAscCompare());


        calMax2();

    }

    static float maxEV = 0;

    private static void calMax2() {
        int n = targetList.size();
        float[] cache = new float[n];


        for (int i = 0; i < n; i++) {

            cache[i] += targetList.get(i).p;
            for (int j = i + 1; j < n; j++) {
                if (Target.isHittable(targetList.get(i), targetList.get(j))) {
                    cache[j] = Math.max(cache[i], cache[j]);
                }
            }

            maxEV = cache[i] > maxEV ? cache[i] : maxEV;
        }

        System.out.println(maxEV);
    }
}