Chef has $N$ small boxes arranged on a line from $1$ to $N$. For each valid $i$, the weight of the $i$-th box is $W_i$. Chef wants to bring them to his home, which is at the position $0$. He can hold any number of boxes at the same time; however, the total weight of the boxes he's holding must not exceed K at any time, and he can only pick the ith box if all the boxes between Chef's home and the ith box have been either moved or picked up in this trip.
Therefore, Chef will pick up boxes and carry them home in one or more round trips. Find the smallest number of round trips he needs or determine that he cannot bring all boxes home.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains two space-separated integers $N$ and $K$.
- The second line contains $N$ space-separated integers $W_1, W_2, \ldots, W_N$.

-----Output-----
For each test case, print a single line containing one integer ― the smallest number of round trips or $-1$ if it is impossible for Chef to bring all boxes home.

-----Constraints-----
- $1 \le T \le 100$
- $1 \le N, K \le 10^3$
- $1 \le W_i \le 10^3$ for each valid $i$

-----Example Input-----
4
1 1 
2
2 4
1 1
3 6
3 4 2
3 6
3 4 3

-----Example Output-----
-1
1
2
3

-----Explanation-----
Example case 1: Since the weight of the box higher than $K$, Chef can not carry that box home in any number of the round trip.
Example case 2: Since the sum of weights of both boxes is less than $K$, Chef can carry them home in one round trip.
Example case 3: In the first round trip, Chef can only pick up the box at position $1$. In the second round trip, he can pick up both remaining boxes at positions $2$ and $3$.
Example case 4: Chef can only carry one box at a time, so three round trips are required.

Difficulty: interview

Starter code:

Solutions:
t=int(input())
for i in range(t):
 x,y=0,0
 n,m=list(map(int,input().split()))
 l=list(map(int,input().split()))
 if(max(l)>m):
  print(-1)
 else:
  for i in range(len(l)):
   y+=l[i]
   if(y>m):
    y=l[i]
    x+=1
  if(y>0):
   x+=1
  print(x)


# cook your dish here
for __ in range(int(input())):
 n,k=list(map(int,input().split()))
 arr=list(map(int,input().split()))
 i=0
 c=0
 while(True):
  if arr[i]>k:
   ans=-1
   break
  else:
   w=0
   flag=0
   for j in range(i,n):
    if(w+arr[j]<=k):
     w+=arr[j]
     flag=1
     i=j+1
    else:
     i=j
     break
   if(flag==1):
    c+=1
    ans=c
   if(i>=n):
    break
   
 print(ans)
   
   
   
  
 


def fun(lst, k):
 
 weight = 0
 ans = 1
 
 for el in lst:
  
  if el > k:
   return -1
  
  elif weight + el <= k:
   weight += el
   
  else:
   ans += 1
   weight = el
 return ans


for _ in range(int(input())):
 
 n, k = list(map(int, input().split()))
 lst = [int(i) for i in input().split()]
 
 print(fun(lst, k))


for _ in range(int(input())):
 n,k = list(map(int,input().split()))
 arr = list(map(int,input().split()))

 count = 0

 flag = True
 curr_sum = 0
 for i in arr:
  if i>k:
   flag = False
  else:
   curr_sum+=i

   if curr_sum>k:
    curr_sum = i
    count+=1
 

 if curr_sum<=k:
  count+=1
 if flag==False:
  print(-1)
 else:
  print(count)

 
 


for _ in range(int(input())):
 n,k = list(map(int,input().split()))
 arr = list(map(int,input().split()))

 count = 0

 flag = True
 curr_sum = 0
 for i in arr:
  if i>k:
   flag = False
  else:
   curr_sum+=i

   if curr_sum>k:
    curr_sum = i
    count+=1
 

 if curr_sum<=k:
  count+=1
 if flag==False:
  print(-1)
 else:
  print(count)

 


t = int(input())

for _ in range(t):
 n, k = list(map(int, input().split()))
 w = list(map(int, input().split()))
 
 p = 0; ans = 0
 flag = False
 while p<n:
  pick = 0
  if w[p]>k:
   flag = True; break
  else:
   while p<n:
    if pick+w[p]<=k:
     pick += w[p]
     p += 1
    else:
     break
   ans += 1
   pick = 0

 if flag:
  print(-1)
 else:
  print(ans)
   
   
  


T=int(input())
for i in range(T):
 N,K=map(int,input().split())
 w=list(map(int,input().split()))
 if max(w)<=K:
  x=y=0
  for i in range(len(w)):
   x+=w[i]
   if x>K:
    y+=1
    x=w[i]
  if x>0:
   y+=1
  print(y)
 else:
  print("-1")

for _ in range(int(input())):
 n,k = list(map(int,input().split()))
 s = 0
 res = 0
 for i in map(int,input().split()):
  if i>k:
   res=-1
   s=0
   break
  if s+i<=k:
   s+=i
  else:
   s=i
   res+=1
 if s>0: res+=1
 print(res)


t=int(input())
for _ in range(t):
 n,k=map(int,input().split())
 w=list(map(int,input().split()))
 count=0
 while w!=[]:
  w1=[]
  for i in range(n):
   if sum(w1)+w[i]<=k:
    w1.append(w[i])
   else:
    break
  if w1==[]:
   count=-1
   break
  else:
   w[:len(w1)]=[]
   n-=len(w1)
   count+=1
 print(count)

t=int(input())
for i in range(t):
 s,c=0,0
 n,k=list(map(int,input().split()))
 l=list(map(int,input().split()))
 if max(l)>k:
  print("-1")
 else:
  for i in range(len(l)):
   s+=l[i]
   if s>k:
    c+=1
    s=l[i]
  if s>0:
   c+=1
    
  print(c)


for i in range(int(input())):
 n,k=list(map(int,input().split()))
 l=list(map(int,input().split()))
 ro=0
 s=0
 f=1
 for i in range(n):
  if l[i]>k:
   print(-1)
   f=0
   break
  s+=l[i]
  if s>k:
   s=l[i]
   ro+=1
 if s and f:
  print(ro+1)
 elif f:
  print(ro)

# cook your dish here
t=int(input())
for i in range(t):
 n,k=map(int,input().split())
 w=list(map(int,input().split()))
 c=1
 d=0
 for i in w:
  if i>k:
   c=-1
   break
  d+=i
  if d>k:
   d=i
   c+=1
 print(c)

l=int(input())

for i in range(l):
 n=input().split()
 k=int(n[1])
 ws = list(map(int, input().split(" ")))
 
 flag=False
 for w in ws:
  if w>k:
   flag=True
   print(-1)
   break
 if flag:
  continue 
 p=0
 r=0
 while p<len(ws):
  r=r+1
  c=0
  t=len(ws);
  while(p<t and c+ws[p]<=k):
   c=c+ws[p]
   p=p+1
    
 print(r)

MOD = 1000000007
for _ in range(int(input())):
 n,k = list(map(int,input().split()))
 # n = int(input())
 weights = list(map(int,input().split()))
 if max(weights)>k :
  print(-1)
 else :
  carry = 0
  rounds = 0
  for w in weights :
   if carry+w <= k :
    carry += w
   else :
    rounds += 1
    carry = w
  if carry > 0 :
   rounds += 1
  print(rounds)


for _ in range(int(input())):
 n, k = list(map(int, input().split()))
 W = list(map(int, input().split()))
 W_cp = W.copy()
 
 count = 1
 curr = 0
 for i, w in enumerate(W):
  if w > k:
   count = -1
   break
  
  curr += w
  
  if curr > k:
   curr = w
   count += 1
   
 print(count)

t = int(input())

for _ in range(t):
 n, k = [int(x) for x in input().split()]
 w = [int(x) for x in input().split()]
 
 i=0
 total = 0
 c = 0
 flag = 0
 
 while(i<n):
  if(w[i] > k):
   flag = 1
   break
  total += w[i]
  if(total > k):
   total = 0
   c += 1
  else:
   i += 1
 
 if(flag == 1):
  print(-1)
 else:
  print(c+1)

a=int(input())
for i in range(a):
 m,o=input().split()
 n,k=[int(m),int(o)]
 b=list(map(int,input().split()))
 c=max(b)
 u=0
 z=1
 if k<c:
  print("-1")
 else:
  for j in b:
   if u+j <=k:
    u=u+j
   else:
    u=j
    z=z+1
  print(z)

a=int(input())
for i in range(a):
 m,o=input().split()
 n,k=[int(m),int(o)]
 b=list(map(int,input().split()))
 u=0
 z=1
 for j in b:
  if j>k:
   z=0
   break
  elif u+j <=k:
   u=u+j
  else:
   u=j
   z=z+1

 if z==0:
  print(-1)
 else:
  print(z)

for t in range(int(input())):
 n, k = map(int, input().split())
 B = list(map(int, input().split()))
 flag = 1
 w = 0
 for i in range(n):
  if B[i] > k:
   flag = 0
   break
  elif w + B[i] <= k:
   w += B[i]
  else:
   w = B[i]
   flag += 1
 if flag == 0:
  print("-1")
 else:
  print(flag)

# cook your dish here
import sys

def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
for t in range(int(input())):
 N, K = get_ints()
 B = get_array()
 flag = 1
 w = 0
 for i in range(N):
  if B[i] > K:
   flag = 0
   break
  elif w + B[i] <= K:
   w += B[i]
  else:
   w = B[i]
   flag += 1
 if flag == 0:
  print("-1")
 else:
  print(flag)

# cook your dish here
for _ in range(int(input())):
 w,k=list(map(int,input().split()))
 l=list(map(int,input().split()))
 if(max(l)<=k):
  i=0
  r=0
  while i<w:
   a=0
   #print("hii")
   for j in range(w-i):
    a+=l[i+j]
    if a>k:
     j-=1 
     break
   r+=1
   i+=(j+1)
   
   
   
  print(r) 
 else:
  print(-1)


try:
 for t in range(int(input())):
  n,k = list(map(int,input().split()))
  l = list(map(int,input().split()))
  c = 0
  z = k 
  for j in range(0,n):
   if(l[j]<=z):
    z = z-l[j]
    if(j+1<n and l[j+1]>z):
     z = k 
     c= c+1 
   else:
    c = -2
    break
  if(c==-2):
   print(-1)
  else:
   print(c+1)
except EOFError as e:
 pass
  # TODO: write code...