The administration of the Tomsk Region firmly believes that it's time to become a megacity (that is, get population of one million). Instead of improving the demographic situation, they decided to achieve its goal by expanding the boundaries of the city.

The city of Tomsk can be represented as point on the plane with coordinates (0; 0). The city is surrounded with n other locations, the i-th one has coordinates (x_{i}, y_{i}) with the population of k_{i} people. You can widen the city boundaries to a circle of radius r. In such case all locations inside the circle and on its border are included into the city.

Your goal is to write a program that will determine the minimum radius r, to which is necessary to expand the boundaries of Tomsk, so that it becomes a megacity.


-----Input-----

The first line of the input contains two integers n and s (1 ≤ n ≤ 10^3; 1 ≤ s < 10^6) — the number of locatons around Tomsk city and the population of the city. Then n lines follow. The i-th line contains three integers — the x_{i} and y_{i} coordinate values of the i-th location and the number k_{i} of people in it (1 ≤ k_{i} < 10^6). Each coordinate is an integer and doesn't exceed 10^4 in its absolute value.

It is guaranteed that no two locations are at the same point and no location is at point (0; 0).


-----Output-----

In the output, print "-1" (without the quotes), if Tomsk won't be able to become a megacity. Otherwise, in the first line print a single real number — the minimum radius of the circle that the city needs to expand to in order to become a megacity.

The answer is considered correct if the absolute or relative error don't exceed 10^{ - 6}.


-----Examples-----
Input
4 999998
1 1 1
2 2 1
3 3 1
2 -2 1

Output
2.8284271

Input
4 999998
1 1 2
2 2 1
3 3 1
2 -2 1

Output
1.4142136

Input
2 1
1 1 999997
2 2 1

Output
-1

Difficulty: interview

Starter code:

Solutions:
n, s = map(int, input().split())
c = []
for i in range(n):
    x, y, z = map(int, input().split())
    c.append((x, y, z))
minans = 10**20
for i in range(n):
    nc = 0
    total = s
    for j in range(n):
        if c[j][0] ** 2 + c[j][1] ** 2 <= c[i][0] ** 2 + c[i][1] ** 2:
            total += c[j][2]
    if total >= 10**6 and c[i][0] ** 2 + c[i][1] ** 2 < minans:
        minans = c[i][0] ** 2 + c[i][1] ** 2
if minans != 10**20:
    print(minans ** 0.5)
else:
    print(-1)

import math

n,s = (int(i) for i in input().strip().split())
l = [None] * n
for i in range(n):
    x,y,p = list(map(int, input().split()))
    l[i] = (x*x+y*y, p)
l.sort(key=lambda x:x[0])
r = 1000000 - s
for i in l:
    r -= i[1]
    if r <= 0:
        print("%.7f" % (math.sqrt(i[0])))
        break
if r > 0:
    print(-1)


import math


n, s = tuple(map(int, str.split(input())))
cities = list([tuple(map(int, str.split(input()))) for _ in range(n)])
cities.sort(key=lambda city: city[0] ** 2 + city[1] ** 2)
i = 0
extra = 0
while s + extra < 10 ** 6 and i < n:

    extra, i = extra + cities[i][2], i + 1

if s + extra < 10 ** 6:

    print(-1)

else:

    x, y, _ = cities[i - 1]
    print(math.sqrt(x ** 2 + y ** 2))



import math 
n,s=list(map(int,input('').split()))
L=[]
for i in range(n):
    x,y,z=list(map(int,input('').split()))
    L+=[(math.sqrt(x*x+y*y),z)]
L.sort()
count=s
if s>=1000000:
    print('0')
    return
for i in L:
    count+=i[1]
    if count>=1000000:
        print(i[0])
        return
    
print('-1')





            
            
        
        
    


                



import sys


n, s = list(map(int, input().split()))
sqr_r = 0
arounds = []
total = s

for _ in range(n):
    x, y, k = list(map(int, input().split()))
    arounds.append([x ** 2 + y ** 2, k])
    total += k

if total < 10 ** 6:
    print(-1)
    return

arounds.sort()

for i in range(n):
    if s >= 10 ** 6:
        break
    s += arounds[i][-1]
    sqr_r = arounds[i][0]

print(sqr_r ** 0.5)


from math import*
n, s = list(map(int, input().split()))
k = [0] * 1001
x = [0] * 1001
y = [0] * 1001
r0 = 0
r = 0
count = 0
Minr = 1000000
otv = -1
for i in range(n):
    x[i], y[i], k[i] = list(map(int, input().split()))
for i in range(n):
    count = s
    r0 = sqrt((x[i]) ** 2 + y[i] ** 2)
    for j in range(n):
        r = sqrt((x[j]) ** 2 + y[j] ** 2)
        if r <= r0:
            count += k[j]
        if count >= 1000000 and r0 < Minr:
            Minr = r0
            otv = r0
            break
print(otv)

            
        


__author__ = 'Lipen'

def main():
    n, s = map(int, input().split())
    data = []
    for _ in range(n):
        x, y, k = map(int, input().split())
        r = pow(x, 2) + pow(y, 2)
        data.append([x, y, k, r])

    rmin = -1
    for i in range(n):
        count = 0
        r = data[i][3]

        for j in range(n):
            if data[j][3] <= r:
                count += data[j][2]

        if count + s >= 1000000 and (r<rmin or rmin==-1):
            rmin = r

    if rmin == -1:
        print(-1)
    else:
        print(pow(rmin, .5))

main()

n,s=list(map(int,input().split()))
L=[]
for i in range(n):
    x,y,k=list(map(int,input().split()))
    L.append((x**2+y**2,k))
L.sort()
inc=0
ind=0
r=0
while(ind<n and s+inc<1000000):
    r=L[ind][0]
    inc+=L[ind][1]
    ind+=1

if(s+inc>=1000000):
    print(pow(r,1/2))
else:
    print(-1)


from math import*
n, s = map(int, input().split())
dist = []
for i in range(n):
    a, b, c = map(int, input().split())
    dist.append((a*a + b*b, c))
dist = sorted(dist)
i = 0
while s < 1000000 and i < n:
    s += dist[i][1]
    i += 1
if s < 1000000:
    print(-1)
elif i == 0:
    print(0)
else:
    print(sqrt(dist[i - 1][0]))

n, k = map(int, input().split())
if k >= 1000000:
    print('0')
    return
def f():
    x, y, d = map(int, input().split())
    return (x * x + y * y, d)
t = [f() for i in range(n)]
t.sort()
for r, d in t:
    k += d
    if k >= 1000000:
        print(r ** 0.5)
        break
else: print('-1')

n, s = map(int, input().split())
vals = [tuple(map(int, input().split())) for i in range(n)]
vals.sort(key = lambda e: e[0]*e[0] + e[1]*e[1])
b = True
for v in vals:
    s += v[2]
    if s >= 1000000:
        print((v[0]*v[0] + v[1]*v[1])**0.5)
        b = False
        break
if b:
    print(-1)

import math
import sys

n,p = list(map(int,input().split()))
cities=[]
for i in range(n):
    x,y,pi = list(map(int,input().split()))
    cities.append(((x,y),pi))
 
sorted_cities = sorted(cities,key=lambda data: math.sqrt(data[0][0]**2+data[0][1]**2))
for i in range(n):
    if p < 1000000:
        p+=sorted_cities[i][1]
        if p>= 1000000:
            print(math.sqrt(sorted_cities[i][0][0]**2+sorted_cities[i][0][1]**2))
            return
print(-1)




from math import sqrt

class City:
    def __init__(self, x, y, pop):
        self.distance = sqrt(x*x + y*y)
        self.population = pop

n, need = list(map(int, input().split()))
need = 1000000 - need
cities =[]
total = 0
for i in range(n):
    x, y, pop = list(map(int,input().split()))
    cities.append(City(x,y,pop))
    total += pop

if total < need:
    print(-1)
else:
    cities.sort(key=lambda city: city.distance)
    dis = 0
    i = 0
    while need > 0:
        need -= cities[i].population
        dis = cities[i].distance
        i += 1

    print(dis)






import math
n, s = tuple(map(int,input().split()))
x=[];y=[];k=[];r=[]
for i in range(n):
    a,b,c = tuple(map(int,input().split()))
    x.append(a)
    y.append(b)
    k.append(c)
    r.append((math.sqrt(x[i]**2+y[i]**2),i))
r.sort()
nas = s; i = 0
while i < n and nas < 1000000:
    nas += k[r[i][1]]
    i += 1
if i == n and nas < 1000000: print('-1')
else: print(r[i-1][0])

import math
R = lambda: list(map(int, input().split()))
n, sum = R()
x = []; y = []; z = []; dis = []
for i in range(n):
    a, b, c = R()
    x.append(a)
    y.append(b)
    z.append(c)
    dis.append((math.sqrt(a**2 + b ** 2), i))
dis.sort()
i = 0
while sum < 1000000 and i < n:
    sum += z[dis[i][1]]
    i += 1
if sum < 1000000: print('-1')
else: print(dis[i-1][0])


def func(x):
    nonlocal a
    y=0
    for i in range(x):
        y+=a[i][1]
    return y
n,s=map(int,input().split())
a=[]
for i in range(n):
    x,y,k=map(int,input().split())
    a.append([x*x+y*y,k])
if func(n)+s<10**6:
    print(-1)
    return
a.sort()
l=-1
r=n
while l+1<r:
    m=(l+r)//2
    if s+func(m+1)>=10**6:
        r=m
    else:
        l=m
print(a[r][0]**0.5)

from math import *
R = lambda:map(int, input().split())
n, s = R()
x = sorted((x * x + y * y, k) for x, y, k in (R() for i in range(n)))
for i in range(n):
  s += x[i][1]
  if s >= 1000000:
    print(sqrt(x[i][0]))
    return
print(-1)

from math import *
R = lambda:map(int, input().split())
n, s = R()
x = sorted((hypot(x, y), k) for x, y, k in (R() for i in range(n)))
for t in x:
  s += t[1]
  if s >= 1000000:
    print(t[0])
    return
print(-1)

import math
n,m=map(int, input().split())
L=[]
for i in range(n):
    x,y,z=map(int, input().split())
    L+=[(math.sqrt(x*x+y*y),z)]
L.sort()
count=m
if count>=1000000:
    print('0')
    return
for i in L:
    count+=i[1]
    if count>=1000000:
        print(i[0])
        return
print('-1')

import math
n,s=map(int, input().split())
locations=[]
for i in range(n):
    x,y,k=map(int, input().split())
    locations+=[(x*x+y*y, k)]
locations.sort()
if s>=1000000:
    print('0')
    return
for i in range(n):
    s+=locations[i][1]
    if s>=1000000:
        print(math.sqrt(locations[i][0]))
        return
print('-1')

import math
n,s=map(int, input().split())
locations=[]
for i in range(n):
    x,y,k=map(int, input().split())
    locations+=[(x*x+y*y, k)]
locations.sort()
if s>=1000000:
    print(0)
    return
for i in range(n):
    s+=locations[i][1]
    if s>=1000000:
        print(math.sqrt(locations[i][0]))
        return
print(-1)

import math
n,s=map(int, input().split())
locations=[]
for i in range(n):
    x,y,k=map(int, input().split())
    locations+=[(x*x+y*y, k)]
locations.sort()
for i in range(n):
    s+=locations[i][1]
    if s>=1000000:
        print(math.sqrt(locations[i][0]))
        return
print(-1)

import math
n,m=map(int, input().split())
L=[]
for i in range(n):
     x,y,z=map(int, input().split())
     L.append( (math.sqrt(x*x+y*y),z) )
L.sort()
count=m
if count>=1000000:
     print('0')
     return
for i in L:
     count+=i[1]
     if count>=1000000:
          print(i[0])
          return
print('-1')

import math

n, s = [int(c) for c in input().split()]

ar = []

for i in range(n):
    x, y, count = [int(c) for c in input().split()]
    ar.append([math.sqrt(x**2 + y**2), count])

ar.sort(key=lambda _: _[0])

i = 0

while i < n and s < 10 ** 6:
    s += ar[i][1]
    i += 1

if s < 10 ** 6:
    print(-1)
else:
    print(round(ar[i - 1][0],7))