691 - I2P(II)2015_Yang_Lab1 Scoreboard

Time

2015/03/04 08:20:00 2015/03/04 09:40:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
10434 problem1

10434 - problem1   

Description

Consider an input string of length less than 1000.

For example, "abcdefgabcdefg".

We may denote a substring of this input string by a pair of indexes.
For example, the pair (5, 9) represents the substring "fgabc". (The index starts from 0, following the C convention.)

Now, given N pairs of the indexes representing N substrings, we are interested in sorting substrings that are remained after extracting N substrings we denote in alphabetical order. For example, if the three pairs are (0, 2), (5, 7), (6, 8), and (11, 11), then the remaining substrings are "de", "cd", "fg". (abcdefgabcdefg)
The output of the sorted substrings would be
cd
de
fg

Input

The first line contains an input string. The length of the input string is less than 1000.


The second line is an integer N indicating the number of substrings, where N<=100.

The next N lines are the N pairs of indexes denoting the N substrings. (The index of the first character in the input string is 0 as in the C array indexing convention.)

Output

The output contains sorted substrings that are remained in the input string after extracting the N substring we denote. Each line should be ended with a newline character '\n'.

Sample Input  Download

Sample Output  Download

Tags




Discuss