. Please answer Q queries. Each query consists of one integer v, asking the minimum index i such that. =v. If the sequence doesn't have any number with value v, you only need to output -1.The value of n may be as large as. Because n is so large. We will only give you four integers. ,a,b,p to generate the sequence. For all i>0, the sequence is generated as
There is a sequence of length n: x_0, x_1, x_2, ldots, x_{n-1} x ,x 1 ,x 2 ,…,x n−1 . Please answer Q queries. Each query consists of one integer v, asking the minimum index i such that x_i = v x i =v. If the sequence doesn't have any number with value v, you only need to output -1. Does the problem look simple? Surprise! The value of n may be as large as 10^{18} 10 18 ! Because n is so large. We will only give you four integers x_0, a, b, p x ,a,b,p to generate the sequence. For all i>0, the sequence is generated as x_i = (a cdot x_{i-1} + b) mod p x i =(a⋅x i−1 +b)modp.