Suppose you are given a multi-set.
Definition: Multiset is a set in which duplicate elements are allowed.
There are 3 types of Query.
1 x: add x into your multiset.
2 x: delete x from the multiset.
3 x: restore the multiset to a set which was after executing query x .
for each query, you need to answer the number of pairs in the multiset such that gcd of two elements is equal to 1e9+7.
It is guaranteed that if a query is like a "2 x", then x must be in your multiset and if a query is like a "3 x" then x is smaller than current query .
for first two type of query 1<=x<=10^14
for third query 0<=x < current query number where zero means empty set
1<= Number Of Queries <=200000
Setter: Utsav Patel