#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e5 + 11;
int main() {
  int a, b;
  cin >> a >> b;
  int t;
  cin >> t;
  int x, y, v;
  cin >> x >> y >> v;
  int d = (x - a) * (x - a) + (y - b) * (y - b);
  double dx = sqrt(d);
  t--;
  while (t--) {
    int xx, yy, vv;
    cin >> xx >> yy >> vv;
    int dd = (xx - a) * (xx - a) + (yy - b) * (yy - b);
    double ddx = sqrt(dd);
    if (ddx * v - dx * vv < 0) {
      dx = ddx;
      v = vv;
    }
  }
  printf("%.6lf\n", dx / (double)v);
  return 0;
}
