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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
pair<long double, long double> MV(pair<long double, long double> a,
                                  pair<long double, long double> b) {
  return make_pair(b.first - a.first, b.second - a.second);
}
long double area(pair<long double, long double> a,
                 pair<long double, long double> b,
                 pair<long double, long double> c) {
  return MV(a, b).first * MV(a, c).second - MV(a, b).second * MV(a, c).first;
}
long double SP(pair<long double, long double> a,
               pair<long double, long double> b) {
  return a.first * b.first + a.second * b.second;
}
long double VP(pair<long double, long double> a,
               pair<long double, long double> b,
               pair<long double, long double> c) {
  return MV(a, b).first * MV(a, c).second - MV(a, b).second * MV(a, c).first;
}
long double len(pair<long double, long double> a,
                pair<long double, long double> b) {
  return sqrt(MV(a, b).first * MV(a, b).first +
              MV(a, b).second * MV(a, b).second);
}
long double distptsect(pair<long double, long double> a,
                       pair<long double, long double> b,
                       pair<long double, long double> c) {
  if (SP(MV(b, a), MV(b, c)) < 0 || SP(MV(c, a), MV(c, b)) < 0) return 1e12;
  return abs(area(a, b, c) / len(b, c));
}
bool intersect_1(long double a, long double b, long double c, long double d) {
  if (a > b) swap(a, b);
  if (c > d) swap(c, d);
  return max(a, c) <= min(b, d);
}
bool intersect(pair<long double, long double> a,
               pair<long double, long double> b,
               pair<long double, long double> c,
               pair<long double, long double> d) {
  return intersect_1(a.first, b.first, c.first, d.first) &&
         intersect_1(a.second, b.second, c.second, d.second) &&
         area(a, b, c) * area(a, b, d) <= 0 &&
         area(c, d, a) * area(c, d, b) <= 0;
}
vector<pair<int, pair<pair<long double, long double>, long double>>> g;
long double d[1001];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  long long temp;
  g.resize(n);
  for (int i = 0; i < (int)(n); ++i)
    cin >> g[i].second.first.first >> g[i].second.first.second >> g[i].first >>
        g[i].second.second;
  sort(g.begin(), g.end());
  for (int i = 0; i < (int)(n); ++i) {
    d[i] = g[i].second.second;
    for (int j = 0; j < (int)(i); ++j) {
      if (len(g[i].second.first, g[j].second.first) <= g[i].first - g[j].first)
        d[i] = max(d[i], d[j] + g[i].second.second);
    }
  }
  long double max = 0;
  for (int i = 0; i < (int)(n); ++i) {
    if (d[i] > max) max = d[i];
  }
  cout.precision(15);
  cout << fixed << max;
  return 0;
}