import java.io.*; import java.util.*; public class Solution { public static void main(String[] args) { Scanner readIn = new Scanner(System.in); int n = readIn.nextInt(); int x = readIn.nextInt(); int y = readIn.nextInt(); ArrayList cities = new ArrayList<>(n); for(int ii = 0; ii < n; ii++) cities.add(new City(readIn.nextInt(), readIn.nextInt(), readIn.nextInt(), readIn.nextInt())); Collections.sort(cities); int outMax = cities.get(n - 1).points; for(int ii = n - 2; ii >= 0; ii--) { City current = cities.get(ii); int additionalPoints = 0; for(int jj = ii + 1; jj < n; jj++) { City next = cities.get(jj); if(Math.abs(next.lattitude - current.lattitude) <= x && Math.abs(next.longitude - current.longitude) <= x && next.points > additionalPoints) additionalPoints = next.points; if(additionalPoints == outMax) break; } current.points += additionalPoints; outMax = outMax > current.points ? outMax : current.points; } System.out.println(outMax); } } class City implements Comparable { public int lattitude; public int longitude; public int height; public int points; public City(int la, int lo, int height, int points) { this.lattitude = la; this.longitude = lo; this.height = height; this.points = points; } public int compareTo(City other) { return this.height - other.height; } }