Death-Moon loves telling stories.
Some days ago, he told us a funny story.
Long long ago, there is a hamster who is so naughty. Now, he comes to a place likes a N * N square. so, he is so excited to drill holes underground.
输入
Input until EOF. Fisrt input two integers N (3 <= N < 100) and M (0 < M <2000). N is the side of N * N ground, M is the number of operations.
Then follow M lines. Each line is a command:
Out x y : Hamster will get out at (x, y) from underground. So, place (x, y) will be a hole. P : Calculate out the number of the holes and output (Two holes are connected when they share an edge). If two holes are connected, it means it is one hole.
输出
For each 'P' command, output the number of the holes. Maybe hamster will get out at the same place more than once.