#include <bits/stdc++.h>
using namespace std;
int main() {
  long double x, y, ans, x1, y1, t;
  cin >> x >> y;
  int n;
  cin >> n;
  cin >> x1 >> y1 >> t;
  ans = (sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1))) / (t);
  for (int i = 1; i < n; i++) {
    cin >> x1 >> y1 >> t;
    ans = min(ans, (sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1))) / (t));
  }
  cout << setprecision(18) << ans << endl;
  return 0;
}
