The enemy of my enemy is my friend!
Winnie-the-Pooh has joined a new social network called InTheForest. On this platform, each user has a list of friends and a list of enemies. Users can add anyone to their enemy list, but there are specific rules:
If user v lists user u as an enemy, it does not automatically mean that u considers v an enemy.
A user cannot list themselves as an enemy.
Winnie-the-Pooh is fascinated by this social network. He spends his time tracking who becomes whose enemy, eager to understand the dynamics in their forest. He believes that no one would visit their enemy, and in his view, the enemy of an enemy is a friend. Therefore, he thinks that everyone should visit their friends. Winnie-the-Pooh is curious to find out how many friends user v has. According to him, user u is considered a friend of user v if the following conditions are met:
u is an enemy of an enemy of v.
u is not an enemy of v.
Additionally, no user can be their own friend.
Input
The first line of the input contains two numbers, n and m (1 ≤ n, m ≤ 2000), representing the number of users on the social network and the number of queries, respectively.
The following m lines contain queries of two types:
+ v u - user v has started considering user u as an enemy.
? v - determine the number of friends user v has, according to Winnie-the-Pooh.
It is guaranteed that the input data is valid: a user will not consider themselves an enemy, and no user will be listed as an enemy more than once.
Output
For each ? v query, output a single integer on a separate line, representing the answer.