{"problem":{"name":"Ex - K-th beautiful Necklace","description":{"content":"We have $N$ gemstones. The color and beauty of the $i$\\-th gemstone are $D_i$ and $V_i$, respectively.   Here, the color of each gemstone is one of $1, 2, \\ldots, C$, and there is at least one gemston","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc252_h"},"statements":[{"statement_type":"Markdown","content":"We have $N$ gemstones. The color and beauty of the $i$\\-th gemstone are $D_i$ and $V_i$, respectively.  \nHere, the color of each gemstone is one of $1, 2, \\ldots, C$, and there is at least one gemstone of each color.\nOut of the $N$ gemstones, we will choose $C$ with distinct colors and use them to make a necklace. (The order does not matter.) The beautifulness of the necklace will be the bitwise $\\rm XOR$ of the chosen gemstones.\nAmong all possible ways to make a necklace, find the beautifulness of the necklace made in the way with the $K$\\-th greatest beautifulness. (If there are multiple ways with the same beautifulness, we count all of them.)\nWhat is bitwise $\\rm XOR$?The bitwise $\\rm XOR$ of integers $A$ and $B$, $A \\oplus B$, is defined as follows:\n\n*   When $A \\oplus B$ is written in base two, the digit in the $2^k$'s place ($k \\geq 0$) is $1$ if either $A$ or $B$, but not both, has $1$ in the $2^k$'s place, and $0$ otherwise.\n\nFor example, $3 \\oplus 5 = 6$. (In base two: $011 \\oplus 101 = 110$.)\n\n## Constraints\n\n*   $1 \\leq C \\leq N \\leq 70$\n*   $1 \\leq D_i \\leq C$\n*   $0 \\leq V_i < 2^{60}$\n*   $1 \\leq K \\leq 10^{18}$\n*   There are at least $K$ ways to make a necklace.\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $C$ $K$\n$D_1$ $V_1$\n$\\vdots$\n$D_N$ $V_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc252_h","tags":[],"sample_group":[["4 2 3\n2 4\n2 6\n1 2\n1 3","5\n\nThere are four ways to make a necklace, as follows.\n\n*   Choose the $1$\\-st and $3$\\-rd gemstones to make a necklace with the beautifulness of $4\\ {\\rm XOR}\\ 2 =6$.\n*   Choose the $1$\\-st and $4$\\-th gemstones to make a necklace with the beautifulness of $4\\ {\\rm XOR}\\ 3 =7$.\n*   Choose the $2$\\-nd and $3$\\-rd gemstones to make a necklace with the beautifulness of $6\\ {\\rm XOR}\\ 2 =4$.\n*   Choose the $2$\\-nd and $4$\\-th gemstones to make a necklace with the beautifulness of $6\\ {\\rm XOR}\\ 3 =5$.\n\nThus, the necklace with the $3$\\-rd greatest beautifulness has the beautifulness of $5$."],["3 1 2\n1 0\n1 0\n1 0","0\n\nThere are three ways to make a necklace, all of which result in the beautifulness of $0$."],["10 3 11\n1 414213562373095048\n1 732050807568877293\n2 236067977499789696\n2 449489742783178098\n2 645751311064590590\n2 828427124746190097\n3 162277660168379331\n3 316624790355399849\n3 464101615137754587\n3 605551275463989293","766842905529259824"]],"created_at":"2026-03-03 11:01:14"}}