#include <bits/stdc++.h>
using namespace std;
struct CGlb {
  void write(vector<int> &r) {
    int i;
    for (i = 0; i < (r.size()); i++) cout << r[i] << ' ';
    cout << endl;
  }
  void write(int r[], int n) {
    int i;
    for (i = 0; i < (n); i++) cout << r[i] << ' ';
    cout << endl;
  }
} x_glb;
struct CP {
  int x, y;
  CP() { x = y = 0; }
  CP(int x, int y) {
    this->x = x;
    this->y = y;
  }
  double length() { return ::sqrt(x * x + y * y); }
  double dis(const CP &that) { return ((*this) - that).length(); }
  CP operator+(const CP &that) { return CP(x + that.x, y + that.y); }
  CP operator-(const CP &that) { return CP(x - that.x, y - that.y); }
  friend istream &operator>>(istream &is, CP &c);
  friend ostream &operator<<(ostream &os, const CP &c);
};
istream &operator>>(istream &is, CP &c) {
  is >> c.x >> c.y;
  return is;
}
ostream &operator<<(ostream &os, const CP &c) {
  os << c.x << ' ' << c.y;
  return os;
}
int n, m;
int T, Ti;
double da, db;
CP ra, rb;
int main() {
  ios::sync_with_stdio(false);
  int i, j, k;
  int a, b, c;
  int x, y, z;
  int s;
  string zs;
  while (cin >> ra >> n) {
    for (i = 0; i < (n); i++) {
      double rc;
      cin >> rb >> rc;
      if (!i || da > ra.dis(rb) / rc) da = ra.dis(rb) / rc;
    }
    cout << setiosflags(ios::fixed) << setprecision(8) << da << endl;
  }
  return 0;
}
