{"raw_statement":[{"iden":"problem statement","content":"There are $N$ cards placed on a grid with $H$ rows and $W$ columns of squares.\nThe $i$\\-th card has an integer $A_i$ written on it, and it is placed on the square at the $R_i$\\-th row from the top and the $C_i$\\-th column from the left.\nMultiple cards may be placed on the same square.\nYou will first pick up at most one card from each row.\nThen, you will pick up at most one card from each column.\nFind the maximum possible sum of the integers written on the picked cards."},{"iden":"constraints","content":"*   All values are integers.\n*   $1 \\leq N \\leq 10^5$\n*   $1 \\leq H, W \\leq 10^5$\n*   $1 \\leq A_i \\leq 10^5$\n*   $1 \\leq R_i \\leq H$\n*   $1 \\leq C_i \\leq W$"},{"iden":"input","content":"Input is given from Standard Input in the following format:\n\n$N$ $H$ $W$\n$R_1$ $C_1$ $A_1$\n$R_2$ $C_2$ $A_2$\n$\\vdots$\n$R_N$ $C_N$ $A_N$"},{"iden":"sample input 1","content":"6 2 2\n2 2 2\n1 1 8\n1 1 5\n1 2 9\n1 2 7\n2 1 4"},{"iden":"sample output 1","content":"28\n\nThe sum of the integers written on the picked cards will be $28$, the maximum value possible, if you pick up cards as follows:\n\n*   Pick up the fourth card from the first row.\n*   Pick up the sixth card from the second row.\n*   Pick up the second card from the first column.\n*   Pick up the fifth card from the second column."},{"iden":"sample input 2","content":"13 5 6\n1 3 35902\n4 6 19698\n4 6 73389\n3 6 3031\n3 1 4771\n1 4 4784\n2 1 36357\n2 1 24830\n5 6 50219\n4 6 22645\n1 2 30739\n1 4 68417\n1 5 78537"},{"iden":"sample output 2","content":"430590"},{"iden":"sample input 3","content":"1 100000 100000\n1 1 1"},{"iden":"sample output 3","content":"1"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}