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(); int p=0; int[] latitude=new int[n]; int[] longitude=new int[n]; int[] height=new int[n]; int[] points=new int[n]; for(int a0 = 0; a0 < n; a0++){ latitude[a0] = in.nextInt(); longitude[a0] = in.nextInt(); height[a0] = in.nextInt(); points[a0]= in.nextInt(); } p=points[0]; int a=0; for(int i=1;iheight[a])) { a++; p+=points[i]; } } System.out.println(p); } }