#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <ctime>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <iostream>
#pragma comment (linker,"/STACK:64000000")
using namespace std;
struct point{
	int x,y,z;
};
struct position{
	int plan,fuel;
};
const int maxn=110, maxm=110;
point crd[maxn]={0,0,0};
int a[maxn][maxm];
const int maxDist=999999999;
int dist[maxn][maxn]={{0}};
int cost[maxn]={0};
int n,m,k,b;
bool used[maxn][maxm]={false};
point a0={0,0,0};

int fuel(point a,point b)
{
	return (int)(ceil(sqrt((double)((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z)))/100));
}
int main()
{
//	freopen("space.in","r",stdin);
//	freopen("space.out","w",stdout);
	int i,j,l;
	cin >> a0.x >> a0.y >> a0.z;
	cin >> n >> b >> k;
	for(i=1;i<=n;i++)
		cin >> crd[i].x >> crd[i].y >> crd[i].z >> cost[i];
	m=80;
	for (i=1;i<=n;i++)
		for (j=0;j<=m;j++)
			a[i][j]=maxDist;
	for (i=1;i<=n;i++)
	{
		for (j=1;j<=n;j++)
		{
			dist[i][j]=fuel(crd[i],crd[j]);
			dist[j][i]=dist[i][j];
		}
	}
	int tmp=0;
	for (i=1;i<=n;i++)
	{
		tmp=fuel(a0,crd[i]);
		if (tmp<=k) a[i][k-tmp]=0;
	}
	a[0][0]=maxDist;
	for (l=1;l<n*m;l++)
	{
		position sm={0,0};
		for (i=1;i<=n;i++)
		{		
			for (j=0;j<=m;j++)
				if ((used[i][j]==false)&&(a[i][j]<a[sm.plan][sm.fuel]))
				{
					sm.plan=i;
					sm.fuel=j;
				}
		}
		if ((sm.plan>0)&&(sm.fuel>=0))
		{
			//fuel optimize loop
			used[sm.plan][sm.fuel]=true;
			for (i=sm.fuel+1;i<=m;i++)
			{
				if ((a[sm.plan][i]>(a[sm.plan][sm.fuel]+(i-sm.fuel)*cost[sm.plan]))&&(used[sm.plan][i]==false))
					a[sm.plan][i]=a[sm.plan][sm.fuel]+(i-sm.fuel)*cost[sm.plan];
			}
			for (i=1;i<=n;i++)
			{
				tmp=sm.fuel-dist[sm.plan][i];
				if ((tmp>=0)&&(used[i][tmp]==false)&&(a[i][tmp]>a[sm.plan][sm.fuel]))
					a[i][tmp]=a[sm.plan][sm.fuel];
			}
		}
	}
	int minI=0;
	for (i=1;i<=m;i++)
		if (a[b][i]<a[b][minI]) minI=i;
	if (a[b][minI]==maxDist)
		cout << -1 << endl;
	else
		cout << a[b][minI] << endl;
	return 0;
}
