#Lutece1301. Find the Stuff
Find the Stuff
Migrated from Lutece 1301 Find the Stuff
All parts of this problem, including description, images, samples, data and checker, might be broken. If you find bugs in this problem, please contact the admins.
Description
There are warehouses numbered with .
In each warehouse, there are stuff numbered with .
Now there is a robot facing to the warehouse. Every time the robot will pick up the stuff with the smallest number from the warehouse which it face to, and then turns to the next warehouse with stuff (the next of is ).
As a warehouse administrator, I want to find out the stuff that the robot picked up was in which warehouse and was the which number in that warehouse.
Input
The first line contains two numbers , indicating the number of warehouses and the number of queries.
The second line contains numbers , indicating the number of stuff in each warehouses.
Next lines each line contains one number , indicating the query.
Output
For each query output one line.
Each line contains two number , the stuff was in warehouse and was the stuff in that warehouse.
Samples
3 6
1 2 3
1
2
3
4
5
6
1 1
2 1
3 1
2 2
3 2
3 3
Resources
The 14th UESTC Programming Contest Preliminary