using System; using System.Collections; using System.Collections.Generic; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ double Inf=1e16; double[][] dp=new double[1<<N][]; for(int i=0;i<(1<<N);i++){ dp[i]=new double[N]; for(int j=0;j<N;j++)dp[i][j]=Inf; } double[] Sum=new double[1<<N]; double tot=0; for(int i=0;i<N;i++)tot+=W[i]; for(int i=0;i<(1<<N);i++){ Sum[i]=tot; for(int j=0;j<N;j++){ if(((i>>j)&1)>0)Sum[i]-=W[j]; } } //for(int i=0;i<(1<<N);i++)Console.Write("{0} ",Sum[i]);Console.WriteLine(); for(int j=0;j<N;j++){ dp[1<<j][j]=W[j]+(Math.Abs(X[j]-X0)+Math.Abs(Y[j]-Y0))*(tot+100)/120; } for(int s=0;s<(1<<N);s++){ for(int j=0;j<N;j++){ if(dp[s][j]==Inf)continue; for(int k=0;k<N;k++){ if(((s>>k)&1)>0)continue; dp[s|(1<<k)][k]=Math.Min(dp[s|(1<<k)][k],dp[s][j]+W[k]+(Math.Abs(X[k]-X[j])+Math.Abs(Y[k]-Y[j]))*(Sum[s]+100)/120); } } } double Ans=Inf; for(int i=0;i<N;i++){ Ans=Math.Min(Ans,dp[(1<<N)-1][i]+(Math.Abs(X[i]-X0)+Math.Abs(Y[i]-Y0))*(0+100.0)/120.0); } Console.WriteLine(Ans); } int X0,Y0; int N; int[] X,Y; double[] W; public Sol(){ var d=ria(); X0=d[0];Y0=d[1]; N=ri(); X=new int[N]; Y=new int[N]; W=new double[N]; for(int i=0;i<N;i++){ var dd=rsa(); X[i]=int.Parse(dd[0]); Y[i]=int.Parse(dd[1]); W[i]=double.Parse(dd[2]); } } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(){return Console.ReadLine().Split(' ');} static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }