import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int x = in.nextInt(); int y = in.nextInt(); City[] cities = new City[n]; for (int i = 0; i < n; i++) { int latitude = in.nextInt(); int longitude = in.nextInt(); int height = in.nextInt(); int points = in.nextInt(); cities[i] = new City(latitude, longitude, height, points); } solve(cities, x, y); } private static void solve(City[] cities, int x, int y) { System.out.println(maxSubArraySum(cities, x, y)); } static int maxSubArraySum(City a[], int x, int y) { int size = a.length; int max_so_far = Integer.MIN_VALUE, max_ending_here = 0; for (int i = 0; i < size; i++) { max_ending_here = max_ending_here + a[i].points; if (max_so_far < max_ending_here) max_so_far = max_ending_here; if (max_ending_here < 0 || (i > 0 && (areTooFar(a[i], a[i - 1], x, y)))) max_ending_here = 0; } return max_so_far; } private static boolean areTooFar(City city1, City city2, int x, int y) { // TODO Auto-generated method stub return Math.abs(city2.latitude - city1.latitude) > x || Math.abs(city1.longitude - city2.longitude) > y; } } class City implements Comparable { int latitude, longitude, height, points; public City(int latitude, int longitude, int height, int points) { this.latitude = latitude; this.longitude = longitude; this.points = points; this.height = height; } @Override public int compareTo(City o) { return this.height = o.height; } }