#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int oo = ~0u >> 2, mo = (int)1e9 + 7;
const int mn = 110, mm = mn * 12;
int sgn(double x) {
  if (fabs(x) <= eps) return 0;
  if (x > -eps) return 1;
  return -1;
}
struct po {
  double x, y, z;
  po() {}
  po(double _x, double _y, double _z) { x = _x, y = _y, z = _z; }
  void readin() { cin >> x >> y >> z; }
  po operator+(const po &p) { return po(x + p.x, y + p.y, z + p.z); }
  po operator-(const po &p) { return po(x - p.x, y - p.y, z - p.z); }
} P, v;
struct circle {
  po o;
  double r;
} C[mm];
int R, n, l(0);
double Ans(oo);
double calc(circle O) {
  double A = ((v.x) * (v.x)) + ((v.y) * (v.y)) + ((v.z) * (v.z));
  double B = -2 * (v.x * O.o.x + v.y * O.o.y + v.z * O.o.z);
  double C = ((O.o.x) * (O.o.x)) + ((O.o.y) * (O.o.y)) + ((O.o.z) * (O.o.z)) -
             ((O.r) * (O.r));
  double delta = ((B) * (B)) - 4 * A * C;
  if (sgn(delta) < 0) return -1;
  delta = sqrt(delta);
  double t1 = (-B - delta) / 2. / A;
  double t2 = (-B + delta) / 2. / A;
  if (sgn(t1) <= 0) return t2;
  return t1;
}
int main() {
  P.readin(), v.readin();
  cin >> R >> n;
  for (int i = 1; i <= n; ++i) {
    int m, t(l + 1);
    C[++l].o.readin();
    C[l].o = C[l].o - P;
    cin >> C[l].r >> m;
    C[l].r += R;
    while (m--) C[++l].o.readin(), C[l].r = R, C[l].o = C[l].o + C[t].o;
  }
  for (int i = 1; i <= l; ++i) {
    double t = calc(C[i]);
    if (sgn(t) <= 0) continue;
    (Ans = min(Ans, t));
  }
  if (!sgn(Ans - oo))
    printf("-1\n");
  else
    printf("%.10f\n", Ans);
}
