The only difference between easy and hard versions is on constraints. In this version constraints are lower. You can make hacks only if all versions of the problem are solved.

Koa the Koala is at the beach!

The beach consists (from left to right) of a shore, $n+1$ meters of sea and an island at $n+1$ meters from the shore.

She measured the depth of the sea at $1, 2, \dots, n$ meters from the shore and saved them in array $d$. $d_i$ denotes the depth of the sea at $i$ meters from the shore for $1 \le i \le n$.

Like any beach this one has tide, the intensity of the tide is measured by parameter $k$ and affects all depths from the beginning at time $t=0$ in the following way:

  For a total of $k$ seconds, each second, tide increases all depths by $1$.

  Then, for a total of $k$ seconds, each second, tide decreases all depths by $1$.

  This process repeats again and again (ie. depths increase for $k$ seconds then decrease for $k$ seconds and so on ...).

Formally, let's define $0$-indexed array $p = [0, 1, 2, \ldots, k - 2, k - 1, k, k - 1, k - 2, \ldots, 2, 1]$ of length $2k$. At time $t$ ($0 \le t$) depth at $i$ meters from the shore equals $d_i + p[t \bmod 2k]$ ($t \bmod 2k$ denotes the remainder of the division of $t$ by $2k$). Note that the changes occur instantaneously after each second, see the notes for better understanding. 

At time $t=0$ Koa is standing at the shore and wants to get to the island. Suppose that at some time $t$ ($0 \le t$) she is at $x$ ($0 \le x \le n$) meters from the shore:

  In one second Koa can swim $1$ meter further from the shore ($x$ changes to $x+1$) or not swim at all ($x$ stays the same), in both cases $t$ changes to $t+1$.

  As Koa is a bad swimmer, the depth of the sea at the point where she is can't exceed $l$ at integer points of time (or she will drown). More formally, if Koa is at $x$ ($1 \le x \le n$) meters from the shore at the moment $t$ (for some integer $t\ge 0$), the depth of the sea at this point  — $d_x + p[t \bmod 2k]$  — can't exceed $l$. In other words, $d_x + p[t \bmod 2k] \le l$ must hold always.

  Once Koa reaches the island at $n+1$ meters from the shore, she stops and can rest.

Note that while Koa swims tide doesn't have effect on her (ie. she can't drown while swimming). Note that Koa can choose to stay on the shore for as long as she needs and neither the shore or the island are affected by the tide (they are solid ground and she won't drown there). 

Koa wants to know whether she can go from the shore to the island. Help her!


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 100$)  — the number of test cases. Description of the test cases follows.

The first line of each test case contains three integers $n$, $k$ and $l$ ($1 \le n \le 100; 1 \le k \le 100; 1 \le l \le 100$) — the number of meters of sea Koa measured and parameters $k$ and $l$.

The second line of each test case contains $n$ integers $d_1, d_2, \ldots, d_n$ ($0 \le d_i \le 100$)  — the depths of each meter of sea Koa measured.

It is guaranteed that the sum of $n$ over all test cases does not exceed $100$.


-----Output-----

For each test case:

Print Yes if Koa can get from the shore to the island, and No otherwise.

You may print each letter in any case (upper or lower).


-----Example-----
Input
7
2 1 1
1 0
5 2 3
1 2 3 2 2
4 3 4
0 2 4 3
2 3 5
3 0
7 2 3
3 0 2 1 3 0 1
7 1 4
4 4 3 0 2 4 2
5 2 3
1 2 3 2 2

Output
Yes
No
Yes
Yes
Yes
No
No



-----Note-----

In the following $s$ denotes the shore, $i$ denotes the island, $x$ denotes distance from Koa to the shore, the underline denotes the position of Koa, and values in the array below denote current depths, affected by tide, at $1, 2, \dots, n$ meters from the shore.

In test case $1$ we have $n = 2, k = 1, l = 1, p = [ 0, 1 ]$.

Koa wants to go from shore (at $x = 0$) to the island (at $x = 3$). Let's describe a possible solution:

  Initially at $t = 0$ the beach looks like this: $[\underline{s}, 1, 0, i]$.  At $t = 0$ if Koa would decide to swim to $x = 1$, beach would look like: $[s, \underline{2}, 1, i]$ at $t = 1$, since $2 > 1$ she would drown. So Koa waits $1$ second instead and beach looks like $[\underline{s}, 2, 1, i]$ at $t = 1$.  At $t = 1$ Koa swims to $x = 1$, beach looks like $[s, \underline{1}, 0, i]$ at $t = 2$. Koa doesn't drown because $1 \le 1$.  At $t = 2$ Koa swims to $x = 2$, beach looks like $[s, 2, \underline{1}, i]$ at $t = 3$. Koa doesn't drown because $1 \le 1$.  At $t = 3$ Koa swims to $x = 3$, beach looks like $[s, 1, 0, \underline{i}]$ at $t = 4$.  At $t = 4$ Koa is at $x = 3$ and she made it! 

We can show that in test case $2$ Koa can't get to the island.

Difficulty: interview

Starter code:

Solutions:
for q in range(int(input())):
    n, k, l = map(int, input().split())
    line = list(map(int, input().split()))
    line.append(-1000)
    dp = [[False] * (2 * k) for i in range(n + 2)]
    for i in range(2 * k):
        dp[0][i] = True
    for i in range(1, n + 2):
        for j in range(2 * k):
            if j < k and line[i - 1] + j <= l:
                if dp[i - 1][(j - 1) % (2 * k)]:
                    dp[i][j] = True
                elif dp[i][(j - 1) % (2 * k)]:
                    dp[i][j] = True
            if j >= k and line[i - 1] + 2 * k - j <= l:
                if dp[i - 1][j - 1]:
                    dp[i][j] = True
                elif dp[i][j - 1]:
                    dp[i][j] = True
    if max(dp[n + 1]) == True:
        print("Yes")
    else:
        print("No")

#
#    ------------------------------------------------
#           ____          _     Generatered using
#          / ___|        | |
#         | |    __ _  __| | ___ _ __  ______ _
#         | |   / _` |/ _` |/ _ \ '_ \|_  / _` |
#         | |__| (_| | (_| |  __/ | | |/ / (_| |
#          \____\____|\____|\___|_| |_/___\____|
#
#      GNU Affero General Public License v3.0
#    ------------------------------------------------
#    Author   : prophet
#    Created  : 2020-07-24 11:18:32.110309
#    UUID     : dhIFbAnMq2yrA0IR
#    ------------------------------------------------
#
production = True

import sys, math, collections

def input(input_format = 0, multi = 0):

    if multi > 0: return [input(input_format) for i in range(multi)]
    else:
        next_line = sys.stdin.readline()[:-1]

        if input_format >= 10:
            use_list = False
            input_format = int(str(input_format)[-1])
        else: use_list = True

        if input_format == 0: formatted_input = [next_line]
        elif input_format == 1: formatted_input = list(map(int, next_line.split()))
        elif input_format == 2: formatted_input = list(map(float, next_line.split()))
        elif input_format == 3: formatted_input = list(next_line)
        elif input_format == 4: formatted_input = list(map(int, list(next_line)))
        elif input_format == 5: formatted_input = next_line.split()
        else: formatted_input = [next_line]

        return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format = 0, newline = True):

    formatted_output = ""

    if output_format == 0: formatted_output = str(output_line)
    elif output_format == 1: formatted_output = " ".join(map(str, output_line))
    elif output_format == 2: formatted_output = "\n".join(map(str, output_line))
    elif output_format == 3: formatted_output = "".join(map(str, output_line))

    print(formatted_output, end = "\n" if newline else "")

def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)
flip = lambda a: (a + 1) & 1

def mapl(iterable, format = 0):
    
    if format == 0: return list(map(int, iterable))
    elif format == 1: return list(map(str, iterable))
    elif format == 2: return list(map(list, iterable))
#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#


def solve():

    n, k, l = input(1)
    d = input(1)

    log(k, l)
    log(d)

    f = [l - i for i in d]

    log(f)

    t =  list(range(k, -1, -1)) + list(range(1, k))
    log("t", t)
    p = [(0, 2 * k - 1)]

    for i in f:
        a, b = p[-1]
        if i >= k:
            p.append((0, 2 * k - 1))
        else:
            fb = k + i
            fa = max(a + 1, k - i)
            log(i, fb, fa)
            if fb < fa:
                out("No")
                return

            p.append((fa, fb))
        log(p)
    else:
        out("Yes")

    log("")
    return


for i in range(input(11)): solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#


t = int(input())
for _ in range(t):
    n, k, l = list(map(int, input().split()))
    d = list(map(int, input().split()))
    p = list(range(k)) + list(range(k, 0, -1))

    pos = list(range(2*k))
    ans = 'Yes'
    for i in range(n):
        new_pos = []
        for t in pos:
            j = 1
            for j in range(1, 2*k + 1):
                if d[i] + p[(t+j) % (2*k)] > l:
                    break
                new_pos.append((t+j) % (2*k))
        pos = list(set(new_pos))
        if len(pos) == 0:
            ans = 'No'
    print(ans)


for _ in range(int(input())):
    n, k, l = list(map(int, input().split()))
    dd = list(map(int, input().split()))
    t = 0
    curld = 0
    di = False
    for d in [-(2**30), *dd]:
        if d > l:
            break
        ld = l - d
        if d + k <= l:
            curld = ld
            di = False
            continue
        if di:
            if ld >= curld + 1:
                curld += 1
            else:
                break
        else:
            curld = min(curld - 1, ld)
            if curld == 0:
                di = True
    else:
        print('Yes')
        continue
    print('No')


import sys
input = sys.stdin.readline
 
t = int(input())
letters = 'abcdefghijklmnopqrst'
 
for _ in range(t):

    n,k,l = list(map(int,input().split()))
    d = list(map(int,input().split()))
    
    ll = []
    
    tot = len(d)
    
    while len(d) > 0:
        ddd = []
        c= 0 
        for el in d:
            ddd.append(el)
            c += 1
            if el + k <= l:
                d = d[c:]
                break
        
        for j in range(2*k):
            ok = 1
            for s in range(len(ddd)):
                modif = (j + s + 1) % (2*k)
                modif = min(modif, 2*k - modif)
                
                depth = ddd[s] + modif
                #if j==3:
                #    print(depth, j)
                if depth > l:
                    ok = 0
                    
            if ok==1:
                break
            
        ll.append(ok)
        
        if len(d)==tot:
            break
        
        tot = len(d)
    
    if min(ll) == 1:
        print('Yes')
    else:
        print('No')
    


inp = lambda : map(int, input().split())
t = int(input())
for _ in range(t):
    n, k, l = inp()
    d = list(inp())
    remain = [i for i in range((-1) * (k - 1), 0)] + [i for i in range(k + 1)]
    f = True
    for i in range(n):
        #print(remain)
        f = False
        new_remain = []
        for j in range(len(remain)):
            temp = (remain[j] + 1)
            if temp > k:
                temp = - k + 1
            if abs(temp) + d[i] <= l:
                f = True
                new_remain.append(temp)
        if not f:
            print("No")
            break
        remain = []
        flag = False if k + d[i] > l else True
        for j in range(1 - k, k + 1):
            if j in new_remain:
                flag = True
            if abs(j) + d[i] <= l and flag:
                remain.append(j)
            if abs(j) + d[i] > l:
                flag = False
        
    if f:
        print("Yes")

T = int(input())
for _ in range(T):
    N,K,L = list(map(int,input().split()))
    D = list(map(int,input().split()))
    P = list(range(K)) + list(range(K,0,-1))
    dp = [[0]*(len(P)) for _ in range(N+1)]
    for i in range(len(P)):
        dp[0][i] = 1
    for i in range(N):
        for _ in range(2):
            for j in range(len(P)):
                if dp[i][j]==0: continue
                if i and dp[i][(j+1)%len(P)]==0 and D[i-1] + P[(j+1)%len(P)] <= L:
                    dp[i][(j+1)%len(P)] = 1
                if D[i] + P[(j+1)%len(P)] <= L:
                    dp[i+1][(j+1)%len(P)] = 1
    print('No' if all(a==0 for a in dp[-1]) else 'Yes')


def go(n, k, l, d):
    p = [0] * (2 * k)
    for t in range(0, 2 * k):
        if t <= k:
            p[t] = t
        else:
            p[t] = 2 * k - t

    h = []
    for x in range(n):
        h_x = [0] * (2 * k)
        for t in range(0, 2 * k):
            h_x[t] = d[x] + p[t]
        h.append(h_x)

    dp = []
    for x in range(n):
        dp.append([False] * (2 * k))
    for t in range(0, 2 * k):
        if h[0][t] <= l:
            dp[0][t] = True
        else:
            dp[0][t] = False
    #print(dp)
    for x in range(1, n):
        for t in range(0, 2 * k):
            if dp[x-1][(t-1)%(2*k)] and h[x-1][(t-1)%(2*k)] <= l and h[x][t] <= l:
                dp[x][t] = True
        for t in range(0, 2 * k):
            if dp[x][(t-1)%(2*k)] and h[x][(t-1)%(2*k)] <= l and h[x][t] <= l:
                dp[x][t] = True

    #print(dp)
    for t in range(0, 2 * k):
        if dp[n-1][t]:
            return True
    return False

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

    if go(n, k, l, d):
        print("Yes")
    else:
        print("No")

import sys
import math 
from decimal import *
def I(): return int(sys.stdin.readline())
def IL(): return list(map(int,sys.stdin.readline().strip().split()))
def ILS(): return list(map(str,sys.stdin.readline().strip().split()))






def solve():
	tt = I()
	for ii in range(tt):
		n,k,l = IL()
		d = IL()
		tmp = []
		kl = []
		for i in range(k+1):
			tmp.append(0);
		for i in range(k-1,0,-1):
			tmp.append(0)
		dp = [tmp.copy() for dd in d]
		# print(dp)
		for i in range(k+1):
			kl.append(i);
		for i in range(k-1,0,-1):
			kl.append(i)

		for i in range(len(tmp)):
			if d[0] + kl[i] <= l : dp[0][i] = 1
			else : dp[0][i] = 0
		for i in range(1,len(d)):
			for j in range(len(dp[i])):
				k = j-1
				if k <0 : k = len(dp[i])-1
				if d[i]+kl[j] <= l : 
					dp[i][j] = 1 if dp[i-1][k]+dp[i][k] > 0 else 0
				else : dp[i][j] = 0
				
		# print(dp)
		# for pp in dp :
		# 	print(pp)
		flag = 0
		for i in range(len(dp[-1])):
			if dp[-1][i] == 1 : flag = 1; break;
		if flag == 1 : print("Yes")
		else : print("No")
		# cal(d,-1)
		pass

solve()

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7

def bfs(grid, src):
    from collections import deque

    H, W = len(grid), len(grid[0])
    visited = list3d(2, H, W, 0)
    que = deque()
    for h, w in src:
        que.append((0, h, w))
        que.append((1, h, w))
        visited[0][h][w] = 1
        visited[1][h][w] = 1
    while que:
        up, h, w = que.popleft()
        if w == N-1:
            return True
        if h == 0:
            up = 1
        if h == K:
            up = 0
        if up:
            if not visited[up][h+1][w] and grid[h+1][w] <= L:
                visited[up][h+1][w] = 1
                que.append((up, h+1, w)) 
            if not visited[up][h+1][w+1] and grid[h+1][w+1] <= L:
                visited[up][h+1][w+1] = 1
                que.append((up, h+1, w+1))
        else:
            if not visited[up][h-1][w]:
                visited[up][h-1][w] = 1
                que.append((up, h-1, w))
            if not visited[up][h-1][w+1] and grid[h-1][w+1] <= L:
                visited[up][h-1][w+1] = 1
                que.append((up, h-1, w+1))
    return False

for _ in range(INT()):
    N, K, L = MAP()
    A = LIST()

    grid = list2d(K+1, N, 0)
    for i in range(K+1):
        for j in range(N):
            grid[i][j] = A[j] + i

    src = []
    for i in range(K+1):
        if grid[i][0] <= L:
            src.append((i, 0))
    ok = False
    for x in range(K+1):
        if bfs(grid, src):
            Yes()
            break
    else:
        No()