🏡 index : github.com/captn3m0/codechef.git

---
{"category_name":"medium","problem_code":"ICM2001","problem_name":"Yet Another Mod Mod Mod","problemComponents":{"constraints":"","constraintsState":false,"subtasks":"","subtasksState":false,"inputFormat":"","inputFormatState":false,"outputFormat":"","outputFormatState":false,"sampleTestCases":{}},"video_editorial_url":"","languages_supported":{"0":"CPP14","1":"C","2":"JAVA","3":"PYTH 3.6","4":"CPP17","5":"PYTH","6":"PYP3","7":"CS2","8":"ADA","9":"PYPY","10":"TEXT","11":"PAS fpc","12":"NODEJS","13":"RUBY","14":"PHP","15":"GO","16":"HASK","17":"TCL","18":"PERL","19":"SCALA","20":"LUA","21":"kotlin","22":"BASH","23":"JS","24":"LISP sbcl","25":"rust","26":"PAS gpc","27":"BF","28":"CLOJ","29":"R","30":"D","31":"CAML","32":"FORT","33":"ASM","34":"swift","35":"FS","36":"WSPC","37":"LISP clisp","38":"SQL","39":"SCM guile","40":"PERL6","41":"ERL","42":"CLPS","43":"ICK","44":"NICE","45":"PRLG","46":"ICON","47":"COB","48":"SCM chicken","49":"PIKE","50":"SCM qobi","51":"ST","52":"NEM"},"max_timelimit":2,"source_sizelimit":50000,"problem_author":"theanshul","problem_tester":null,"date_added":"9-02-2020","tags":{"0":"theanshul"},"problem_difficulty_level":"Medium","best_tag":"","editorial_url":"","time":{"view_start_date":1582014600,"submit_start_date":1582014600,"visible_start_date":1582014600,"end_date":1735669800},"is_direct_submittable":false,"problemDiscussURL":"https://discuss.codechef.com/search?q=ICM2001","is_proctored":false,"visitedContests":{},"layout":"problem"}
---
You are given $n$ numbers $a_1,a_2, ... a_n$ and another number $x$. Let $P= p_1,p_2,...p_n$ be any permutation of  $1,2,...n$. 

Your task is to find the number of distinct values of $((((x\%a_{p_1})\%a_{p_2})\%a_{p_3}...)\%a_{p_n}$ 

###Input:
- The first line contains $T$, the number of testcases.
- There are two lines in each testcase. The first line contains the numbers $n$ and $x$.
- The second line contains the $n$ numbers $a_1,a_2,...a_n$ separated by spaces. 

###Output:
Output in a single line the number of distinct values.
###Constraints 
- $1 \leq T \leq 10$
- $1 \leq n \leq 10^5$
- $1 \leq x \leq 10^9$
- $1 \leq a_i \leq 10^5$
- The sum of $n$ over all testcases doesn't exceed $10^5$.

###Sample Input:
    1
    2 5
    2 3

###Sample Output:
	2
	
###EXPLANATION:
$(5\%2)\%3 = 1$

$(5\%3)\%2 = 0$

Thus there are 2 distinct numbers.

<aside style='background: #f8f8f8;padding: 10px 15px;'><div>All submissions for this problem are available.</div></aside>