Under construction

Still being built. Things may change

Photos

Time limit2sMemory limit1024 MB

Summary
Given a numbered list of photo file names and a list of intervals of photo numbers, output the file names in each interval in order.
Level

Easy2 of 10

Topics
Array, Implementation
Solved
No attempts yet

Input

Sergei is into digital photography. He recently decided to print some of his pictures and hang them on the wall in his hallway. He wrote down the file names of all the photos and numbered them in the order they appear in the list.

NumberFile name
1idx1001.jpg
2idx1000.jpg
3idx1014.jpg

After that, Sergei spent several hours picking his favorite shots. He usually liked several photos in a row, so he wrote down the number of the first and the last one in each run. The result was a list of intervals of photo numbers that he liked.

First photo numberLast photo numberCorresponding file names
23idx1000.jpg idx1014.jpg
12idx1001.jpg idx1000.jpg

Now Sergei wants a list of the file names of all the photos he liked. The list must first contain the file names of the photos in the first interval in increasing order of their numbers, then those of the second interval, and so on.

File names
idx1000.jpg
idx1014.jpg
idx1001.jpg
idx1000.jpg

The list can be very large, so Sergei asks you to help him.

Examples1

  1. Example 1

    Input
    3
    idx1001.jpg
    idx1000.jpg
    idx1014.jpg
    2
    2 3
    1 2
    
    Expected output
    idx1000.jpg
    idx1014.jpg
    idx1001.jpg
    idx1000.jpg