P3014 [USACO11FEB] Cow Line S

Description

The N (1

Input Format

\* Line 1: Two space-separated integers: N and K \* Lines 2..2\*K+1: Line 2\*i and 2\*i+1 will contain a single query. Line 2\*i will contain just one character: 'Q' if the cows are lining up and asking Farmer John for their line number or 'P' if Farmer John gives the cows a line number. If the line 2\*i is 'Q', then line 2\*i+1 will contain N space-separated integers B\_ij which represent the cow line. If the line 2\*i is 'P', then line 2\*i+1 will contain a single integer A\_i which is the line number to solve for.

Output Format

\* Lines 1..K: Line i will contain the answer to query i. If line 2\*i of the input was 'Q', then this line will contain a single integer, which is the line number of the cow line in line 2\*i+1. If line 2\*i of the input was 'P', then this line will contain N space separated integers giving the cow line of the number in line 2\*i+1.