exhausted, and chose to record every one of the stages that she might actually acquire by performing precisely one procedure on the underlying change. Obviously, Alice is extremely savvy, so she recorded each realistic change precisely once (regardless of in the number of ways it tends to be acquired), and obviously the rundown was arranged lexicographically.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Correct answer will be upvoted else Multiple Downvoted. Computer science.

 

she got truly exhausted, and chose to record every one of the stages that she might actually acquire by performing precisely one procedure on the underlying change. Obviously, Alice is extremely savvy, so she recorded each realistic change precisely once (regardless of in the number of ways it tends to be acquired), and obviously the rundown was arranged lexicographically. 

 

Presently Bob might want to pose Alice a few inquiries about her rundown. Each question is in the accompanying structure: what is the I-th number in the j-th change that Alice recorded? Since Alice is too exhausted to even think about addressing these inquiries, she requested that you help her out. 

 

Input 

 

The primary line contains a solitary integer t (1≤t≤30) — the number of experiments. 

 

The primary line of each experiment contains three integers n, c, q (1≤n≤3⋅104, 1≤c≤4, 1≤q≤3⋅105) — the length of the change, the most extreme expense of the activity, and the number of questions. 

 

The following line of each experiment contains n integers p1,p2,… ,pn (1≤pi≤n, pi≠pj if i≠j), depicting the underlying stage. 

 

The accompanying q lines depict the questions. Every one of them contains two integers I and j (1≤i≤n, 1≤j≤1018), signifying boundaries of this question. 

 

It is ensured that the amount of qualities n over all experiments doesn't surpass 3⋅105, and the amount of qualities q over all experiments doesn't surpass 3⋅105. 

 

Output 

 

For each inquiry output the response for this question, or −1 if j-th stage doesn't exist in her rundown.

 

 

 

 

 

Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Knowledge Booster
System Model Approaches
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education