QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 128 MB مجموع النقاط: 100

#16299. Posting on Weibo

الإحصائيات

The newly launched SH Weibo has $n$ users (labeled $1 \dots n$). Within this short month, users have been active, with $m$ records in chronological order:

  • ! x indicates that user $x$ posted a Weibo message;
  • + x y indicates that user $x$ and user $y$ became friends;
  • - x y indicates that user $x$ and user $y$ ended their friendship.

When a user posts a Weibo message, all of their friends (direct relationship) will see their message.

Assume that initially, no one is friends with anyone else, and the records are all valid (i.e., when + x y occurs, $x$ and $y$ are definitely not friends, and when - x y occurs, $x$ and $y$ are definitely friends).

After these $m$ records have occurred, calculate how many messages each user has seen.

Input

The first line contains two integers $n$ and $m$.

The next $m$ lines contain the $m$ records in chronological order. Each record is formatted as described in the problem, with values separated by spaces.

Output

Output a single line containing $n$ space-separated integers (with no trailing space), where the $i$-th integer represents the number of messages user $i$ has seen.

Examples

Input 1

2 8
! 1
! 2
+ 1 2
! 1
! 2
- 1 2
! 1
! 2

Output 1

1 1

Note

Only the messages corresponding to the 4th and 5th records were seen. When the other messages were posted, 1 and 2 were not friends.

Constraints

1 2 3 4 5 6 7 8 9 10
$n=$ $2000$ $2000$ $2000$ $2000$ $2000$ $20000$ $200000$ $200000$ $200000$ $200000$
$m=$ $50000$ $50000$ $50000$ $50000$ $50000$ $50000$ $500000$ $500000$ $500000$ $500000$

Table 1. Constraints on n and m

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.