Problem: E --Disappear Drive

Story

The person in D likes basketball, but he likes shooting, so other techniques are crazy. I'm not particularly good at dribbling, and when I enter the opponent's defensive range, I always get the ball stolen. So I decided to come up with a deadly dribble that would surely pull out any opponent. After some effort, he finally completed the disappearing drive, "Disapia Drive".

This Apia Drive creates a gap by provoking the opponent to deprive him of his concentration and take his eyes off, and in that gap he goes beyond the wall of dimension and slips through the opponent's defensive range. It's a drive. However, crossing the dimensional wall puts a heavy burden on the body, so there is a limit to the number of times the dimensional wall can be crossed. Also, because he always uses his concentration, he can only change direction once, including normal movements. How do you move on the court to reach the goal in the shortest time without being robbed of the ball?

Problem

Consider a rectangle on a two-dimensional plane with (0,0) at the bottom left and (50,94) at the top right. In addition, there are N circles on this plane, the center position of the i-th circle is (x_i, y_i), and the radius is r_i. There is no overlap between the circles.

Let (25,0) be the point S and (25,94) be the point G, and consider the route from S to G. A "path" consists of (1) a line segment connecting S and G, or (2) a combination of a line segment SP and a line segment GP at any point P inside a rectangle. In the middle of the route from S to G, the period from entering the inside of a circle to exiting the inside of the circle is defined as "the section passing through the inside of the circle". However, it is assumed that the circumferences of the rectangle and the circle are not included in the rectangle and the circle, respectively.

Find the length of the shortest route among the routes where the number of sections passing through the inside of the circle is D or less. If you can't reach the goal, return -1.

Input

The input consists of the following format.


N D
x_1 y_1 r_1
...
x_N y_N r_N

The first line consists of two integers, and the number N of circles and the number of times D that can pass inside the circle are given, separated by one blank character. The following N lines are given circle information. The i + 1 line (1 \ leq i \ leq N) consists of three integers, and the x-coordinate x_i, y-coordinate y_i, and radius r_i of the center of the i-th circle are given by separating them with one blank character.

Constraints:

* 0 \ leq N \ leq 5
* 0 \ leq D \ leq 5
* 0 \ leq x_i \ leq 50
* 0 \ leq y_i \ leq 94
* 1 \ leq r_i \ leq 100
* It can be assumed that any two circles are separated by 10 ^ {-5} or more.
* It can be assumed that S and G are not included inside any circle.
* It can be assumed that S and G are separated from any circle by 10 ^ {-5} or more.
* It can be assumed that the point P in the shortest path is more than 10 ^ {-5} away from the circumference of the rectangle and any circumference.



Output

Output the length of the shortest path on one line. Be sure to start a new line at the end of the line. However, if you cannot reach the goal, return -1. Absolute error or relative error of 10 ^ {-7} or less is allowed for the correct answer.

Sample Input 1


Ten
25 47 10

Sample Output 1


96.2027355887

DisappearDrive_sample1.png

The detour route is the shortest because it cannot disappear.

Sample Input 2


1 1
25 47 10

Sample Output 2


94.0000000000

DisappearDrive_sample2.png

It can disappear, so you just have to go straight through it.

Sample Input 3


Ten
20 47 5

Sample Output 3


94.0000000000

DisappearDrive_sample3.png

Since the circumference is not included in the circle, it can pass through without disappearing.

Sample Input 4


Ten
25 47 40

Sample Output 4


-1

DisappearDrive_sample4.png

You can't reach the goal because you can't disappear or detour.

Sample Input 5


5 2
11 10 16
33 40 18
20 66 10
45 79 14
22 85 8

Sample Output 5


96.1320937224

DisappearDrive_sample5.png





Example

Input

1 0
25 47 10


Output

96.2027355887

Solution (in CPP):

Solution:
#include<iostream>
#include<cstdio>
#include<complex>
#include<vector>

using namespace std;

#define X real()
#define Y imag()

typedef long double D;
typedef complex<D> P;
struct L{P a, b;};

const D EPS = 1e-8;

int sig(D a, D b = 0) {return a < b - EPS ? -1 : a > b + EPS ? 1 : 0;}
bool near(P a, P b) {return !sig(norm(a - b));}
namespace std {
  bool operator<(P a, P b) {return sig(a.X, b.X) ? a.X < b.X : a.Y < b.Y;}
}

D sr(D a) {return sqrt(max(a, (D)0));}

D dot(P a, P b) {return a.X * b.X + a.Y * b.Y;}
D det(P a, P b) {return a.X * b.Y - a.Y * b.X;}

P vec(L a) {return a.b - a.a;}

enum CCW{FRONT = 1, RIGHT = 2, BACK = 4, LEFT = 8, ON = 16};
int ccw(P a, P b, P c) {
  if (near(a, c) || near(b, c)) return ON;
  int s = sig(det(b - a, c - a));
  if (s) return s > 0 ? LEFT : RIGHT;
  return (a < b) == (b < c) ? FRONT : (c < a) == (a < b) ? BACK : ON;
}

P proj(P a, P b) {return a * dot(a, b) / norm(a);}
P perp(L l, P p) {return l.a + proj(vec(l), p - l.a);}

bool iLLs(L a, L b) {return sig(det(vec(a), vec(b)));}

P pLL(L a, L b) {return a.a + vec(a) * (det(vec(b), b.a - a.a) / det(vec(b), vec(a)));}

D dLP(L l, P p) {return abs(det(vec(l), p - l.a) / vec(l));}
D dSP(L s, P p) {
  if (dot(vec(s), p - s.a) < 0) return abs(p - s.a);
  if (dot(vec(s), p - s.b) > 0) return abs(p - s.b);
  return dLP(s, p);
}

struct C{P c; D r;};
bool iCSs(C c, L s) {return sig(c.r, dSP(s, c.c)) > 0;}

pair<P, P> pCL(C c, L l) {
  P x = perp(l, c.c);
  P y = vec(l) / abs(vec(l)) * sr(c.r * c.r - norm(x - c.c));
  return make_pair(x - y, x + y);
}

pair<P, P> tCP(C c, P p) {
  D d2 = norm(p - c.c);
  D x = sqrt(max(d2 - c.r * c.r, (D)0));
  P h = c.c + (p - c.c) * (c.r * c.r / d2);
  P w = (p - c.c) * (x * c.r / d2) * P(0, 1);
  return make_pair(h - w, h + w);
}

#define rep(i, n) for (int i = 0; i < int(n); ++i)

int main() {
  int n, d;
  cin >> n >> d;
  C c[n];
  rep (i, n) {
    D x, y, r;
    cin >> x >> y >> r;
    c[i] = (C){P(x, y), r};
  }
  L l;
  l.a = P(25, 0);
  l.b = P(25, 94);
  int cnt = 0;
  rep (i, n) if (iCSs(c[i], l)) ++cnt;
  if (cnt <= d) {
    puts("94");
    return 0;
  }
  vector<L> vl1, vl2;
  rep (i, n) {
    pair<P, P> pp = tCP(c[i], l.a);
    vl1.push_back((L){l.a, pp.first});
    vl1.push_back((L){l.a, pp.second});
  }
  rep (i, n) {
    pair<P, P> pp = tCP(c[i], l.b);
    vl2.push_back((L){l.b, pp.first});
    vl2.push_back((L){l.b, pp.second});
  }
  D res = 1000;
  rep (i, vl1.size()) rep (j, vl2.size()) if (iLLs(vl1[i], vl2[j])) {
    P p = pLL(vl1[i], vl2[j]);
    if (sig(p.X) < 0 || sig(p.X, 50) > 0 || sig(p.Y) < 0 || sig(p.Y, 94) > 0) continue;
    cnt = 0;
    rep (i, n) if (iCSs(c[i], (L){l.a, p})) {
      pair<P, P> pp = pCL(c[i], (L){l.a, p});
      if (ccw(l.a, p, pp.first) == ON) ++cnt;
      if (ccw(l.a, p, pp.second) == ON) ++cnt;
    }
    rep (i, n) if (iCSs(c[i], (L){l.b, p})) {
      pair<P, P> pp = pCL(c[i], (L){l.b, p});
      if (ccw(l.b, p, pp.first) == ON) ++cnt;
      if (ccw(l.b, p, pp.second) == ON) ++cnt;
    }
    if (cnt / 2 <= d) {
      res = min(res, abs(l.a - p) + abs(l.b - p));
    }
  }
  if (sig(res, 1000) == 0) {
    puts("-1");
  } else {
    printf("%.12Lf\n", res);
  }
}