{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eYou\u0027ve been invited to the \"I-Love-Kd-trees\" annual con, but first, you have to show them that you really know about great data structures, so they give you an easy task!\u003c/p\u003e\r\n\u003cp\u003eYou are given a list of \u003cstrong\u003eN\u003c/strong\u003e numbers and \u003cstrong\u003eQ\u003c/strong\u003e queries, each query consist of three integers: \u003cem\u003e\u003cstrong\u003ek\u003c/strong\u003e\u003c/em\u003e, \u003cstrong\u003e\u003cem\u003ei\u003c/em\u003e\u003c/strong\u003e and \u003cstrong\u003e\u003cem\u003el\u003c/em\u003e\u003c/strong\u003e; let \u003cstrong\u003ed\u003c/strong\u003e be the \u003cstrong\u003ek-th\u003c/strong\u003e smallest element until the index \u003cstrong\u003ei\u003c/strong\u003e (i.e. if the first i+1 elements were sorted in non-descending way, \u003cstrong\u003ed \u003c/strong\u003ewould be the element at index \u003cstrong\u003ek - 1\u003c/strong\u003e). Then, the answer to each query is the index of the \u003cstrong\u003el-th\u003c/strong\u003e occurrence of \u003cstrong\u003ed\u003c/strong\u003e in the array. If there\u0027s no such index, the answer is \u003cstrong\u003e-1\u003c/strong\u003e. You have to consider that all indexes are counted starting with \u003cstrong\u003e0\u003c/strong\u003e.\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eInput consists of one test case.\u003c/p\u003e\r\n\u003cp\u003eThe first line contains two integers, \u003cstrong\u003eN\u003c/strong\u003e (1 ≤ N ≤ 10\u003csup\u003e5\u003c/sup\u003e) and \u003cstrong\u003eQ\u003c/strong\u003e (1 ≤ Q ≤ 10\u003csup\u003e5\u003c/sup\u003e).\u003c/p\u003e\r\n\u003cp\u003eThe next line contains \u003cstrong\u003eN\u003c/strong\u003e possibly distinct integers \u003cstrong\u003ea\u003csub\u003ei\u003c/sub\u003e\u003c/strong\u003e (-10\u003csup\u003e9\u003c/sup\u003e ≤ a\u003csub\u003ei\u003c/sub\u003e ≤ 10\u003csup\u003e9\u003c/sup\u003e).\u003c/p\u003e\r\n\u003cp\u003eThen \u003cstrong\u003eQ\u003c/strong\u003e lines follow, each of those contains three integers \u003cem\u003e\u003cstrong\u003ek\u003c/strong\u003e\u003c/em\u003e, \u003cem\u003e\u003cstrong\u003ei\u003c/strong\u003e\u003c/em\u003e and \u003cem\u003e\u003cstrong\u003el\u003c/strong\u003e\u003c/em\u003e. (0 \u0026lt; k ≤ i \u0026lt; N, 1 ≤ l ≤ N).\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eFor each query (in the same order as the input) output a single line with the answer to that query.\u003c/p\u003e\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n10 6\n2 6 7 1 8 1 2 3 2 6\n2 4 2\n2 6 3\n1 4 1\n1 4 2\n3 4 2\n3 3 2\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\n-1\n3\n5\n9\n9\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\r\n\u003ch3\u003eExplanation of the first query:\u003c/h3\u003e\r\n\u003cp\u003eThe elements until index 4 are [2,6,7,1,8] so the 2nd smallest element is 2, and your asked for the index of its 2nd occurrence, so the answer is 6.\u003c/p\u003e\n\u003c/div\u003e"}}]}