Jet Trains

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

The year is 3019. By now the humanity is living in cities floating in the atmosphere on air balloons and jet engines. There are nn cities on the planet connected by the jet trains network. If the cities aa and bb are connected by the train route, people can travel between them in any direction. The aa-th city can be reached from the bb-th city if and only if there is a path between aa and bb, where each edge of the path represent a train route.

People of 3019 love to be friends, and it happens so people from the same city have many friends in common. Let us say that the friendship connects not pairs of people, but pairs of cities. The friendship of two cities is mutual.

Sometimes people from a city may decide to organize a celebration and invite all the people from friendly cities. If the celebration is announced to be in city aa, all people from the friendly cities of aa try to get to aa using jet trains network. People from all friendly cities of aa that can reach the city aa join the celebration.

It has been decided to create a special system called "Celebration 3019" to evaluate the number of people on a certain celebration. There is information about cities which are friends, and the current state of the jet trains network. The system must handle the following requests: "If the celebration is announced in the city vv, people from how many cities will attend it?". Besides, there should be an option to add an information about new pair of friendly cities, and about new jet train route. Fortunately, the train routes never cancel and once friended, the cities remain friends forever.

Please help the mankind to develop such a system.

입력

The first line contains three integers nn, mm, kk --- number of cities, number of pairs of friendly cities and number of jet trains routes (1n1051 \le n \le 10^5, 0m,k1050 \le m, k \le 10^5). 

The following mm lines contain two integers aa and bb each (1a,bn1 \le a, b \le n, aba \neq b) --- pairs of friendly cities. It is guaranteed that each pair is listed at most once.

The following kk lines contain two integers aa, bb (1a,bn1 \le a, b \le n, aba \neq b) --- pairs of cities connected by the jet train routes. There is at most one route between each pair of cities.

The next line contains the integer qq (0q1050 \le q \le 10^5) --- the number of requests to handle, and the following qq lines represent requests.

  • Request "T aa bb" means that there is now a jet train route between aa and bb (1a,bn1 \le a, b \le n, aba \neq b). It is guaranteed that there was no direct route between aa and bb before the request.
  • Request "F aa bb" means that aa and bb are friends now (1a,bn1 \le a, b \le n, aba \neq b). It is guaranteed that aa and bb were not friends before the request.
  • Request "? vv" means that a request is made to the system: "If the celebraion is announced in the city vv, people from how many cities will attend it?" (1vn1 \le v \le n)

출력

For each request "? vv" print the answer to it on a new line.

힌트

The answer to the first request equals one, because only one of the cities 2,3{2, 3} has a train route to the city 11.

The answer to the second request equals two, because before the request cities 11 and 44 became friends, and they had a train route connecting them.

The answer to the third request equals three, because there is now possible to travel from the city 33 to the city 11 using trains network: first, people can travel to city 44, and then to city 11.