Note: this problem is different from "WTF Another GCD?". The difference is highlighted in bold.
In this task, you need to maintain a multiset $$$S$$$ that stores pairs of integers $$$(v,w)$$$.
Your multiset should support $$$n$$$ operations of the following types:
$$$$$$\max(\{w~|~(v,w) \in S \land \gcd(v,k) \ne 1 \})$$$$$$
where $$$\gcd(x,y)$$$ represents the largest integer that divides both $$$x$$$ and $$$y$$$.
If no such pair exists, output $$$0$$$.
The first line of each test contains an integer $$$n$$$ ($$$1 \le n \le 2 \cdot 10^5$$$) — the number of operations.
Each of the next $$$n$$$ lines describes an operation:
For each query, output one integer representing the maximum value of $$$w$$$ you found, or $$$0$$$ if no such $$$w$$$ exists.
8+ 4 5+ 3 4? 2? 3- 3 4? 4+ 114514 8? 3
5 4 5 0