#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <deque>
#include <set>

using namespace std;
double Xa, Ya, Za, K;
int N, B;
double G[100][4];
bool f[100];
bool f2[100];
pair<int, double> P[100];
double r;

double rast(double x1, double y1, double z1 ,double x2, double y2, double z2)
{
	return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
}
double rast2(int n1, int n2)
{
	return rast(G[n1][0], G[n1][1], G[n1][2], G[n2][0], G[n2][1], G[n2][2]);
}
double ru(double x)
{
	return ceil(x);
}
#define eps 0.00000001
int src[100];
int main()
{
	freopen("space.in", "r", stdin);
	freopen("space.out", "w", stdout);
	cin >> Xa >> Ya >> Za >> N >> B >> K;
	B--;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 4; j++)
			cin >> G[i][j];
		r = rast(Xa, Ya, Za, G[i][0],G[i][1],G[i][2]);
		if (ru(r/100.0) <= K+eps)
		{P[i] = make_pair(0.0, K-ru(r/100));src[i];f2[i] = true;}
		else P[i] = make_pair(0,1E100);
	}
	bool ff = true;
	while (ff && !f2[B])
	{
		ff = false;
		int min = 0;
		for (int i = 0; i < N; i++)
			if (f2[i])
			if (!f[i])
			if (P[i].first < P[min].first
				|| (P[i].first == P[min].first && P[i].second > P[min].second)
				) min = i;
		//if (f[min]) break;
		f[min] = true;
		for (int i = 0; i < N; i++)
		if (!f2[i])
		{
			double c = ru(rast2(min, i)/100);
			if (c > P[min].second ) 
			{
				P[i].first = P[min].first+ru((c - P[min].second)*G[min][3]);
				P[i].second = 0;
				f2[i] = true;
				ff = true;
			}
		}
	}
	//while (
	if (f2[B])
		cout << (int)ru(P[B].first);
	else cout << -1;
	return 0;
}