The chef is playing a game of long distance. Chef has a number K and he wants to find the longest distance between the index of the first and the last occurrence of K in a given array of N numbers.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Each test case contains two lines of input.
- Next line with Two integers in one line $K, N$.
- Next line with $N$ space-separated integers.

-----Output:-----
For each test case, output in a single line answer as the index of first and last occurrence of K in the given array.
Note: Here Indexing is from 1 not  0 based.

-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq k \leq 10^5$
- $1 \leq N \leq 10^5$

-----Sample Input:-----
2
2 6
2 3 4 2 1 6
4 6
2 3 4 2 1 6

-----Sample Output:-----
3
0

-----EXPLANATION:-----
For 1) Index of First and last occurrence of 2 in the given array is at 1 and 4, i.e. distance is 3. 
For 2) 4 occurs only once in the given array hence print 0.

Starter code:

Solutions:
# cook your dish here
for _ in range(int(input())):
    m,n=list(map(int,input().split()))
    a=[int(i) for i in input().split()]
    l=-1
    for i in range(n-1,-1,-1):
        if a[i]==m:
            l=i
            break
    f=-1
    for i in range(0,n):
        if a[i]==m:
            f=i
            break
    print(l-f)
            
        


# cook your dish here
t=int(input())
for _ in range(t):
    k,n=map(int,input().split())
    l=list(map(int,input().split())) 
    f=-1
    s=-1
    for i in range(n):
        if l[i]==k:
            f=i 
            break 
    for  i in range(n-1,-1,-1):
        if l[i]==k:
            s=i
            break 
    if f==-1 or s==-1:
        print(0) 
    else:
        s+=1 
        f+=1
        print(s-f)

# cook your dish here
for t in range(int(input())):
    k,n=map(int, input().split())
    a=list(map(int, input().split()))[:n]
    lst=[]
    for i in range(n):
        if a[i]==k:
            lst.append(i)
    if len(lst)>0:
        print(max(lst)-min(lst))
    else:
        print(0)

# cook your dish here
T = int(input())

for t in range(T):
    K,N = map(int,input().split())
    data = list(map(int,input().split()))
    
    first = -1
    
    for i in range(len(data)):
        if(data[i]==K):
            first = i
            break
            
    second = -1
    
    for i in range(len(data)-1,first,-1):
        if(data[i]==K):
            second = i
            break
            
    if(first == -1 or second == -1):
        print(0)
    else:
        print(second-first)

# cook your dish here
T = int(input())

for t in range(T):
    K,N = map(int,input().split())
    data = list(map(int,input().split()))
    
    first = -1
    
    for i in range(len(data)):
        if(data[i]==K):
            first = i
            break
            
    second = -1
    
    for i in range(len(data)-1,first,-1):
        if(data[i]==K):
            second = i
            break
            
    if(first == -1 or second == -1):
        print(0)
    else:
        print(second-first)

from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict as dd
import math
def geti(): return list(map(int, input().strip().split()))
def getl(): return list(map(int, input().strip().split()))
def gets(): return input()
def geta(): return int(input())
def print_s(s): stdout.write(s+'\n')

def solve():
    for _ in range(geta()):
        m,n=geti()
        a=getl()
        l=s=0
        for i in range(n):
            if a[i]==m:
                s=i
                break
        for i in range(n-1,-1,-1):
            if a[i]==m:
                l=i
                break
        print(l-s)

def __starting_point():
    solve()

__starting_point()

T = int(input())

for t in range(T):
    K,N = map(int,input().split())
    data = list(map(int,input().split()))
    
    first = -1
    
    for i in range(len(data)):
        if(data[i]==K):
            first = i
            break
            
    second = -1
    
    for i in range(len(data)-1,first,-1):
        if(data[i]==K):
            second = i
            break
            
    if(first == -1 or second == -1):
        print(0)
    else:
        print(second-first)