using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AlgoTraining.Codeforces.A_s
{
    public class FastScanner : StreamReader
    {
        private string[] _line;
        private int _iterator;

        public FastScanner(Stream stream) : base(stream)
        {
            _line = null;
            _iterator = 0;
        }
        public string NextToken()
        {
            if (_line == null || _iterator >= _line.Length)
            {
                _line = base.ReadLine().Split(' ');
                _iterator = 0;
            }
            if (_line.Count() == 0) throw new IndexOutOfRangeException("Input string is empty");
            return _line[_iterator++];
        }
        public int NextInt()
        {
            return Convert.ToInt32(NextToken());
        }
        public long NextLong()
        {
            return Convert.ToInt64(NextToken());
        }
        public float NextFloat()
        {
            return float.Parse(NextToken());
        }
        public double NextDouble()
        {
            return Convert.ToDouble(NextToken());
        }
    }
    class AATask
    {
        public static void Main(string[] args)
        {
            using (FastScanner fs = new FastScanner(new BufferedStream(Console.OpenStandardInput())))
            using (StreamWriter writer = new StreamWriter(new BufferedStream(Console.OpenStandardOutput())))
            {
                int a = fs.NextInt(), b = fs.NextInt(), n = fs.NextInt();
                double t = double.MaxValue;
                for (int i = 0; i < n; i++)
                {
                    int x = fs.NextInt(), y = fs.NextInt(), v = fs.NextInt();
                    double s = Math.Sqrt((a - x) * (a - x) + (b - y) * (b - y));
                    t = Math.Min(t, s / v);
                }
                writer.WriteLine(t.ToString().Replace(",", "."));
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;

namespace prA {
    class Program {
#if ONLINE_JUDGE
        private static readonly StreamReader reader = new StreamReader(Console.OpenStandardInput(1024 * 10), System.Text.Encoding.ASCII, false, 1024 * 10);
        private static readonly StreamWriter writer = new StreamWriter(Console.OpenStandardOutput(1024 * 10), System.Text.Encoding.ASCII, 1024 * 10);
#else
        private static readonly StreamWriter writer = new StreamWriter(@"..\..\output");
        private static readonly StreamReader reader = new StreamReader(@"..\..\input");
#endif

        static void Main(string[] args) {
            int a = Next();
            int b = Next();
            int n = Next();
            double min = double.MaxValue;
            for (int i = 0; i < n; i++) {
                int x = Next();
                int y = Next();
                int v = Next();
                double r = Math.Sqrt((x - a) * (x - a) + (y - b) * (y - b));
                double t = r / v;
                if (t < min) {
                    min = t;
                }
            }
            writer.Write(min.ToString(CultureInfo.InvariantCulture));
            writer.Flush();
#if !ONLINE_JUDGE
            writer.Close();
#endif
        }
        private static int Next() {
            int c;
            int res = 0;
            do {
                c = reader.Read();
                if(c == -1)
                    return res;
            } while(c != '-' && (c < '0' || c > '9'));
            int sign = 1;
            if(c == '-') {
                sign = -1;
                c = reader.Read();
            }
            res = c - '0';
            while(true) {
                c = reader.Read();
                if(c < '0' || c > '9')
                    return res * sign;
                res *= 10;
                res += c - '0';
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    public void Solve()
    {
        int x0 = ReadInt();
        int y0 = ReadInt();
        double ans = double.MaxValue;
        for (int n = ReadInt(); n > 0; n--)
        {
            int x = ReadInt() - x0;
            int y = ReadInt() - y0;
            int v = ReadInt();
            ans = Math.Min(ans, Math.Sqrt(x * x + y * y) / v);
        }

        Write(ans.ToString(CultureInfo.InvariantCulture));
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            new Solver().Solve();
            //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            //thread.Start();
            //thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0)currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++)matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++)ret[i][j] = matrix[j][i]; } return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++)lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array)writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++)ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication252
{
    class Program
    {

        static void Main(string[] args)
        {
            string[] s1 = Console.ReadLine().Split();
            int x = int.Parse(s1[0]);
            int y = int.Parse(s1[1]);
            double min = double.MaxValue;
            int n = int.Parse(Console.ReadLine());
            for (int i = 0; i < n; i++)
            {
                string[] ss = Console.ReadLine().Split();
                int x1 = int.Parse(ss[0]);
                int y1 = int.Parse(ss[1]);
                double v = double.Parse(ss[2]);
                double dist = 0;

                if (x == x1 || y == y1)
                {
                    if (x == x1)
                    {
                        dist = Math.Abs(y - y1);
                    }
                    else
                    {
                        dist = Math.Abs(x - x1);
                    }
                }
                else
                {
                    int a = Math.Abs(x - x1);
                    int b = Math.Abs(y - y1);
                    dist = Math.Sqrt(a * a + b * b);
                }
                double time = dist / v;
                if (time < min)
                {
                    min = time;
                }
            }
            Console.WriteLine(min.ToString().Replace(',','.'));
        }
    }
}


using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace istu_contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] coord = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(), tmp;
            int n = int.Parse(Console.ReadLine());
            double min = 1000000, res = 0;
            for (int i = 0; i < n; i++) {
                tmp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                res = Math.Sqrt((tmp[0] - coord[0]) * (tmp[0] - coord[0]) + (tmp[1] - coord[1]) * (tmp[1] - coord[1])) / tmp[2];
                if (res < min) min = res;
            }
            string ans = String.Format("{0:F20}", min).Replace(',', '.');
            Console.WriteLine(ans);
            //Console.ReadKey();
        }
    }
}


using System;
using System.Globalization;
using System.Linq;
using System.Runtime.Remoting.Messaging;

namespace ConsoleApplication1
{
    public class CodeForces706A
    {
        static void Main(string[] args)
        {
            var parts = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int a = parts[0];
            int b = parts[1];
            var n = int.Parse(Console.ReadLine());
            int[][] arr = new int[n][];
            for (int i = 0; i < n; ++i)
            {
                arr[i] = new int[3];
                parts = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                arr[i][0] = parts[0];
                arr[i][1] = parts[1];
                arr[i][2] = parts[2];
            }

            double result = -1;

            for (int i = 0; i < n; ++i)
            {
                var time = Calc(a, b, arr[i][0], arr[i][1], arr[i][2]);
                if (result < 0 || result > time)
                    result = time;
            }

            Console.WriteLine(Math.Sqrt(result).ToString(CultureInfo.InvariantCulture));
        }

        static double Calc(int x1, int y1, int x2, int y2, int speed)
        {
            double squareDist = (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2);
            return squareDist / (double) (speed*speed);
        }
    }
}


/*
 * TemplateCS
 * Copyright (C) 2014-2016 Markus Himmel
 * This file is distributed under the terms of the MIT license
 */

//#define CodeJam
#define CodeForces

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections.Generic;

namespace ProgrammingCompetitions
{
	class Program
	{

		#region GCJ
#if CodeJam
		private static bool DEBUG = false;

		static void debug()
		{
		}

		static string solveCase(int num)
		{
			checked
			{
				return null;
			}
		}
#endif
		#endregion

		#region CodeForces
#if CodeForces
#if DEBUG
		static Queue<string> testInput = new Queue<string>(string.Format(@"

1 3
3
3 3 2
-2 3 6
-2 7 10
").Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries));
#endif

		static object Solve()
		{
			checked
			{
				int a, b;
				read(out a, out b);

				int n = read<int>();

				double best = double.MaxValue;
				for (int i = 0; i < n; i++)
				{
					int x, y, v;
					read(out x, out y, out v);
					best = Math.Min(best, Math.Sqrt((x - a) * (x - a) + (y - b) * (y - b)) / v);
				}

				return best;
			}
		}
#endif
		#endregion

		// Everything after this comment is template code

		private static T read<T>()
		{
			return (T)Convert.ChangeType(read(), typeof(T));
		}

		private static T[] readMany<T>()
		{
			return readMany<T>(' ');
		}

		private static _[] readMany<_>(params char[] ___)
		{
			return read().Split(___).Select(__ => (_)Convert.ChangeType(__, typeof(_))).ToArray();
		}

		private static string[] readMany()
		{
			return readMany<string>();
		}

		private static T[][] readMany<T>(int n)
		{
			T[][] res = new T[n][];
			for (int i = 0; i < n; i++)
			{
				res[i] = readMany<T>();
			}
			return res;
		}

		private static T[][] readField<T>(int height, Func<char, T> map)
		{
			T[][] res = new T[height][];
			for (int _ = 0; _ < height; _++)
			{
				res[_] = read().Select(c => map(c)).ToArray();
			}
			return res;
		}

		private static char[][] readField(int height)
		{
			return readField(height, c => c);
		}

		private static T[][] readField<T>(int height, Dictionary<char, T> dic)
		{
			return readField(height, c => dic[c]);
		}

		private static void read<T1>(out T1 t1)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
		}

		private static void read<T1, T2>(out T1 t1, out T2 t2)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
		}

		private static void read<T1, T2, T3>(out T1 t1, out T2 t2, out T3 t3)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
		}

		private static void read<T1, T2, T3, T4>(out T1 t1, out T2 t2, out T3 t3, out T4 t4)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
			t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
		}

		private static void read<T1, T2, T3, T4, T5>(out T1 t1, out T2 t2, out T3 t3, out T4 t4, out T5 t5)
		{
			var vals = readMany();
			t1 = (T1)Convert.ChangeType(vals[0], typeof(T1));
			t2 = (T2)Convert.ChangeType(vals[1], typeof(T2));
			t3 = (T3)Convert.ChangeType(vals[2], typeof(T3));
			t4 = (T4)Convert.ChangeType(vals[3], typeof(T4));
			t5 = (T5)Convert.ChangeType(vals[4], typeof(T5));
		}

		static Func<T1, TResult> DP<T1, TResult>(Func<T1, Func<T1, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1>, TResult>();
			Func<T1, TResult> res = null;
			res = (t1) =>
			{
				var key = Tuple.Create(t1);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, res));
				return cache[key];
			};
			return res;
		}

		static Func<T1, T2, TResult> DP<T1, T2, TResult>(Func<T1, T2, Func<T1, T2, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2>, TResult>();
			Func<T1, T2, TResult> res = null;
			res = (t1, t2) =>
			{
				var key = Tuple.Create(t1, t2);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, res));
				return cache[key];
			};
			return res;
		}

		static Func<T1, T2, T3, TResult> DP<T1, T2, T3, TResult>(Func<T1, T2, T3, Func<T1, T2, T3, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3>, TResult>();
			Func<T1, T2, T3, TResult> res = null;
			res = (t1, t2, t3) =>
			{
				var key = Tuple.Create(t1, t2, t3);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, res));
				return cache[key];
			};
			return res;
		}

		static Func<T1, T2, T3, T4, TResult> DP<T1, T2, T3, T4, TResult>(Func<T1, T2, T3, T4, Func<T1, T2, T3, T4, TResult>, TResult> f)
		{
			var cache = new Dictionary<Tuple<T1, T2, T3, T4>, TResult>();
			Func<T1, T2, T3, T4, TResult> res = null;
			res = (t1, t2, t3, t4) =>
			{
				var key = Tuple.Create(t1, t2, t3, t4);
				if (!cache.ContainsKey(key))
					cache.Add(key, f(t1, t2, t3, t4, res));
				return cache[key];
			};
			return res;
		}

		static IEnumerable<T> single<T>(T it)
		{
			yield return it;
		}

		static IEnumerable<long> range(long first, long last, long step = 1)
		{
			for (long i = first; i <= last; i += step)
			{
				yield return i;
			}
		}

		static IEnumerable<int> range(int first, int last, int step = 1)
		{
			for (int i = first; i <= last; i += step)
			{
				yield return i;
			}
		}

		static T id<T>(T a)
		{
			return a;
		}

		public static T[][] mkarr<T>(int x, int y)
		{
			T[][] res = new T[x][];
			for (int i = 0; i < x; i++)
			{
				res[i] = new T[y];
			}
			return res;
		}

		public static T[][][] mkarr<T>(int x, int y, int z)
		{
			T[][][] res = new T[x][][];
			for (int i = 0; i < x; i++)
			{
				res[i] = new T[y][];
				for (int j = 0; j < y; j++)
				{
					res[i][j] = new T[z];
				}
			}
			return res;
		}

		static bool[] tf = new[] { true, false };

#if CodeJam

		static void Main(string[] args)
		{
			if (DEBUG)
			{
				debug();
			}
			else
			{
				Initialize();
				SolveAll(solveCase);
			}
			Console.ReadKey();
		}

		private static StreamReader inf;
		private static StreamWriter outf;

		private delegate void o(string format, params object[] args);
		private static o Output;

		public static void Initialize()
		{
			Console.ForegroundColor = ConsoleColor.Yellow;
			Console.Write("File name: ");
			string name = Console.ReadLine();
			inf = new StreamReader($"D:\\Users\\marku\\Downloads\\{name}.in");
			outf = new StreamWriter($"D:\\Users\\marku\\Downloads\\{name}.out");
			Console.ForegroundColor = ConsoleColor.White;
			Output = highlightedPrint;
			Output += outf.WriteLine;
		}

		private static void highlightedPrint(string format, params object[] args)
		{
			ConsoleColor prev = Console.ForegroundColor;
			Console.ForegroundColor = ConsoleColor.Green;
			Console.WriteLine(format, args);
			Console.ForegroundColor = prev;
		}

		public static void SolveAll(Func<int, string> calc)
		{
			int cases = int.Parse(inf.ReadLine());
			for (int _ = 1; _ <= cases; _++)
			{
				Output($"Case #{_}: {calc(_)}");
			}
			inf.Close();
			outf.Close();
			Console.ForegroundColor = ConsoleColor.Cyan;
			Console.WriteLine("Eureka!");
		}

		private static string read()
		{
			return inf.ReadLine();
		}
#endif

#if CodeForces
		static void Main(string[] args)
		{
#if DEBUG
			var sw = new System.Diagnostics.Stopwatch();
			sw.Start();
#endif
			object o = Solve();
			if (o != null)
			{
				if (o is double)
				{
					Console.WriteLine(((double)o).ToString("0.000000", System.Globalization.CultureInfo.InvariantCulture));
				}
				else
				{
					string s = o.ToString();
					if (!string.IsNullOrEmpty(s))
					{
						Console.WriteLine(s);
					}
				}
			}
#if DEBUG
			sw.Stop();
			Console.WriteLine(sw.Elapsed);
			Console.ReadKey();
#endif
		}

		private static string read()
		{
#if !DEBUG
			return Console.ReadLine();
#else
			return testInput.Dequeue();
#endif
		}
#endif
	}

	public static class ExtensionMethods
	{
		public static IEnumerable<TOut> Cartesian<T1, T2, TOut>(this IEnumerable<T1> first, IEnumerable<T2> second, Func<T1, T2, TOut> collector)
		{
			return first.SelectMany(f => second.Select(s => collector(f, s)));
		}

		public static IEnumerable<Tuple<T1, T2>> Cartesian<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
		{
			return first.Cartesian(second, Tuple.Create);
		}

		public static IEnumerable<Tuple<T1, T2>> CartesianE<T1, T2>(this IEnumerable<T1> first, IEnumerable<T2> second)
		{
			// Calling CartesianE prevents selection of the wrong overload of Cartesian when you want a tuple of tuples to be returned
			return first.Cartesian(second);
		}

		public static IEnumerable<Tuple<T1, T2, T3>> Cartesian<T1, T2, T3>(this IEnumerable<Tuple<T1, T2>> first, IEnumerable<T3> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4>> Cartesian<T1, T2, T3, T4>(this IEnumerable<Tuple<T1, T2, T3>> first, IEnumerable<T4> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, y));
		}

		public static IEnumerable<Tuple<T1, T2, T3, T4, T5>> Cartesian<T1, T2, T3, T4, T5>(this IEnumerable<Tuple<T1, T2, T3, T4>> first, IEnumerable<T5> second)
		{
			return first.Cartesian(second, (x, y) => Tuple.Create(x.Item1, x.Item2, x.Item3, x.Item4, y));
		}

		public static IEnumerable<IEnumerable<T>> Cartesian<T>(this IEnumerable<IEnumerable<T>> source)
		{
			IEnumerable<IEnumerable<T>> res = source.First().Select(x => single(x));
			foreach (IEnumerable<T> next in source.Skip(1))
			{
				res = res.Cartesian(next, (sofar, n) => sofar.Concat(single(n)));
			}
			return res;
		}

		public static IEnumerable<IEnumerable<T>> Pow<T>(this IEnumerable<T> it, int num)
		{
			return Enumerable.Repeat(it, num).Cartesian();
		}

		public static IEnumerable<T> Demask<T>(this IEnumerable<Tuple<T, bool>> inp)
		{
			foreach (var pair in inp)
			{
				if (pair.Item2)
				{
					yield return pair.Item1;
				}
			}
		}

		public static IEnumerable<IEnumerable<IEnumerable<T>>> Partition<T>(this IEnumerable<T> source, int groups)
		{
			foreach (var part in Enumerable.Range(0, groups).Pow(source.Count()).Select(x => x.ToArray()))
			{
				yield return Enumerable.Range(0, groups).Select(x => source.Where((item, idx) => part[idx] == x));
			}
		}

		public static IEnumerable<IEnumerable<T>> Combinations<T>(this IEnumerable<T> it)
		{
			foreach (var conf in new[] { true, false }.Pow(it.Count()))
			{
				yield return it.Zip(conf, Tuple.Create).Demask();
			}
		}

		private static IEnumerable<T> single<T>(T it)
		{
			yield return it;
		}

		private static IEnumerable<T> ExceptSingle<T>(this IEnumerable<T> first, T it, IEqualityComparer<T> comp = null)
		{
			comp = comp ?? EqualityComparer<T>.Default;
			bool seen = false;
			foreach (T a in first)
			{
				if (!seen && comp.Equals(a, it))
				{
					seen = true;
				}
				else
				{
					yield return a;
				}
			}
		}

		public static IEnumerable<IEnumerable<T>> Permutations<T>(this IEnumerable<T> it)
		{
			if (it.Count() < 2)
			{
				yield return it;
				yield break;
			}

			foreach (T first in it)
			{
				foreach (IEnumerable<T> part in Permutations(it.ExceptSingle(first)))
				{
					yield return single(first).Concat(part);
				}
			}
		}

		public static T[][] Rho<T>(this IEnumerable<T> source, int x, int y)
		{
			T[][] res = Program.mkarr<T>(x, y);

			int i = 0, j = 0;

			while (true)
			{
				foreach (T item in source)
				{
					res[i][j] = item;
					j++;
					if (j == y)
					{
						j = 0;
						i++;
						if (i == x)
							break;
					}
				}
				if (i == x)
					break;
			}

			return res;
		}

		public static T[][][] Rho<T>(this IEnumerable<T> source, int x, int y, int z)
		{
			T[][][] res = Program.mkarr<T>(x, y, z);

			int i = 0, j = 0, k = 0;
			while (true)
			{
				foreach (T item in source)
				{
					res[i][j][k] = item;
					k++;
					if (k == z)
					{
						k = 0;
						j++;
						if (j == y)
						{
							j = 0;
							i++;
							if (i == x)
							{
								break;
							}
						}
					}
				}
				if (i == x)
					break;
			}

			return res;
		}
	}
}


using System;
using System.Globalization;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _706A.Beru_taxi
{
    class Program
    {
        static void Main(string[] args)
        {
            string origin = Console.ReadLine();
            string[] token = origin.Split(' ');
            int a = int.Parse(token[0]);
            int b = int.Parse(token[1]);
            int n = int.Parse(Console.ReadLine());
            double tiempo;
            double tiempo_min = 1.7E+302;
            for (int i = 0; i < n; i++)
            {
                string taxi = Console.ReadLine();
                string[] taksi = taxi.Split(' ');
                int x = int.Parse(taksi[0]);
                int y = int.Parse(taksi[1]);
                int v = int.Parse(taksi[2]);
                tiempo = Math.Sqrt((x - a) * (x - a) + (y-b) * (y - b)) / v;
                if (tiempo_min > tiempo)
                    tiempo_min = tiempo;

            }
            NumberFormatInfo nfi = new NumberFormatInfo();
            nfi.NumberDecimalSeparator = ".";
            Console.WriteLine("{0:F16}", tiempo_min.ToString(nfi));
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _706A.Beru_taxi
{
    class Program
    {
        static void Main(string[] args)
        {
            string origin = Console.ReadLine();
            string[] token = origin.Split(' ');
            int a = int.Parse(token[0]);
            int b = int.Parse(token[1]);
            int n = int.Parse(Console.ReadLine());
            double tiempo;
            double tiempo_min = 1.7E+302;
            for (int i = 0; i < n; i++)
            {
                string taxi = Console.ReadLine();
                string[] taksi = taxi.Split(' ');
                int x = int.Parse(taksi[0]);
                int y = int.Parse(taksi[1]);
                int v = int.Parse(taksi[2]);
                tiempo = Math.Sqrt((x - a) * (x - a) + (y-b) * (y - b)) / v;
                if (tiempo_min > tiempo)
                    tiempo_min = tiempo;

            }
            Console.WriteLine("{0:F16}", tiempo_min);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Beru_такси
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double a = ab[0];
            double b = ab[1];
            double x, y, v;
            double min = 150;
            double time;

            int n = int.Parse(Console.ReadLine());
            double[] tx = new double[n];

            for (int i = 0; i < n; i++)
            {
                tx = Console.ReadLine().Split().Select(double.Parse).ToArray();
                x = tx[0];
                y = tx[1];
                v = tx[2];

                time = Math.Sqrt((Math.Pow(a - x, 2) + Math.Pow(b - y, 2))) / v;
                min = time < min ? time : min;
            }

            string d = min.ToString().Replace(',', '.');

            Console.WriteLine(d);

            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Beru_такси
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double a = ab[0];
            double b = ab[1];
            double x, y, v;
            double min = 150;
            double time;

            int n = int.Parse(Console.ReadLine());
            double[] tx = new double[n];

            for (int i = 0; i < n; i++)
            {
                tx = Console.ReadLine().Split().Select(double.Parse).ToArray();
                x = tx[0];
                y = tx[1];
                v = tx[2];

                time = Math.Sqrt((Math.Pow(a - x, 2) + Math.Pow(b - y, 2))) / v;
                min = time < min ? time : min;
            }

            Console.WriteLine("{0:F10}",min);
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Beru_такси
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(double.Parse).ToArray();
            double a = ab[0];
            double b = ab[1];
            double x, y, v;
            double min = 283;
            double time;

            int n = int.Parse(Console.ReadLine());
            double[] tx = new double[n];

            for (int i = 0; i < n; i++)
            {
                tx = Console.ReadLine().Split().Select(double.Parse).ToArray();
                x = tx[0];
                y = tx[1];
                v = tx[2];

                time = Math.Sqrt((Math.Pow(a - x, 2) + Math.Pow(b - y, 2))) / v;
                min = time < min ? time : min;
            }

            string d = min.ToString().Replace(',', '.');

            Console.WriteLine(d);

            Console.ReadLine();
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp17
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] v = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = int.Parse(Console.ReadLine());
            double[] x = new double[n];

            for (int i = 0; i < n; i++)
            {
                int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                s[0] -= v[0];
                s[1] -= v[1];
                x[i] = Math.Sqrt(Math.Pow(s[0], 2) + Math.Pow(s[1], 2));
                x[i] /= s[2];

            }
            Console.WriteLine(x.Min());

        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp17
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] v = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int n = int.Parse(Console.ReadLine());
            double[] x = new double[n];

            for (int i = 0; i < n; i++)
            {
                int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
                s[0] -= v[0];
                s[1] -= v[1];
                x[i] = Math.Sqrt(Math.Pow(s[0], 2) + Math.Pow(s[1], 2));
                x[i] /= s[2];

            }
            Console.WriteLine(x.Min().ToString().Replace(',','.'));

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Beru_такси
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split(' ');
            int x_vas, y_vas;
            int x, y;
            double v;
            double rastoyanie;
            double? min_t=null;
            double t;
            x_vas = int.Parse(tokens[0]);
            y_vas = int.Parse(tokens[1]);
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                 tokens = Console.ReadLine().Split(' ');
                x = int.Parse(tokens[0]);
                y = int.Parse(tokens[1]);
                v = int.Parse(tokens[2]);
                rastoyanie = Math.Sqrt(Math.Pow(x - x_vas, 2) + Math.Pow(y - y_vas, 2));
                t = rastoyanie /v;

                if ((min_t == null)|| (min_t>t))
                    min_t = t;

            }
            Console.WriteLine(min_t.ToString().Replace(",","."));
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Beru_такси
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split(' ');
            int x_vas, y_vas;
            int x, y;
            double v;
            double rastoyanie;
            double min_t=0.0;
            double t;
            x_vas = int.Parse(tokens[0]);
            y_vas = int.Parse(tokens[1]);
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                 tokens = Console.ReadLine().Split(' ');
                x = int.Parse(tokens[0]);
                y = int.Parse(tokens[1]);
                v = int.Parse(tokens[2]);
                rastoyanie = Math.Sqrt(Math.Pow(x - x_vas, 2) + Math.Pow(y - y_vas, 2));
                t = rastoyanie /v;

                if ((min_t == 0.0)|| (min_t>t))
                    min_t = t;

            }
            Console.WriteLine(min_t.ToString().Replace(",","."));
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Beru_такси
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split(' ');
            int x_vas, y_vas;
            int x, y,v;
            double rastoyanie;
            double min_t=0;
            double t;
            x_vas = int.Parse(tokens[0]);
            y_vas = int.Parse(tokens[1]);
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                 tokens = Console.ReadLine().Split(' ');
                x = int.Parse(tokens[0]);
                y = int.Parse(tokens[1]);
                v = int.Parse(tokens[2]);
                rastoyanie = Math.Sqrt(Math.Pow(x - x_vas, 2) + Math.Pow(y - y_vas, 2));
                t = rastoyanie / v;
                if ((min_t == 0)|| (min_t>t))
                    min_t = t;

            }
            Console.WriteLine(min_t);
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Beru_такси
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] tokens = Console.ReadLine().Split(' ');
            int x_vas, y_vas;
            int x, y;
            double v;
            double rastoyanie;
            double min_t=0;
            double t;
            x_vas = int.Parse(tokens[0]);
            y_vas = int.Parse(tokens[1]);
            int n = int.Parse(Console.ReadLine());

            for (int i = 0; i < n; i++)
            {
                 tokens = Console.ReadLine().Split(' ');
                x = int.Parse(tokens[0]);
                y = int.Parse(tokens[1]);
                v = int.Parse(tokens[2]);
                rastoyanie = Math.Sqrt((double)((double)Math.Pow(x - x_vas, 2) + (double)Math.Pow(y - y_vas, 2)));
                t = rastoyanie / (double)v;

                if ((min_t == 0)|| (min_t>t))
                    min_t = t;

            }
            Console.WriteLine(min_t);
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

class Program
{
    static void solve(StreamReader reader, StreamWriter writer)
    {
        var a = reader.ReadInt();
        var b = reader.ReadInt();
        var n = reader.ReadInt();
        var t = double.MaxValue;
        while (n-- > 0)
        {
            var x = reader.ReadInt() - a;
            var y = reader.ReadInt() - b;
            var v = reader.ReadInt();
            t = Math.Min(t, Math.Sqrt(x*x + y*y)/v);
        }
        writer.WriteLine("{0:F8}", t);
    }

    #region launch
    static void Main(string[] args)
    {
        using (var writer = new FormattedStreamWriter(Console.OpenStandardOutput()))
        {
            using (var reader = new StreamReader(
#if CODECHIEF_LOCAL
"input.txt"
#else
Console.OpenStandardInput()
#endif
))
            {
                solve(reader, writer);
            }
        }
    }
    #endregion
}

#region helpers
class FormattedStreamWriter : StreamWriter
{
    public FormattedStreamWriter(Stream stream)
        : base(stream)
    {
    }

    public override IFormatProvider FormatProvider
    {
        get
        {
            return CultureInfo.InvariantCulture;
        }
    }
}

static class IOExtensions
{
    public static string ReadString(this StreamReader reader)
    {
        return reader.ReadToken();
    }

    public static int ReadInt(this StreamReader reader)
    {
        return int.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
    }

    public static long ReadLong(this StreamReader reader)
    {
        return long.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
    }

    public static double ReadDouble(this StreamReader reader)
    {
        return double.Parse(reader.ReadToken(), CultureInfo.InvariantCulture);
    }

    static Queue<string> buffer = new Queue<string>(100);

    static string ReadToken(this StreamReader reader)
    {
        while (buffer.Count == 0)
        {
            reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).ToList().ForEach((t) =>
            {
                buffer.Enqueue(t);
            });
        }
        return buffer.Dequeue();
    }
}
#endregion


using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Security.AccessControl;
using System.Text;

namespace codeforces
{
	class Program
	{
		public class User
		{
			public int c;

			public int r;
		}

		public class Point
		{
			public int x;

			public int y;
		}

		public class Comparer : IComparer<User>
		{
			public int Compare(User x, User y)
			{
				if (x.c < y.c || (x.c == y.c && x.r < y.r))
					return -1;
				return 1;
			}
		}

		public static long getGcd(long a, long b)
		{
			if (b == 0)
				return a;
			return getGcd(b, a % b);
		}

		public static void WriteYESNO(bool x, string yes = "YES", string no = "NO")
		{
			if (x)
				Console.WriteLine(yes);
			else
			{
				Console.WriteLine(no);
			}
		}

		public static string GetString()
		{
			return Console.ReadLine();
		}

		public static List<int> getList()
		{
			var s = Console.ReadLine();
			return s.Split(' ').Select(int.Parse).ToList();
		}

		public static int Min(int x, int y)
		{
			return Math.Min(x, y);
		}

		public static int Max(int x, int y)
		{
			return Math.Max(x, y);
		}

		public static int Abs(int x)
		{
			return Math.Abs(x);
		}

		public static int getInt()
		{
			var s = Console.ReadLine();
			return int.Parse(s);
		}

		public static bool Equal(int x, int y, int x1, int y1)
		{
			return x == x1 && y == y1;
		}

		public class Vertex
		{
			public List<int> edges;

			public int ct;

			public Vertex()
			{
				ct = 0;
				edges = new List<int>();
				for (var i = 0; i < 26; ++i)
					edges.Add(0);
			}
		}

		private static void Main(string[] args)
		{
/*			var input = new StreamReader("input.txt");
			var output = new StreamWriter("output.txt");*/
			var c = getList();
			var n = getInt();
			double ans = 0;
			var xx = getList();
			ans = Math.Sqrt((xx[0] - c[0]) * (xx[0] - c[0]) + (xx[1] - c[1]) * (xx[1] - c[1])) / xx[2];
			for (var i = 1; i < n; ++i)
			{
				xx = getList();
				var tt = Math.Sqrt((xx[0] - c[0]) * (xx[0] - c[0]) + (xx[1] - c[1]) * (xx[1] - c[1])) / xx[2];
				if (tt < ans)
					ans = tt;
			}
			Console.WriteLine(ans.ToString().Replace(',', '.'));
			/*			input.Close();
			output.Close();*/
		}
	}
}


using System;
using System.Globalization;

public static class Codeforces
{
	public static void Main()
	{
		double ans = 0;

		var coordinates = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
		var a = coordinates[0];
		var b = coordinates[1];

		var n = int.Parse(Console.ReadLine());

		for (var i = 0; i < n; i++) {
			var tmp = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
			var x = tmp[0];
			var y = tmp[1];
			var v = tmp[2];

			var ra = Math.Sqrt(Math.Pow(a - x, 2) + Math.Pow(b - y, 2)) / v;
			var rb = Math.Abs((a - x) / v) + Math.Abs((b - y) / v);
			var r = Math.Min(ra, rb);

			if (i == 0) {
				ans = r;
			}

			ans = Math.Min(ans, r);
		}

		Console.WriteLine(ans.ToString(new CultureInfo("en-US")));
	}
}


using System;

public static class Codeforces
{
	public static void Main()
	{
		double ans = 0;

		var coordinates = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
		var a = coordinates[0];
		var b = coordinates[1];

		var n = int.Parse(Console.ReadLine());

		for (var i = 0; i < n; i++) {
			var tmp = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
			var x = tmp[0];
			var y = tmp[1];
			var v = tmp[2];

			var res = Math.Abs((a - x) / v) + Math.Abs((b - y) / v);

			if (i == 0) {
				ans = res;
			}

			ans = Math.Min(ans, res);
		}

		Console.WriteLine("{0:N20}", ans);
	}
}


using System;

public static class Codeforces
{
	public static void Main()
	{
		double ans = 0;

		var coordinates = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
		var a = coordinates[0];
		var b = coordinates[1];

		var n = int.Parse(Console.ReadLine());

		for (var i = 0; i < n; i++) {
			var tmp = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
			var x = tmp[0];
			var y = tmp[1];
			var v = tmp[2];

			var ra = Math.Sqrt(Math.Pow(a - x, 2) + Math.Pow(b - y, 2)) / v;
			var rb = Math.Abs((a - x) / v) + Math.Abs((b - y) / v);
			var r = Math.Min(ra, rb);

			if (i == 0) {
				ans = r;
			}

			ans = Math.Min(ans, r);
		}

		Console.WriteLine("{0:N20}", ans);
	}
}


using System;
using System.Globalization;

public static class Codeforces
{
	public static void Main()
	{
		double ans = double.PositiveInfinity;

		var coordinates = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
		var a = coordinates[0];
		var b = coordinates[1];

		var n = int.Parse(Console.ReadLine());

		for (var i = 0; i < n; i++) {
			var tmp = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
			var x = tmp[0];
			var y = tmp[1];
			var v = tmp[2];

			var min = (Math.Pow(a - x, 2) + Math.Pow(b - y, 2)) / (v * v);
			ans = Math.Min(ans, min);
		}

		Console.WriteLine(Math.Sqrt(ans).ToString(new CultureInfo("en-US")));
	}
}


using System;
using System.Linq;

namespace _706A
{
    class Program
    {
        static void Main()
        {
            var Vas = Console.ReadLine().Split().Select(double.Parse).ToArray();
            var n = int.Parse(Console.ReadLine());
            double min = double.MaxValue;
            for (int i = 0; i < n; i++)
            {
                var taxi = Console.ReadLine().Split().Select(double.Parse).ToArray();
                var deltaX = taxi[0] - Vas[0];
                var deltaY = taxi[1] - Vas[1];
                var time = Math.Sqrt(deltaX*deltaX + deltaY*deltaY) / taxi[2];
                min = Math.Min(time, min);
            }
            Console.WriteLine(min.ToString().Replace(',', '.'));
        }
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Linq;
using System.Globalization;

class Program
{
    static void Main(string[] args)
    {
        int a = RI();
        int b = RI();
        int n = RI();

        double bestTIme = 1000000;
        for(int i=0;i<n;i++)
        {
            int x = RI();
            int y = RI();
            double v = RI();

            double time = Math.Sqrt((a - x) * (a - x) + (b - y) * (b - y)) / v;
            bestTIme = Math.Min(bestTIme, time);
        }

        Console.Write(DoubleToString(bestTIme));
    }

    private static int GCD(int a, int b)
    {
        if (a % b == 0) return b;
        return GCD(b, a % b);
    }

    private static int Mod = 1000000007;
    private static List<int>[] ReadGraph(int n, int m)
    {
        List<int>[] g = new List<int>[n];
        for (int i = 0; i < n; i++) g[i] = new List<int>();
        for (int i = 0; i < m; i++)
        {
            int a = RI() - 1;
            int b = RI() - 1;

            g[a].Add(b);
            g[b].Add(a);
        }

        return g;
    }

    private static int[,] ReadGraphAsMatrix(int n, int m)
    {
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < m; i++)
        {
            int a = RI();
            int b = RI();
            matrix[a, b] = matrix[b, a] = 1;
        }

        return matrix;
    }

    private static void Sort(ref int a, ref int b)
    {
        if (a > b) Swap(ref a, ref b);
    }

    private static void Swap(ref int a, ref int b)
    {
        int tmp = a;
        a = b;
        b = tmp;
    }

    private const int BufferSize = 1 << 16;
    private static StreamReader consoleReader;
    private static MemoryStream testData;

    private static int RI()
    {
        int ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static ulong RUL()
    {
        ulong ans = 0;
        int chr;
        do
        {
            chr = consoleReader.Read();
            if (chr == -1)
                return 0;
        } while (chr < '0' || chr > '9');

        ans = (uint)(chr - '0');
        while (true)
        {
            chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans;
            ans = ans * 10 + (uint)(chr - '0');
        }
    }

    private static long RL()
    {
        long ans = 0;
        int mul = 1;
        do
        {
            ans = consoleReader.Read();
            if (ans == -1)
                return 0;
            if (ans == '-') mul = -1;
        } while (ans < '0' || ans > '9');

        ans -= '0';
        while (true)
        {
            int chr = consoleReader.Read();
            if (chr < '0' || chr > '9')
                return ans * mul;
            ans = ans * 10 + chr - '0';
        }
    }

    private static int[] RIA(int n)
    {
        int[] ans = new int[n];
        for (int i = 0; i < n; i++)
            ans[i] = RI();
        return ans;
    }

    private static long[] RLA(int n)
    {
        long[] ans = new long[n];
        for (int i = 0; i < n; i++)
            ans[i] = RL();
        return ans;
    }

    private static char[] ReadString()
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        List<char> s = new List<char>();
        do
        {
            s.Add((char)ans);
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s.ToArray();
    }

    private static char[] ReadString(int n)
    {
        int ans;

        do
        {
            ans = consoleReader.Read();
        } while (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')));

        char[] s = new char[n];
        int pos = 0;
        do
        {
            s[pos++] = (char)ans;
            if (pos == n) break;
            ans = consoleReader.Read();
        } while ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'));

        return s;
    }

    private static char ReadLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if ((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z'))
                return (char)ans;
        }
    }
    private static char ReadNonLetter()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (!((ans >= 'a' && ans <= 'z') || (ans >= 'A' && ans <= 'Z')))
                return (char)ans;
        }
    }

    private static char ReadDigit()
    {
        while (true)
        {
            int ans = consoleReader.Read();
            if (ans >= '0' && ans <= '9')
                return (char)ans;
        }
    }

    private static int ReadDigitInt()
    {
        return ReadDigit() - (int)'0';
    }

    private static char ReadAnyChar()
    {
        return (char)consoleReader.Read();
    }

    private static string DoubleToString(double x)
    {
        return x.ToString(CultureInfo.InvariantCulture);
    }

    private static double DoubleFromString(string x)
    {
        return double.Parse(x, CultureInfo.InvariantCulture);
    }

    static Program()
    {
        //Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
        consoleReader = new StreamReader(Console.OpenStandardInput(BufferSize), Encoding.ASCII, false, BufferSize);
    }

    private static void PushTestData(string data)
    {
#if TOLYAN_TEST
        if (testData == null)
        {
            testData = new MemoryStream();
            consoleReader = new StreamReader(testData);
        }

        var pos = testData.Position;
        var bytes = Encoding.UTF8.GetBytes(data);
        testData.Write(bytes, 0, bytes.Length);
        testData.Flush();
        testData.Position = pos;
#endif
    }
}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
    public static class MainClass
    {

        static int ReadIntLine()
        {
            return int.Parse(Console.ReadLine());
        }

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static string GetSha1(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            using (BufferedStream bs = new BufferedStream(fs))
            {
                using (SHA1Managed sha1 = new SHA1Managed())
                {
                    byte[] hash = sha1.ComputeHash(bs);
                    StringBuilder formatted = new StringBuilder(2 * hash.Length);
                    foreach (byte b in hash)
                    {
                        formatted.AppendFormat("{0:X2}", b);
                    }

                    return formatted.ToString();
                }
            }
        }

        static bool canFit(int a1, int b1, int a2, int b2)
        {
            int[] r1 = { a1, b1 };
            int[] r2 = { a2, b2 };

            Array.Sort(r1);
            Array.Sort(r2);

            bool ans = (r1[0] <= r2[0]) && (r1[1] <= r2[1]);

            return ans;

        }

        class Pair
        {
            public int first { get; set; }
            public int second { get; set; }
        }

        static void Main(string[] args)
        {
            int vx = 0, vy = 0;
            int n = 0;
            int x = 0, y = 0, v=0;

            ReadInts(ref vx, ref vy);
            ReadInt(ref n);

            double minT = double.MaxValue;

            for (int i = 0; i < n; i++)
            {
                ReadInts(ref x,ref y,ref v);
                x-=vx;
                y-=vy;
                minT = Math.Min(minT, Math.Sqrt(x * x + y * y)/v);
            }

            PrintLn(minT.ToString().Replace(',','.'));

        }

    }

}


using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace CodeForces
{
    public static class MainClass
    {

        static int ReadIntLine()
        {
            return int.Parse(Console.ReadLine());
        }

        static void ReadInt(ref int a)
        {
            a = ReadIntArrayLine()[0];
        }

        static void ReadInts(ref int a, ref int b)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1];
        }

        static void ReadInts(ref int a, ref int b, ref int c)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4];
        }

        static void ReadInts(ref int a, ref int b, ref int c, ref int d, ref int e, ref int f)
        {
            var x = ReadIntArrayLine();
            a = x[0]; b = x[1]; c = x[2]; d = x[3]; e = x[4]; f = x[5];
        }

        static int[] ReadIntArrayLine()
        {
            char[] sep = { ' ' };
            return Console.ReadLine().Split(sep, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static void PrintLn(object obj)
        {
            Console.WriteLine(obj.ToString());
        }

        public static string Reverse(string s)
        {
            char[] charArray = s.ToCharArray();
            Array.Reverse(charArray);
            return new string(charArray);
        }

        public static void PrintLnCollection<T>(IEnumerable<T> col)
        {
            PrintLn(string.Join(" ", col));
        }

        public static void PrintLn(params object[] v)
        {
            PrintLnCollection(v);
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static string MySubstring(this string str, int start, int finish)
        {
            if (start > finish) return "";
            return str.Substring(start, finish - start + 1);
        }

        public static bool IsInRange(this int a, int lb, int ub)
        {
            return (a >= lb) && (a <= ub);
        }

        private static void mergeDS(int i, int j, int[] a)
        {
            int t = a[j];
            for (int ii = 0; ii < a.Length; ii++)
            {
                if (a[ii] == t)
                    a[ii] = a[i];
            }
        }

        private static T MyMax<T>(params T[] a)
        {
            return a.Max();
        }

        private static T MyMin<T>(params T[] a)
        {
            return a.Min();
        }

        private static int[] GetPrimesLessThan(int x)
        {
            if (x < 2)
                return new int[0];

            int[] a = new int[x];

            a[0] = 1; a[1] = 1;

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    for (int j = 2 * i; j < a.Length; j += i)
                    {
                        a[j] = 1;
                    }
            }

            var abc = new List<int>(x);

            for (int i = 0; i < a.Length; i++)
            {
                if (a[i] == 0)
                    abc.Add(i);
            }

            return abc.ToArray();
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int startIndex, int endIndex, int target)
        {
            if (startIndex == endIndex)
            {
                if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            if (startIndex + 1 == endIndex)
            {
                if (a[endIndex] <= target)
                    return endIndex;
                else if (a[startIndex] <= target)
                    return startIndex;
                else
                    return -1;
            }

            int mid = (startIndex + endIndex) / 2;
            if (target == a[mid])
                return mid;
            else if (target < a[mid])
                return FindNearestLEQElementInTheArray(a, startIndex, mid - 1, target);
            else
                return FindNearestLEQElementInTheArray(a, mid, endIndex, target);
        }

        private static int FindNearestLEQElementInTheArray(int[] a, int target)
        {
            return FindNearestLEQElementInTheArray(a, 0, a.Length - 1, target);
        }

        private static int gcd(int a, int b)
        {
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        //----------------------------------------------------------------------------

        static string GetSha1(string filePath)
        {
            using (FileStream fs = new FileStream(filePath, FileMode.Open))
            using (BufferedStream bs = new BufferedStream(fs))
            {
                using (SHA1Managed sha1 = new SHA1Managed())
                {
                    byte[] hash = sha1.ComputeHash(bs);
                    StringBuilder formatted = new StringBuilder(2 * hash.Length);
                    foreach (byte b in hash)
                    {
                        formatted.AppendFormat("{0:X2}", b);
                    }

                    return formatted.ToString();
                }
            }
        }

        static bool canFit(int a1, int b1, int a2, int b2)
        {
            int[] r1 = { a1, b1 };
            int[] r2 = { a2, b2 };

            Array.Sort(r1);
            Array.Sort(r2);

            bool ans = (r1[0] <= r2[0]) && (r1[1] <= r2[1]);

            return ans;

        }

        class Pair
        {
            public int first { get; set; }
            public int second { get; set; }
        }

        static void Main(string[] args)
        {
            int vx = 0, vy = 0;
            int n = 0;
            int x = 0, y = 0, v=0;

            ReadInts(ref vx, ref vy);
            ReadInt(ref n);

            double minT = double.MaxValue;

            for (int i = 0; i < n; i++)
            {
                ReadInts(ref x,ref y,ref v);
                x-=vx;
                y-=vy;
                minT = Math.Min(minT, Math.Sqrt(x * x + y * y)/v);
            }

            PrintLn(minT);

        }

    }

}


import kotlin.math.sqrt

fun main() {
    val r = System.`in`.bufferedReader()
    val s1 = StringBuilder()
    //val n = r.readLine()!!.toInt()
    val (x, y) = r.readLine()!!.split(" ").map { it.toInt() }
    var time = Double.MAX_VALUE
    repeat(r.readLine()!!.toInt()){
        val (a, b, s) = r.readLine()!!.split(" ").map { it.toDouble() }
        val dis = sqrt((a-x)*(a-x)+(b-y)*(b-y))
        val t = dis/s
        time = minOf(time, t)
    }
    println(time)
}


import java.util.Scanner

fun main(){
    val input = Scanner(System.`in`)
    var home_x : Int = input.nextInt()
    var home_y : Int = input.nextInt()
    var cars_num : Int = input.nextInt()
    var minimum_time : Double = 200.0
    for(i in 1..cars_num){
        var car_x : Double = input.nextDouble()
        var car_y : Double = input.nextDouble()
        var car_speed : Double = input.nextDouble()
        var x_distance : Double = home_x - car_x;
        x_distance *= x_distance;
        var y_distance : Double = home_y - car_y;
        y_distance *= y_distance
        var div : Double = Math.sqrt(x_distance + y_distance)
        div /= car_speed
        if(minimum_time > div){
            minimum_time = div
        }
    }
    print(minimum_time)
}


import java.util.Scanner

fun main(){
    val input = Scanner(System.`in`)
    var home_x : Int = input.nextInt()
    var home_y : Int = input.nextInt()
    var cars_num : Int = input.nextInt()
    var minimum_time : Double = 1000.0
    for(i in 1..cars_num){
        var car_x : Double = input.nextDouble()
        var car_y : Double = input.nextDouble()
        var car_speed : Double = input.nextDouble()
        var x_distance : Double = home_x - car_x;
        x_distance *= x_distance;
        var y_distance : Double = home_y - car_y;
        y_distance *= y_distance
        var div : Double = Math.sqrt(x_distance + y_distance)
        div /= car_speed
        if(minimum_time > div){
            minimum_time = div
        }
    }
    print(minimum_time)
}


import java.util.Scanner

fun main(){
    val input = Scanner(System.`in`)
    var home_x : Int = input.nextInt()
    var home_y : Int = input.nextInt()
    var cars_num : Int = input.nextInt()
    var minimum_time : Double = 200.0
    for(i in 1..cars_num){
        var car_x : Double = input.nextDouble()
        var car_y : Double = input.nextDouble()
        var car_speed : Double = input.nextDouble()
        var x_distance : Double
        var y_distance : Double
        if(home_x > 0){
            if(car_x > 0){
                x_distance = Math.abs(home_x - car_x)
            }
            else{
                x_distance = car_x * -1
                x_distance += home_x
            }
        }
        else{
            if(car_x > 0){
                x_distance = car_x
                x_distance += (home_x * -1)
            }
            else{
                x_distance = Math.abs(home_x - car_x)
            }
        }
        if(home_y > 0){
            if(car_y > 0){
                y_distance = Math.abs(home_y - car_y)
            }
            else{
                y_distance = car_y * -1
                y_distance += home_y
            }
        }
        else{
            if(car_y > 0){
                y_distance = car_y
                y_distance += (home_y * -1)
            }
            else{
                y_distance = Math.abs(home_y - car_y)
            }
        }
        var div : Double = (x_distance + y_distance) / car_speed
        if(minimum_time > div){
            minimum_time = div
        }
    }
    print(minimum_time)
}


import kotlin.math.min
import kotlin.math.sqrt

fun main() {
    fun readInt() = readLine()!!.toInt()
    fun readInts() = readLine()!!.split(" ").map(String::toInt)

    val (a, b) = readInts()
    val numTaxis = readInt()
    var output = Double.MAX_VALUE
    repeat(numTaxis) {
        val (x, y, v) = readInts()
        output = min(output, sqrt(((a - x) *(a - x) + (b - y) * (b - y)).toDouble()) / v)
    }
    print(output)
}


fun main(args: Array<String>) {
    val (x0, y0) = readLine()!!.split(' ').map(String::toDouble)
    var n = readLine()!!.toInt()
    var ans: Double = 1e9
    // print("x0 = $x0, y0 = $y0\n")
    // print("n = $n\n")
    while (n > 0) {
        var (x, y, v) = readLine()!!.split(' ').map(String::toDouble)
        x -= x0
        y -= y0
        val tmp = Math.sqrt(x * x + y * y) / v
        ans = if (tmp < ans) tmp else ans
        n--
    }
    val s = "%.6f".format(ans)
    print("$s\n")
}


#include <stdio.h>
#include <math.h>
typedef struct p {
	int x, y, speed;
} point ;

double Range(point a, point b) {
	return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}

int main() {
	point home, car[1111];
	int n, i;
	double min, time[1111];

	scanf("%d %d", &home.x, &home.y);
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d %d %d", &car[i].x, &car[i].y, &car[i].speed);
	}
	/*point a = { 4,0,0 }, b = { 0,3,0 };
	printf("%lf", Range(a, b));*/
	for (i = 0; i < n; i++) {
		time[i] = Range(car[i], home) / car[i].speed;
		if (i == 0) min = time[i];
		if (min > time[i]) min = time[i];
	}
	printf("%.20lf", min);

	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	long long int x,y;
	scanf("%lld %lld",&x,&y);
	long long int l,i,j;
	long double dis;
	long double min=10000000;
	scanf("%lld",&l);
	for(i=0;i<l;i++)
	{
		long long int n,m,v;
		scanf("%lld %lld %lld",&n,&m,&v);
		long double st=sqrt(((n-x)*(n-x))+((m-y)*(m-y)));
		dis=st/v;
		if(dis<min)
			min=dis;
	}
	printf("%.20Lf\n",min);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	long long int x,y;
	scanf("%lld %lld",&x,&y);
	long long int l,i,j;
	double dis;
	double min=100000000.0000000000000000;
	scanf("%lld",&l);
	for(i=0;i<l;i++)
	{
		double n,m;
		double v;
		scanf("%lf %lf %lf",&n,&m,&v);
		double st=sqrt(((n-x)*(n-x))+((m-y)*(m-y)));
		dis=st/v;
		if(dis<min)
			min=dis;
	}
	printf("%.20lf\n",min);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	long long int x,y;
	scanf("%lld %lld",&x,&y);
	long long int l,i,j;
	long double dis;
	long double min=10000000;
	scanf("%lld",&l);
	for(i=0;i<l;i++)
	{
		long long int n,m,v;
		scanf("%lld %lld %lld",&n,&m,&v);
		long double st=sqrt(((n-x)*(n-x))+((m-y)*(m-y)));
		dis=st/v;
		if(dis<min)
			min=dis;
	}
	printf("%Lf\n",min);
	return 0;
}


#include <stdio.h>
#include <math.h>
int main() {
  int a,b,n,x,y,v; double min=400,t;
  scanf("%d%d%d",&a,&b,&n);
  for (int i=0;i<n;i++) {
    scanf("%d%d%d",&x,&y,&v);
    t=sqrt((x-a)*(x-a)+(y-b)*(y-b))/v;
    if (t<min) min=t;
  }
  printf("%.20lf\n",min);
  return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define sf scanf
#define pf printf
#define db double
#define end return 0
int func(int,int);
int a[100005];
int main()
{
     int n,m,t,i,b,c;
     db sum,min=10001,s,d;
     sf("%d %d",&n,&m);
     sf("%d",&t);
     for(i=1;i<=t;i++)
     {
          sf("%d %d %lf",&b,&c,&d);
          s=abs(b-n)+abs(c-m);
          sum=s/d;
          if(sum<min)
          min=sum;
     }
     pf("%.20lf",min);
end;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define sf scanf
#define pf printf
#define db double
#define end return 0
int func(int,int);
int a[100005];
int main()
{
     int n,m,t,i,b,c,d;
     db sum,min=10001,s;
     sf("%d %d",&n,&m);
     sf("%d",&t);
     for(i=1;i<=t;i++)
     {
          sf("%d %d %d",&b,&c,&d);
          s=abs(b-n)+abs(c-m);
          sum=s/(double)d;
          if(sum<min)
          min=sum;
     }
     pf("%.20lf",min);
end;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define sf scanf
#define pf printf
#define db double
#define end return 0
int func(int,int);
int a[100005];
int main()
{
     int n,m,t,i,b,c,d;
     db s,sum,min=1000001.00;
     sf("%d %d",&n,&m);
     sf("%d",&t);
     for(i=1;i<=t;i++)
     {
          sf("%d %d %d",&b,&c,&d);
          s=sqrt((b-n)*(b-n)+(c-m)*(c-m));
          sum=s/(double)d;
          if(sum<min)
          min=sum;
     }
     pf("%.20lf",min);
end;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define sf scanf
#define pf printf
#define db double
#define end return 0
int func(int,int);
int a[100005];
int main()
{
     int n,m,t,i,b,c,d,s=0;
     db sum,min=1000001.00;
     sf("%d %d",&n,&m);
     sf("%d",&t);
     for(i=1;i<=t;i++)
     {
          sf("%d %d %d",&b,&c,&d);
          s=abs(b-n)+abs(c-m);
          sum=(double)s/(double)d;
          if(sum<min)
          min=sum;
     }
     pf("%.20lf",min);
end;
}


/*
 * Beri-taxi.c
 *
 *  Created on: 18-Feb-2018
 *      Author: Prabhath Nampally
 */
#include<stdio.h>
#include <math.h>
double distance(int x1,int y1,int x2,int y2){
	int dx=x1-x2;
	int dy=y1-y2;
	double t = dx*dx +dy*dy;
	return sqrt(t);
}
int main(){
	int x1,y1,x2,y2,v,n=0;
	double minTime,time;
	scanf("%d%d",&x1,&y1);
	scanf("%d",&n);
	scanf("%d%d%d",&x2,&y2,&v);
	time = (double)distance(x1,y1,x2,y2)/v;
	minTime = time;
	for(int i=1;i<n;i++){
		scanf("%d%d%d",&x2,&y2,&v);
		time = (double)distance(x1,y1,x2,y2)/v;
		if(minTime>time){
			minTime=time;
		}
	}
	printf("%f",minTime);
	return 0;
}


#include <stdio.h>
#include <math.h>
int main()
{
    int a,b,x[1000],y[1000],v,i,T;
    double flag=10000,z;
    scanf("%d%d", &a, &b);
    scanf("%d", &T);
    for(i=0; i<T; i++)
    {
        scanf("%d%d%d", &x[i], &y[i], &v);
        z=sqrt(((a-x[i])*(a-x[i]))+((b-y[i])*(b-y[i])));
        double w=(double)z/v;
        if(w<flag)
        {
            flag=w;
        }
    }
    printf("%.20lf\n", flag);
    return 0;
}


#include<stdio.h>
#include<iostream>
#include<string.h>
#include<string>
#include<ctype.h>
#include<math.h>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<bitset>
#include<algorithm>
#include<time.h>
using namespace std;
void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }
#define MS(x,y) memset(x,y,sizeof(x))
#define MC(x,y) memcpy(x,y,sizeof(x))
#define MP(x,y) make_pair(x,y)
#define ls o<<1
#define rs o<<1|1
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int X, Y, n;
int x, y, v;
int main()
{
    while (~scanf("%d%d%d", &X, &Y, &n))
    {
        double ans = 1e9;
        while (n--)
        {
            scanf("%d%d%d", &x, &y, &v);
            gmin(ans, sqrt((x - X)*(x - X) + (y - Y)*(y - Y)) / v);
        }
        printf("%.10f\n", ans);
    }
    return 0;
}


#include<stdio.h>
#include <math.h>
typedef long long LL;
typedef unsigned long long UL;
typedef unsigned int UI;
template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
const int N = 0, M = 0, Z = 1e9 + 7, ms63 = 0x3f3f3f3f;
int X, Y, n;
int x, y, v;
int main()
{
    while (~scanf("%d%d%d", &X, &Y, &n))
    {
        double ans = 1e9;
        while (n--)
        {
            scanf("%d%d%d", &x, &y, &v);
            gmin(ans, sqrt((x - X)*(x - X) + (y - Y)*(y - Y)) / v);
        }
        printf("%.10f\n", ans);
    }
    return 0;
}


#include<stdio.h>
#include <math.h>
template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }
int X, Y, n;
int x, y, v;
int main()
{
   scanf("%d%d%d", &X, &Y, &n);

        double ans = 1e9;
        while (n--)
        {
            scanf("%d%d%d", &x, &y, &v);
            gmin(ans, sqrt((x - X)*(x - X) + (y - Y)*(y - Y)) / v);
        }
        printf("%.10f\n", ans);

    return 0;
}


#include<stdio.h>
#include <math.h>
int X, Y, n;
int x, y, v;
double gmin(double a, double b)
{
	if(a > b) return b;
	return a;
}
int main()
{
   scanf("%d%d%d", &X, &Y, &n);

        double ans = 1e9;
        while (n--)
        {
            scanf("%d%d%d", &x, &y, &v);
            ans = gmin(ans, sqrt((x - X)*(x - X) + (y - Y)*(y - Y)) / v);
        }
        printf("%.10f\n", ans);

    return 0;
}


#include <stdio.h>
#define MAX 1000000007

int main()
{
	float a, b, x, y, v, ans = MAX;
	int n;
	scanf("%f %f", &a, &b);
	scanf("%d", &n);
	while(n--)
	{
		scanf("%f %f %f", &x, &y, &v);
		//printf("%.20f\n", sqrt((x - a) * (x - a) + (y - b) * (y - b)) / v);
		if(ans > sqrt((x - a) * (x - a) + (y - b) * (y - b)) / v)
		{
			ans = sqrt((x - a) * (x - a) + (y - b) * (y - b)) / v;
		}
	}
	printf("%.20f\n", ans);
	return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<math.h>
int main()
{
    int a,b,n,x,y;
    double v,min_dis=FLT_MAX,dis;
    scanf("%d %d %d",&a,&b,&n);
    while(n--)
    {
        scanf("%d %d %lf",&x,&y,&v);
        double vx=(a-x)*(a-x),vy=(b-y)*(b-y);
        dis=sqrt(vx+vy);
        dis=dis/v;
        if(min_dis>dis)
            min_dis=dis;
    }
    printf("%.20lf",min_dis);
    return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<float.h>
int main()
{
    int a,b,n,x,y;
    double v,min_dis=FLT_MAX,dis;
    scanf("%d %d %d",&a,&b,&n);
    while(n--)
    {
        scanf("%d %d %lf",&x,&y,&v);
        double vx=abs(a-x),vy=abs(b-y);

        dis=vx/v+vy/v;
        if(min_dis>dis)
            min_dis=dis;
    }
    printf("%.20lf",min_dis);
    return 0;
}


#include <stdio.h>
#include <math.h>

int main()
{
    int n;
    double a,b,x,y,v,res=100000000000000;

    scanf("%lf%lf",&a,&b);

    scanf("%d",&n);

    int i;

    for (i = 0; i < n; i++)
    {
        scanf("%lf%lf%lf",&x,&y,&v);

        double dx = x - a;

        double dy = y - b;

        double X = sqrt(dx * dx + dy * dy);

        double t = X / v;

        if(res<t) res=res;
        else res=t;
    }

    printf("%.20lf\n",res);

    return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define ms(a) memset(a,0,sizeof(a))
typedef long long ll;
const int INF = INT_MAX;
const int MAXN = 12 + 1;
const int MOD = 100000000;
using namespace std;
int main()
{
	int sx, sy;
	int n;
	double ans = INF;
	cin >> sx >> sy >> n;
	for (int i = 0; i < n; i++)
	{
		int x, y, v;
		cin >> x >> y >> v;
		ans = min(ans, sqrt(abs(x - sx)*abs(x - sx) + abs(y - sy)*abs(y - sy)) / (v*1.0));
	}
	printf("%.20lf\n", ans);
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    int a,b;
    int n;
    int i;

    scanf("%d %d",&a,&b);
    scanf("%d",&n);

    int x[n],y[n],v[n];
    float s[n],t[n];

    for(i=0;i<n;i++)
        {scanf("%d %d %d",&x[i],&y[i],&v[i]);}
    for(i=0;i<n;i++)
        s[i]=sqrt((a-x[i])*(a-x[i])+(b-y[i])*(b-y[i]));
    for(i=0;i<n;i++)
    {
        t[i]=s[i]/v[i];
    }

    float min=t[0];
    for(i=1;i<n;i++)
    {
        if(t[i]<min)
            min=t[i];

    }
    printf("%.20f",min);
    return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define ms(a) memset(a,0,sizeof(a))
typedef long long ll;
const int INF = INT_MAX;
const int MAXN = 12 + 1;
const int MOD = 100000000;
using namespace std;
int main()
{
	int sx, sy;
	int n;
	double ans = INF;
	cin >> sx >> sy >> n;
	for (int i = 0; i < n; i++)
	{
		int x, y, v;
		cin >> x >> y >> v;
		ans = min(ans, sqrt(abs(x - sx)*abs(x - sx) + abs(y - sy)*abs(y - sy)) / (v*1.0));
	}
	printf("%.202f\n", ans);
	return 0;
}


#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <ctime>
#include <string>
#include <cstdio>
#include <vector>
#include <cctype>
#include <climits>
#include <sstream>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
#define ms(a) memset(a,0,sizeof(a))
typedef long long ll;
const int INF = INT_MAX;
const int MAXN = 12 + 1;
const int MOD = 100000000;
using namespace std;
int main()
{
	int sx, sy;
	int n;
	double ans = INF;
	cin >> sx >> sy >> n;
	for (int i = 0; i < n; i++)
	{
		int x, y, v;
		cin >> x >> y >> v;
		ans = min(ans, sqrt(abs(x - sx)*abs(x - sx) + abs(y - sy)*abs(y - sy)) / (v*1.0));
	}
	printf("%.200f\n", ans);
	return 0;
}


#incude<stdio.h>
#include<math.h>
//using namespace std;
int main(){
	int i,t,n,a,b,x,y,v;
//	cin>>a>>b;
	scanf("%d%d",&a,&b);
//	cin>>n;
	scanf("%d",&n);
	double min = 0;
	double time[n];
	for(i=0;i<n;i++){
		cin>>x>>y>>v;
		time[i] = (sqrt((a-x)*(a-x) + (b-y)*(b-y)))/v;
	}
	for(i=0;i<n;i++){
		if(time[i] < min){
			min = time[i];
		}
	}
	//cout<<min<<"\n";
	printf("%lf\n",min);
	return 0;
}


#include<stdio.h>
#include<math.h>
//using namespace std;
int main(){
	int i,t,n,a,b,x,y,v;
//	cin>>a>>b;
	scanf("%d%d",&a,&b);
//	cin>>n;
	scanf("%d",&n);
	double min = 0;
	double time[n];
	for(i=0;i<n;i++){
		//cin>>x>>y>>v;
		scanf("%d%d%d",x,y,v);
		time[i] = (sqrt((a-x)*(a-x) + (b-y)*(b-y)))/v;
	}
	for(i=0;i<n;i++){
		if(time[i] < min){
			min = time[i];
		}
	}
	//cout<<min<<"\n";
	printf("%lf\n",min);
	return 0;
}


#include<stdio.h>
#include<math.h>
//using namespace std;
int main(){
	int i,t,n,a,b,x,y;
	float v;
//	cin>>a>>b;
	scanf("%d%d",&a,&b);
//	cin>>n;
	scanf("%d",&n);
	double min = 1000000;
	double time[n];
	for(i=0;i<n;i++){
		//cin>>x>>y>>v;
		scanf("%d%d",&x,&y);
		scanf("%f",&v);
	//	printf("%d",sqrt(9));
		time[i] = ((sqrt((a-x)*(a-x) + (b-y)*(b-y)))*1.0)/v;
	//	printf("%f\n",time[i]);
	}
	for(i=0;i<n;i++){
		if(time[i] < min){
			min = time[i];
		}
	}
	//cout<<min<<"\n";
	printf("%f\n",min);
	return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    double x1,y1,x,y,v,j,k,r,t,temp;
    int n,i;
    scanf("%lf%lf%d",&x1,&y1,&n);

    for(i=0;i<n;i++){
        scanf("%lf%lf%lf",&x,&y,&v);
        r=(x1-x)*(x1-x)+(y1-y)*(y1-y);
        temp=sqrt(r)/v;
    if(i==0){t=temp;}
    else if(temp<t){t=temp;}

    }

     printf("%lf",t);
     return 0;
}


#include <stdio.h>
#include <math.h>

int main(void)
{
    int a, b, n, i, x, y, v, j;

    scanf("%d %d", &a, &b);
    scanf("%d", &n);
    double time[n], min;

    for(i = 0; i < n; i++){
        scanf("%d %d %d", &x, &y, &v);
        time[i] = (double)sqrt(pow(a - x, 2) + pow(b - y, 2)) / v;
       // printf("%0.5lf\n", time[i]);
    }
    min = time[0];
    for(j = 1; j < n; j++){
        if(min > time[j])
            min = time[j];
    }
    printf("%0.20lf\n", min);

    return 0;
}


#include <stdio.h>
#include <math.h>

int main(void)
{
    int a, b, n, i, x, y, v;

    scanf("%d %d", &a, &b);
    scanf("%d", &n);
    double time[n], min;

    for(i = 0; i < n; i++){
        scanf("%d %d %d", &x, &y, &v);
        time[i] = (double)sqrt(pow(a - x, 2) + pow(b - y, 2)) / v;
        min = time[0];
        if(min > time[i])
            min = time[i];
    }
    printf("%0.20lf\n", min);

    return 0;
}


#include <stdio.h>
#include <math.h>

int sqr(int a){
    return a * a;
}

int main(void)
{
    int a, b, n;
    scanf("%d%d%d", &a, &b, &n);
    int x, y, v;
    double tmin, t;
    scanf("%d%d%d", &x, &y, &v);
    tmin = sqrt(sqr(a - x) + sqr(b - y)) / v;
    for(int i = 1; i < n; i++){
        scanf("%d%d%d", &x, &y, &v);
        t = sqrt(sqr(a - x) + sqr(b - y)) / v;
        tmin = t > tmin ? tmin : t;
    }
    printf("%.12g", tmin);
}


#include<stdio.h>
#include<math.h>
main()
{
    int n,i;
    double tf=1000000000,t,s,a,b,x,y,v;
    scanf("%lf %lf",&a,&b);
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%lf %lf %lf",&x,&y,&v);
        s=sqrt(((x-a)*(x-a))+((y-b)*(y-b)));
        t=s/v;
        if(t<=tf)
        {
            tf=t;
        }

    }
    printf("%lf",tf);

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>

typedef struct point
{
    int x;
    int y;
}Point;

typedef struct taxi
{
    Point taxi_coordinates;
    int v;
}Taxi;

int main()
{
    Point home;
    fscanf( stdin , "%d %d" , &home.x , &home.y );

    unsigned n;
    fscanf( stdin , "%u", &n );

    Taxi cars[ n ];
    double d[ n ];
    double t[ n ];
    double min;

    for(int i = 0;i < n;i++)
    {
        fscanf( stdin , "%d %d %d" , &cars[ i ].taxi_coordinates.x ,
               &cars[ i ].taxi_coordinates.y , &cars[ i ].v );
        d[ i ] = sqrt( pow(cars[ i ].taxi_coordinates.x - home.x , 2) + pow(cars[ i ].taxi_coordinates.y - home.y , 2 ) );
        t[ i ] = d[ i ] / cars[ i ].v;

        if(i == 0)
            min = t[ 0 ];
        else if(t[ i ] < min)
            min = t[ i ];

    }

    printf("%f\n" , min );

    return 0;
}


#include <stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
    float a, b, x, y;
    int n, i, j;
    scanf("%f %f", &a, &b);
    scanf("%d", &n);
    float** cab;
    cab = (float **)malloc(n * sizeof(float *));
    for(i = 0; i < n; i++)
    {
        cab[i] = (float *)malloc(3 * sizeof(float));
    }
    for(i = 0; i < n; i++)
    {
        scanf("%f %f %f", &cab[i][0], &cab[i][1], &cab[i][2]);
    }

    float tim[n];
    for(i = 0; i < n; i++)
    {
        x = cab[i][0] - a;
        y = cab[i][1] - b;
        tim[i] = sqrt(x*x + y*y) / cab[i][2];
    }
    float min = tim[0];
    for(i = 1; i < n; i++)
    {
        if(tim[i] < min)
            min = tim[i];
    }
    printf("%f", min);
    return 0;
}


#include <stdio.h>
#include<math.h>

int main()
{
    float a, b, x, y;
    int n, i, j;
    scanf("%f %f", &a, &b);
    scanf("%d, &n");
    float cab[n, 3];
    for(i = 0; i < n; i++)
    {
        scanf("%f %f %f", &cab[i][0], &cab[i][1], &can[i][2]);
    }

    float tim[n];
    for(i = 0; i < n; i++)
    {
        x = cab[i][0] - a;
        y = cab[i][1] - b;
        tim[i] = sqrt(x*x + y*y) / cab[i][2];
    }
    float min = tim[0];
    for(i = 1; i < n; i++)
    {
        if(tim[i] < min)
            min = tim[i];
    }
    printf("%f", min);
    return 0;
}


#include <stdio.h>
#include <math.h>
int main()
{
	int a,b;
	scanf("%d %d ",&a,&b);
	int n;
	scanf("%d ",&n);
	int i,x,y,v;
	double t[10001],dis;
	double r;
	for(i=0;i<n;i++)
	{
		scanf("%d %d %d ",&x,&y,&v);
		r=(a-x)*(a-x)+(b-y)*(b-y);
		dis=sqrt(r);
		t[i]=dis/v;
	}
	double min=t[0];
	for(i=0;i<n;i++)
	{
		if(t[i]<min)
		min=t[i];
	}
	printf("%lf",min);
	return 0;

}


#include <stdio.h>
#include <stdlib.h>
#include <math.h>

double time(double dist, double velo){
    double t;
    t = (double)dist/velo;
    return (double)t;
}

double distance(double x,double y,double a,double b){
double xs = (x-a)*(x-a);
double ys = (y-b)*(y-b);
double ss = xs+ys;
double s = sqrt(ss);
return (double)s;
}

int main()
{
    int a,b,n,*arrx,*arry,*arrv,i,j;
    scanf("%d%d%d",&a,&b,&n);
    arrx = (int*)malloc(n*sizeof(int));
    arry = (int*)malloc(n*sizeof(int));
    arrv = (int*)malloc(n*sizeof(int));
    double *distanc,*tim;
    distanc = (double*)malloc(n*sizeof(double));
    tim = (double*)malloc(n*sizeof(double));
    for(i = 0;i<n;i++){
        scanf("%d%d%d",&arrx[i],&arry[i],&arrv[i]);
    }
    for(i = 0;i<n;i++){
        distanc[i] = distance(arrx[i],arry[i],a,b);
        tim[i] = time(distanc[i],arrv[i]);
    }
    double min = tim[0];
    for(j = 0;j<n;j++){

            if(tim[j]<min){
                    min = tim[j];
            }

    }
    printf("%.12lf",min);
    return 0;
}


#include<stdio.h>
#include<math.h>
#include<limits.h>

double mesafe(int x1 , int y1 , int x2 , int y2)
{
    double a = pow(x1-x2 , 2 ) + pow(y1 - y2 , 2);

    return sqrt(a);
}

int main()
{
    int x1 , y1 ;
    scanf("%d %d",&x1,&y1);

    int n ;
    scanf("%d",&n);

    int i ;
    double min = INT_MAX ;

    int  x2 , y2 , v ;

    for(i=0;i<n;i++)
    {
        scanf("%d %d %d",&x2 , &y2,&v);
        double a = mesafe(x1 , y1 , x2 , y2)/v ;
        if(min > a)
        {
            min = a ;
        }
    }

    printf("%lf",min);

    return 0 ;
}


#include<stdio.h>
#include<math.h>
int main()
{
    double a,b,n,v,i,j,m,value,x,y;
    scanf("%lf %lf",&a,&b);
    scanf("%lf",&n);
    for(j=1;j<=n;j++){
       scanf("%lf %lf %lf",&x,&y,&v);
        i=sqrt((a-x)*(a-x)+(b-y)*(b-y));
        value=i/v;
        if(j==n-1){
            m=value;
        }
        if(value<=m){
            m=value;
        }
    }
    printf("%.20lf\n",m);
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{
    double a,b,n,v,i,j,m,value,x,y;
    scanf("%lf %lf",&a,&b);
    scanf("%lf",&n);
    for(j=1;j<=n;j++){
       scanf("%lf %lf %lf",&x,&y,&v);
        i=sqrt((a-x)*(a-x)+(b-y)*(b-y));
        value=i/v;
        if(j==1){
            m=value;
        }
        else if(value<=m){
            m=value;
        }
    }
    printf("%.20lf\n",m);
    return 0;
}


#include<stdio.h>
#include<math.h>
int main()
{	int a,b,n,i,j;
	int x[1001];
	int y[1001];
	int v[1001];
	double num[1001];
	double sum,t;
	double min=1e100;
	scanf("%d%d",&a,&b);
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{	scanf("%d%d%d",&x[i],&y[i],&v[i]);
		num[i]=(double)(sqrt((x[i]-a)*(x[i]-a)+(y[i]-b)*(y[i]-b)))/v[i];
	}
	for(i=1;i<=n;i++)
		if(min>num[i])
			min=num[i];
		printf("%.20f",min);
}


#include<stdio.h>
#include<math.h>
int main()
{
int  x,y,n,p,q,v,i,t=0,m=0;
double sum,ans;
scanf("%d%d",&x,&y);
scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d%d%d",&p,&q,&v);
t=p-x;
m=q-y;
sum=sqrt(t*t+m*m);
ans=sum/v;
if(i==0)
t=ans;
else
{
if(ans<t)
t=ans;
}
}
printf("%.15lf",ans);
}


#include<stdio.h>
#include<math.h>
int main()
{
int  x,y,n,p,q,v,i,t=0,m=0;
double sum,ans,j=0;
scanf("%d%d",&x,&y);
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&p,&q,&v);
t=p-x;
m=q-y;
sum=sqrt((t*t)+(m*m));
ans=sum/v;
if(i==0)
j=ans;
else
{
if(ans<j)
j=ans;
}
}
printf("%.15lf",j);
}


#include<stdio.h>
#include<math.h>
int main()
{
int  x,y,n,p,q,v,i,t=0,m=0,j=0;
double sum,ans;
scanf("%d%d",&x,&y);
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&p,&q,&v);
t=p-x;
m=q-y;
sum=sqrt(t*t+m*m);
ans=sum/v;
if(i==0)
j=ans;
else
{
if(ans<j)
j=ans;
}
}
printf("%.15lf",ans);
}


#include<stdio.h>
#include<math.h>
int main()
{
int  x,y,n,p,q,v,i,t,m;
float sum,ans;
scanf("%d%d",&x,&y);
scanf("%d",&n);

for(i=0;i<n;i++)
{
scanf("%d%d%d",&p,&q,&v);
t=abs(p-x);
m=abs(q-y);
sum=sqrt((float)t*t+m*m);
ans=sum/v;
if(i==0)
t=ans;
if(ans<t)
t=ans;
}
printf("%.6f",ans);

}


#include<stdio.h>
#include<math.h>
int main()
{
int  x,y,n,p,q,v,i,t=0,m=0;
double sum,ans,j=0;
scanf("%d%d",&x,&y);
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d%d%d",&p,&q,&v);
t=p-x;
m=q-y;
sum=sqrt(t*t+m*m);
ans=sum/v;
if(i==0)
j=ans;
else
{
if(ans<j)
j=ans;
}
}
printf("%.15lf",ans);
}


#include<stdio.h>
#include<math.h>
#define MAX_I 1000

int a, b;//cordinates of Vasiliy's home
int n;//number of taxi
int x[MAX_I], y[MAX_I], v[MAX_I];//taxi cordinates and speed
float ans[MAX_I];//time of taxi
int c[MAX_I];//dirtect of Vasiliy's home

void bubble(float  *a,int n) /*定义两个参数：数组首地址与数组大小*/
{

    int i, j, temp;
    for(i = 0; i < n-1; i++)
        for(j = i+1; j < n; j++) /*注意循环的上下限*/
            if(a[i] > a[j])
            {

                temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
}

int main()
{
    scanf("%d %d", &a, &b);
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
        scanf("%d %d %d", &x[i], &y[i], &v[i]);

    for(int i = 0; i < n; i++)
    {
        c[i] = sqrt(x[i] * x[i] + y[i] * y[i]);
        ans[i] = c[i] / v[i];
    }

    bubble(ans, n);
    printf("%f", ans[0]);
    return 0;

}


fun gcd(a: Long, b: Long): Long {
	if (a == 0L) return b
	return gcd(b % a, a)
}

fun main() {
	repeat(readLine()!!.toInt()) {
		val (m, d, w) = readLine()!!.split(' ').map { it.toLong() }
		val w2 = w / gcd(d - 1, w)
		val mn = minOf(m-1, d-1)
		var cnt = mn / w2
		println((2 * (mn - w2) - w2 * (cnt - 1)) * cnt / 2 +mn)
	}
}


fun gcd(a: Long, b: Long): Long {
	if (a == 0L) return b
	return gcd(b % a, a)
}

fun main() {
	repeat(readLine()!!.toInt()) {
		val (m, d, w) = readLine()!!.split(' ').map { it.toLong() }
		val w2 = w / gcd(d - 1, w)
		val mn = minOf(m, d)
		var cnt = mn / w2
		println((2 * (mn - w2) - w2 * (cnt - 1)) * cnt / 2)
	}
}


import java.util.*

private inline fun debug(str: () -> Any?) = println(str().toString()) //{}
private inline fun readInt() = reader.nextInt()
private inline fun readLong() = reader.nextLong()
private inline fun readDouble() = reader.nextDouble()
private inline fun readArr() = readLine()!!.split(" ").map { it.toInt() }
private inline fun readArr(n: Int) = List<Int>(n) { reader.nextInt() }
private inline fun readArrLong() = readLine()!!.split(" ").map { it.toLong() }
private inline fun readArrLong(n: Int) = List<Long>(n) { reader.nextLong() }
private inline fun readArrDouble() = readLine()!!.split(" ").map { it.toDouble() }
private inline fun readArrDouble(n: Int) = List<Double>(n) { reader.nextDouble() }
private inline fun readLineAsCharList() = reader.nextLine().asSequence().toList()
private inline fun readAndSolve(f: () -> Unit): Unit {
    val n = readInt()
    // usually n is the only value in string
    reader.nextLine()
    repeat(n) { f() }
}

private fun Boolean.yn() = if (this) "YES" else "NO"
private fun <T> Iterable<T>.out() = this.joinToString(" ")
private val reader = Scanner(System.`in`.bufferedReader()).apply { useLocale(Locale.US) }

@ExperimentalStdlibApi
fun main() = solve1389E()

@ExperimentalStdlibApi
private fun solve1389E() {
    readAndSolve {
        val (m,d,w) = readArrLong(3)
        tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

        val gcdDW = gcd(d-1, w)
        val ww = w/gcdDW

        // дальше ищем y-x=0 (mod ww)

        // верхняя граница решений
        val upperBound = minOf(m, d)
        val greaterSolutions = upperBound % ww
        val loops  = upperBound/ww
        val ans = + ww * (loops * (loops - 1) / 2) + greaterSolutions * loops

        //println("x = y mod $ww, $upperBound >= y > x, $greaterSolutions, $loops, $ans")
        println("$ans")
    }
}


import java.io.BufferedReader
import java.io.InputStreamReader
import kotlin.math.min

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val out = StringBuilder()
    for (c in 1..jin.readLine().toInt()) {
        val (m, d, w) = jin.readLine().split(" ").map { it.toLong() }
        val mod = w / gcd(d - 1L, w)
        val lambda = min(m, d)
        val gamma = lambda / mod
        val nu = lambda % mod
        val answer = ((mod - nu) * ((gamma * (gamma - 1L)) / 2L)) + (nu * (((gamma + 1L) * gamma) / 2L))
        out.appendln(answer)
    }
    print(out)
}

fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class _1389E {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int T = 1;
		T = fs.nextInt();
		for(int tt = 1; tt <= T; tt++) {
			long m, d, w;
			m = fs.nextLong();
			d = fs.nextLong();
			w = fs.nextLong();

			//(x-y)(d-1) divisible by w, so (x-y) is divisible by w/gcd(w, d-1)
			w /= gcd(w, d-1);

			m = Math.min(m, d);

			long cnt = m/w;

			long ans = m * cnt - w * (cnt) * (cnt+1) / 2;

			System.out.println(ans);
		}
	}

	static long gcd(long a, long b) {
		if (b == 0L)
			return a;
		return gcd(b, a % b);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

		long nextLong()
        {
            return Long.parseLong(next());
        }
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class _1389E {

	public static void main(String[] args) {
		FastScanner fs=new FastScanner();
		int T = 1;
		T = fs.nextInt();
		for(int tt = 1; tt <= T; tt++) {
			long m, d, w;
			m = fs.nextLong();
			d = fs.nextLong();
			w = fs.nextLong();

			//(x-y)(d-1) divisible by w, so (x-y) is divisible by w/gcd(w, d-1)
			w /= gcd(w, d-1);

			m = Math.min(m, d);

			/*
			   https://youtu.be/WcPU4DcIlk8?t=5534 (for reference)
			   We want x and y to be same under mod of w' i.e. w/gcd(w, d-1)

			   we will get remainders of the form of 0,1,2,3...w'-1; 0,1,2,3...w'-1; 0,1,...
			   Now we have to choose 2 numbers x and y for each of the remainders

			*/

			long full = m / w; //like 0,1,2,3....w'-1
			long partial = m % w; //like 0,1,2,3...k (not reached w'-1)

			long ans = nC2(full) * (w - partial) + nC2(full+1) * partial;

			System.out.println(ans);
		}
	}

	static long nC2(long n) {
		return n * (n-1) / 2;
	}

	static long gcd(long a, long b) {
		if (b == 0L)
			return a;
		return gcd(b, a % b);
	}

	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}

		long nextLong()
        {
            return Long.parseLong(next());
        }
	}
}