#include <bits/stdc++.h>
using namespace std;
const int N = 1000000;
struct point {
  double x, y, v;
  int num;
} date[1005];
int cmp(point a, point b) { return a.v < b.v; }
int main() {
  int n, numer;
  int ans;
  while (cin >> n >> numer) {
    ans = numer;
    for (int i = 0; i < n; i++) {
      cin >> date[i].x >> date[i].y >> date[i].num;
      date[i].v = sqrt(date[i].x * date[i].x + date[i].y * date[i].y);
      ans += date[i].num;
    }
    if (ans < N) {
      cout << "-1" << endl;
      continue;
    }
    sort(date, date + n, cmp);
    for (int i = 0; i < n; i++) {
      numer += date[i].num;
      if (numer >= N) {
        printf("%.7lf\n", date[i].v);
        goto endW;
      }
    }
  endW:;
  }
  return 0;
}
