1.

You are given an array A (distinct integers) of size N, and you are also given a sum. You need to find if two numbers in A exists that have sum equal to the given sum.

Input Format:
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains three lines of input. The first line contains N denoting the size of the array A. The second line contains N elements of the array. The third line contains element sum.

Output Format:
For each testcase, in a new line, print  "1"(without quotes) if any pair found, othwerwise print "0"(without quotes) if not found.

Your Task:
Since this is a function problem, you don't need to take any input. Just complete the provided function sumExists.

Constraints:
1 <= T <= 100
1 <= N <= 1000
1 <= Ai <= 106

Examples:
Input:

1
10
1 2 3 4 5 6 7 8 9 10
14
Output:
1

2.

You are given two arrays of size n1 and n2. Your task is to find all the elements that are common to both the arrays and sum them print them in the order as they appear in the second array. If there are no common elements the output would be 0.

Note: The arrays may contain duplicate elements. However, you need to sum only unique elements that are common to both arrays.

Input Format:
The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains two three lines of input. The first line contains n1 and n2 separated by a space. The second line contains elements of arr1. The third line contains elements of arr2.

Output Format:
For each testcase, in a new line, print the common sum.

Your Task:
Since this is a function problem, you don't need to take any input. Just complete the provided function commonSum that takes two arrays as input.

Constraints:
1 <= T <= 100
1 <= n1,n2 <= 1000
1 <= arr1i,arr2i <= 109

Example:
Input:

1
5 6
1 2 3 4 5
2 3 4 5 6 7
Output:
14

3.

Given an unsorted array of size N and value K. The elements of the array A contains positive integers. You have to print all the elements which are greater than K in the array(including K as well if present in the array A), and print all the elements which are smaller than K in seperate lines. If the elements greater than K does not present in the array then print "-1". Similarly, in case of smaller elements print -1 if elements smaller than k doesn’t exist.

Input Format:
First line of input contains number of testcases T. For each testcase, there are two lines, first of which contains N and K seperated by space, next line contains N space seperated integers.

Output Format:
For each testcase, print the required elements(if any), else print "-1" (without quotes).

Your Task:
Since this is a function problem, you don't need to take any input. Just complete the provided greaterKSorted and smallerKSorted functions that takes two input one is array and second is K.

Constraints:
1 <= T <= 100
1 <= N <= 103
1 <= K <= 106
1 <= A[i] <= 106

Example:
Input:

1
5 1
2 1 5 7 6

Output:
1 2 5 6 7
-1

4.

Given a sequence of non-negative integers, find the subsequence of length 3 having maximum product, with the elements of the subsequence being in increasing order.

Input: 
The first line of input contains number of testcases T. Each testcase contains 2 lines, the first line contains N, the number of elements in array, and second line contains space separated elements of array.

Output: 
Print the subsequence of size 3 having maximum product, numbers of subsequence being in increasing order. If no such sequence exists, print "-1".

User Task:
The task is to complete the function maxProductSubsequence() which finds maximum product of increasing subsequence of size 3. You should store answer in res array.

Constraints:
1 <= T <= 100
1 <= N <= 105
1 <= A[i] <= 105

Example:
Input:

3
8
6 7 8 1 2 3 9 10
4
3 4 2 1
6
1 2 20 10 11 12

Ouput:
8 9 10
-1
10 11 12

5.

Pasha is a strange guy. He has a string of length N. He wants to perform 2 types of queries on the string.
Type 1- Rotate the string by K character from the end.
Type 2- Print the Character at the I'th index of the resulting string at that Instant.

Now, Pasha wants to perform the 2 types of queries, But he is too lazy to do it himself.
So, you need to help him.
Input:
The first line contains an integer T-denoting the test cases.
The first line of each test cases contains two integers- N (Length of the string) and Q(Number of queries),
The second line contains the String.
Then Each of the next Q lines contains Typ of the query and K or I.
Output:
For each query of Type 2, Output the character at the I'th index in a new line.
Constraints:
1<=T<=10
1<=N<=100000
1<=Q<=10000
1<=TYP<=2
1<=K<=1000000000
0<=I
Example:
Sample Input:

1
7 5
abcdefg
1 2
2 0
2 6
1 4
2 1

Sample output:
f
e
c