#include <bits/stdc++.h>
using namespace std;

int main(){
  int N = 0;
  vector<double> UFO(2);
  
  cin >> N;
  
  for (double &x : UFO){
    cin >> x;
  }
  
  vector<vector<double>> buildings (N, vector<double> (2));
  
  for (vector<double> &d : buildings){
    for (double &f : d){
      cin >> f;
    }
  }
  
  double e = 0;
  double y = 0;
  
  for (int i = 0; i < N; i++){
    //y = 10 - 10e, y = 5 - 3e
    //10e - 3e = 10 - 5
    e = (UFO.at(1) - buildings.at(i).at(1)) / (UFO.at(0) - buildings.at(i).at(0));
    y = max(y, UFO.at(1) - UFO.at(0) * e);
  }
  
  cout << setprecision(16) << y << endl;

}

#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define int ll
#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<int>

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 1e13 ;
const ll MOD = 1000000007;
const int N = 18;

int x[N] , y[N] , z[N];
int dp[1LL << N][N];
int DIS[N][N];
int n;
int dis(int from , int to){
	return abs(x[to] - x[from]) + abs(y[to] - y[from]) + max(0LL, z[to] - z[from]);
}
int get_dis(int from , int to){
	return DIS[from][to];
}
int fun(int mask , int src){
	if(__builtin_popcountll(mask) == n)
		return dis(src , 0);
	if(dp[mask][src]!= -1)
		return dp[mask][src];
	int ans = oo;
	for(int i = 1 ; i < n ; i++){
		if((mask >> i) & 1)
			continue;
		ans = min(ans , dis(src , i) + fun(mask | (1 << i) , i));
	}
	return dp[mask][src] = ans;
}
		
		

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

	memset(dp , -1 , sizeof dp);

	cin >> n;
	fo(i , n) cin >> x[i] >> y[i] >> z[i];

	fo(i , n) fo(j , n) if(i!=j) DIS[i][j] = oo; else DIS[i][j] = 0;

	cout << fun(1 , 0) << '\n';

	
    return 0;
}




