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); Graph g = new Graph(); int n = in.nextInt(); int x = in.nextInt(); int y = in.nextInt(); List nodes = new ArrayList<>(); for(int a0 = 0; a0 < n; a0++){ int la = in.nextInt(); int l = in.nextInt(); int h = in.nextInt(); int p = in.nextInt(); nodes.add(new Node(la,l,h,p)); } g.buildGraph(nodes, 1,1); g.maxPoints(); } private static class Graph{ Map> adjList; Map nameMap; public Graph() { this.adjList = new HashMap<>(); this.nameMap = new HashMap<>(); } private void addVertex(Node n, int x, int y){ for(int i =0;i edges = this.adjList.getOrDefault(i, new ArrayList<>()); edges.add(n); this.adjList.put(i, edges); } } } private void buildGraph(List nodes, int x , int y){ Collections.sort(nodes); int i =0; List newNodes = new ArrayList<>(); for(final Node node:nodes){ node.name =i; newNodes.add(node); this.nameMap.put(i, node); i++; } for(final Node node:newNodes){ this.addVertex(node, x, y); } } private void maxPoints(){ int size = this.nameMap.size(); Map visited = new HashMap<>(); Queue queue = new Queue(); long maxPoint = 0; long currPoint = 0; while (size>visited.size()) { for(int i =0;i())) { queue.enqueue(node.name); } } if(maxPoint{ int name; final int lat; final int lng; final Integer h; final int p; public Node(int lat, int lng, int h, int p) { this.lat = lat; this.lng = lng; this.h = h; this.p = p; } @Override public int compareTo(Node o) { return this.h.compareTo(o.h); } } }