Олимпиадный тренинг

Задача 44657. Numbers equal to the given


It is required to determine the number of the leftmost and rightmost element in the given array equal to the desired number.

 

Input

The first line contains one natural number N not exceeding 105: the number of numbers in the array.

The second line contains N natural numbers not exceeding 109, each successive number is at least as great.

The third line contains the number of numbers to be searched for M - a natural number not exceeding 106.

The fourth line contains M of natural numbers not exceeding 109.

 

Imprint

For each query, print two numbers separated by a space on a separate line: the number of the element of the leftmost and rightmost elements of the array equal to the number-query. Array elements are numbered starting from one.

If there is no such number in the array, print two space-separated zeros in the corresponding line.

 
Examples
# Input Output
1
4
1 2 2 3
4
4 3 2 1
0 0
4 4
2 3
1 1