Codeforces Round 109 (Div. 1)
B
Colliders
Codeforces
1600
原题
← AC →
翻译中…

By 2312 there were $*n*$ Large Hadron Colliders in the inhabited part of the universe. Each of them corresponded to a single natural number from $1$ to $*n*$. However, scientists did not know what activating several colliders simultaneously could cause, so the colliders were deactivated.

翻译中…

In 2312 there was a startling discovery: a collider's activity is safe if and only if all numbers of activated colliders are pairwise relatively prime to each other (two numbers are relatively prime if their greatest common divisor equals $1$)! If two colliders with relatively nonprime numbers are activated, it will cause a global collapse.

翻译中…

Upon learning this, physicists rushed to turn the colliders on and off and carry out all sorts of experiments. To make sure than the scientists' quickness doesn't end with big trouble, the Large Hadron Colliders' Large Remote Control was created. You are commissioned to write the software for the remote (well, you do not expect anybody to operate it manually, do you?).

翻译中…

Initially, all colliders are deactivated. Your program receives multiple requests of the form "activate/deactivate the $*i*$-th collider". The program should handle requests in the order of receiving them. The program should print the processed results in the format described below.

翻译中…

To the request of "+ i" (that is, to activate the $*i*$-th collider), the program should print exactly one of the following responses:

翻译中…
  • "Success" if the activation was successful.
  • "Already on", if the $*i*$-th collider was already activated before the request.
  • "Conflict with j", if there is a conflict with the $*j*$-th collider (that is, the $*j*$-th collider is on, and numbers $*i*$ and $*j*$ are not relatively prime). In this case, the $*i*$-th collider shouldn't be activated. If a conflict occurs with several colliders simultaneously, you should print the number of any of them.
翻译中…

The request of "- i" (that is, to deactivate the $*i*$-th collider), should receive one of the following responses from the program:

翻译中…
  • "Success", if the deactivation was successful.
  • "Already off", if the $*i*$-th collider was already deactivated before the request.
翻译中…

You don't need to print quotes in the output of the responses to the requests.

翻译中…

Input

翻译中…

The first line contains two space-separated integers $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 10^{5}$) — the number of colliders and the number of requests, correspondingly.

翻译中…

Next $*m*$ lines contain numbers of requests, one per line, in the form of either "+ i" (without the quotes) — activate the $*i*$-th collider, or "- i" (without the quotes) — deactivate the $*i*$-th collider ($1 ≤ *i* ≤ *n*$).

翻译中…

Output

翻译中…

Print $*m*$ lines — the results of executing requests in the above given format. The requests should be processed in the order, in which they are given in the input. Don't forget that the responses to the requests should be printed without quotes.

翻译中…

Note

翻译中…

Note that in the sample the colliders don't turn on after the second and ninth requests. The ninth request could also receive response "Conflict with 3".

翻译中…

样例

Input #1
10 10
+ 6
+ 10
+ 5
- 10
- 5
- 6
+ 10
+ 3
+ 6
+ 3
Output #1
Success
Conflict with 6
Success
Already off
Success
Success
Success
Success
Conflict with 10
Already on
InputCopy OutputCopy
题目信息
题号
154B
时间限制
2 s
内存限制
256 MB
标签
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。