P3038 [USACO11DEC] Grass Planting G

Description

Farmer John has N barren pastures (2

Input Format

\* Line 1: Two space-separated integers N and M \* Lines 2..N: Two space-separated integers describing the endpoints of a road. \* Lines N+1..N+M: Line i+1 describes step i. The first character of the line is either P or Q, which describes whether or not FJ is planting grass or simply querying. This is followed by two space-separated integers A\_i and B\_i (1

Output Format

\* Lines 1..???: Each line has the answer to a query, appearing in the same order as the queries appear in the input.