/* Author : akgarhwal Date : 14-02-2017 21:49:50 Description : */ #include using namespace std; typedef long long ll; typedef vector vi; typedef pair ii; #define fisrt FF #define second SS #define sz(a) int((a).size()) #define pb push_back #define all(c) (c).begin(),(c).end() #define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) #define present(c,x) ((c).find(x) != (c).end()) #define cpresent(c,x) (find(all(c),x) != (c).end()) int a[100000][4]; int main(){ //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); int n,x,y,t; cin>>n>>x>>y; for(int i=0; i< n; i++){ cin>>t; a[i][0] = t; cin>>t; a[i][1] = t; cin>>t; a[i][2] = t; cin>>t; a[i][3] = t; } //sort(a,a+n); ll res=0ll; ll ans=0; for(int i=0; i< n-1; i++){ int A = a[i][0],b = a[i+1][0]; int c = a[i][1],d = a[i+1][1]; if( abs(A-b)<=x and abs(c-d)<= y and a[i][2] < a[i+1][2]){ res += (a[i][3]); ans = max(ans,res); } } cout<