e-olymp
Competitions

Week 10: January 18 - 24

Names and characters

Given names of n people (numbered from 1 to n in the given order), where each name is written on a separate line.

Your task is to answer m queries of the form "A B", where A corresponds to the number of the person and B to the index of character of the persons' name.

For each query, print a single character corresponding to character of the person's name.

Input

First line contains number of people n (n105) and number of queries m (m1000). Each of the next n lines contains one name and can be up to 105 characters long. Each of the next m lines contains two numbers A (1An) and B (0B < length of the name of a person number A).

It is known that there won't be more than 106 characters in the input.

Output

For each query "A B" print a single character corresponding to character of the person's name. Print all characters in one line.

Time limit 1 second
Memory limit 128 MiB
Input example #1
3 5
Alice
Bob
John
1 3
2 1
3 2
3 3
1 0
Output example #1
cohnA
Author Farid Ahmadov