#P11340. TENIS Tournament

    ID: 13419 Type: Default 1000ms 256MiB

TENIS Tournament

TENIS Tournament

This problem is based on a modified tennis tournament from COI 2019 T4 - TENIS. There are N players (numbered from 1 to N) participating in a tournament held over N-1 rounds. For each of the three court surfaces (clay, grass, and hard), the players have a ranking from strongest to weakest. In each round, two players who have not yet been eliminated will be chosen and made to play on a chosen surface. On that surface the player with the lower ranking (i.e. the player that appears later in the ranking order) loses and is eliminated. After N-1 rounds the only remaining player is the champion.

Vito, who organizes the tournament, has complete control over the matches: he chooses both the two players and the court surface for each match, thus he can fix the outcomes. Furthermore, as his data changes over time, he may swap the positions of two players in the ranking of one of the surfaces. Along the way, he receives queries asking, "Does player X have a chance to win the tournament?"

A player X can be made champion if and only if for every other player Y there exists at least one surface s (with s in \(\{1,2,3\}\)) such that

[ \text{pos}_s(X) < \text{pos}_s(Y), ]

where \(\text{pos}_s(Z)\) is the position (rank) of player Z on surface s (with 1 being the best). In other words, for every other player \(Y\), player \(X\) must be able to defeat \(Y\) on at least one of the three surfaces if Vito schedules that match on that surface.

inputFormat

The first line contains two integers N and Q (2 ≤ N, Q ≤ 105) — the number of players and the number of operations.

The next 3 lines each contain N distinct integers. The i-th line gives the ranking order of the players for one of the three surfaces (in order from strongest to weakest). For each surface, the first number is the best player and the last number is the worst.

Then follow Q lines, each describing an operation. Each operation is in one of the following two forms:

  • Q X — a query asking whether player X can possibly become champion.
  • S s u v — an update operation where the positions of players u and v are swapped in the ranking for surface s (where s = 1 for clay, 2 for grass, and 3 for hard).

outputFormat

For each query operation, output a single line containing either YES if player X can be made the champion, or NO otherwise.

sample

3 3
1 2 3
2 1 3
3 2 1
Q 1
Q 2
Q 3
YES

YES YES

</p>