#include <bits/stdc++.h>
using namespace std;
int main() {
  double a, b, x, y, v, t, h, n, d;
  h = -1;
  scanf("%lf %lf", &a, &b);
  scanf("%lf", &n);
  while (n--) {
    scanf("%lf %lf %lf", &x, &y, &v);
    d = (a - x) * (a - x) + (b - y) * (b - y);
    d = sqrt(d);
    t = d / v;
    if (h == -1)
      h = t;
    else if (t < h)
      h = t;
    else
      ;
  }
  printf("%.10lf\n", h);
  return 0;
}
