#include <bits/stdc++.h>
using namespace std;
int n, now;
struct aa {
  double x, y;
  int nn;
} pp[1100];
double mid;
inline double power(double x) { return x * x; }
bool judge(void) {
  int ss = now;
  for (int i = (1); i <= (n); i++) {
    if (power(pp[i].x) + power(pp[i].y) <= mid * mid + 1e-10) {
      ss += pp[i].nn;
    }
    if (ss >= 1000000) return true;
  }
  return false;
}
void solve(void) {
  for (int i = (1); i <= (n); i++)
    scanf("%lf%lf%d", &pp[i].x, &pp[i].y, &pp[i].nn);
  double l = 0, r = 100000;
  while (fabs(r - l) > 1e-8) {
    mid = (l + r) / 2.0;
    if (judge())
      r = mid;
    else
      l = mid;
  }
  if (r > 50000)
    printf("-1\n");
  else
    printf("%.7lf\n", r);
}
int main(void) {
  while (2 == scanf("%d%d", &n, &now)) solve();
  return 0;
}
