There are n piles of pebbles on the table, the i-th pile contains a_{i} pebbles. Your task is to paint each pebble using one of the k given colors so that for each color c and any two piles i and j the difference between the number of pebbles of color c in pile i and number of pebbles of color c in pile j is at most one.

In other words, let's say that b_{i}, c is the number of pebbles of color c in the i-th pile. Then for any 1 ≤ c ≤ k, 1 ≤ i, j ≤ n the following condition must be satisfied |b_{i}, c - b_{j}, c| ≤ 1. It isn't necessary to use all k colors: if color c hasn't been used in pile i, then b_{i}, c is considered to be zero.


-----Input-----

The first line of the input contains positive integers n and k (1 ≤ n, k ≤ 100), separated by a space — the number of piles and the number of colors respectively.

The second line contains n positive integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100) denoting number of pebbles in each of the piles.


-----Output-----

If there is no way to paint the pebbles satisfying the given condition, output "NO" (without quotes) .

Otherwise in the first line output "YES" (without quotes). Then n lines should follow, the i-th of them should contain a_{i} space-separated integers. j-th (1 ≤ j ≤ a_{i}) of these integers should be equal to the color of the j-th pebble in the i-th pile. If there are several possible answers, you may output any of them.


-----Examples-----
Input
4 4
1 2 3 4

Output
YES
1
1 4
1 2 4
1 2 3 4

Input
5 2
3 2 4 1 3

Output
NO

Input
5 4
3 2 4 3 5

Output
YES
1 2 3
1 3
1 2 3 4
1 3 4
1 1 2 3 4

Difficulty: interview

Starter code:

Solutions:
n, k = map(int, input().split())
arr = [int(i) for i in input().split()]
res = [[] for i in range(n)]
c = 0
while True:
    z = 0
    for i in arr:
        if i > 0:
            z += 1
    if z == 0:
        break
    if z == n:
        for i in range(n):
            arr[i] -= 1
            res[i].append(1)
    else:
        c += 1
        if c > k:
            break
        for i, j in enumerate(arr):
            if j > 0:
                arr[i] -= 1
                res[i].append(c)
if c > k:
    print('NO')
else:
    print('YES')
    for i in res:
        for j in i:
            print(j, end = ' ')
        print()

n, k = map(int, input().split())
a = list(map(int, input().split()))
mn = min(a)
if (max(a) - mn > k):
	print('NO')
else:
	print('YES')
	for i in range(n):
		arr = [1]*mn
		arr += [1+i for i in range(a[i]-mn)]
		print(' '.join(map(str, arr)))

n, k = [int(x) for x in input().split()]

a = [int(x) for x in input().split()]

mn = min(a)
mx = max(a)

if mx - mn > k:
    print("NO")
else:
    print("YES")
    for i in range(n):
        for j in range(a[i]):
            l = [1] * a[i]
            for p in range(mn + 1, a[i]):
                l[p] += l[p-1]
        print(" ".join(str(x) for x in l))


import sys

n, k = list(map(int, input().split()))
keeps = list(map(int, input().split()))
min_k = min(keeps)
ans = [0] * n
for i in range(n):

    ans[i] = (['1'] * (min(min_k + 1, keeps[i])))
    j = 2
    while j <= k and len(ans[i]) < keeps[i]:
        ans[i].append(str(j))
        j += 1
    if len(ans[i]) < keeps[i]:
        print('NO')
        return
print('YES')
for i in range(n):
    print(' '.join(ans[i]))



"""
Codeforces Contest 289 Div 2 Problem B

Author  : chaotic_iak
Language: Python 3.4.2
"""

################################################### SOLUTION

def main():
    n,k = read()
    a = read()
    if max(a) - min(a) > k: return "NO"
    print("YES")
    for i in a:
        print("1 " * min(a) + " ".join(map(str, range(1, i-min(a)+1))))



#################################################### HELPERS



def read(mode=2):
    # 0: String
    # 1: List of strings
    # 2: List of integers
    inputs = input().strip()
    if mode == 0: return inputs
    if mode == 1: return inputs.split()
    if mode == 2: return list(map(int, inputs.split()))

def write(s="\n"):
    if s is None: s = ""
    if isinstance(s, list): s = " ".join(map(str, s))
    s = str(s)
    print(s, end="")

write(main())

def main():
    n, k = list(map(int, input().split()))
    l = list(map(int, input().split()))
    mi, ma = min(l), max(l)
    if ma - mi > k:
        print('NO')
        return
    print('YES')
    res = ['1'] * (mi + 1)
    for i in range(2, k + 1):
        res.append(str(i))
    for a in l:
        print(' '.join(res[:a]))


def __starting_point():
    main()

__starting_point()

n, colors = map(int, input().split())
lens = list(map(int, input().split()))
q = [[] for i in range(n)]

def end():
    for i in range(n):
        if lens[i] != len(q[i]):
            return False
    return True

mi = min(lens)
for i in range(n):
    while len(q[i]) < min(lens[i], 1 + mi):
        q[i].append(1)

k = 1
while not end():
    k += 1
    for i in range(n):
        if len(q[i]) < lens[i]:
            q[i].append(k)

ma = max(map(max, q))
if ma <= colors:
    print('YES')
    for w in q:
        for i in w:
            print(i, end=' ')
        print()
else:
    print('NO')

import sys
f = sys.stdin
#f = open('H:\\Portable Python 3.2.5.1\\test_248B1.txt') 

n, k = list(map(int, f.readline().strip().split()))
a = [int(u) for u in f.readline().strip().split()]

min_a = min(a)
max_a = max(a)

if max_a>min_a+k:
    print('NO')
else:
    print('YES')
 
    for i in range(n):
        d = ['']*a[i]
        for j in range(a[i]):
            if j<=min_a:
                d[j] = '1'
            else:
                d[j] = str(1 + j - min_a)
        print(' '.join(d))


#!/usr/bin/env python

n, k = list(map(int, input().split(' ')))

nums = list(map(int, input().split(' ')))
pebbles = [[] for i in range(len(nums))]

smallest = min(nums)
prefix = smallest * [1]
nums = list([x - smallest for x in nums])

for c in range(1, k+1):
    for i, e in enumerate(nums):
        if e != 0:
            pebbles[i].append(c)
            nums[i] -= 1
    
if any([x > 0 for x in nums]):
    print("NO")
else:
    print("YES")
    prefix = ' '.join(map(str, prefix))
    for p in pebbles:
        print(prefix + ' ' + ' '.join(map(str, p)))


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if max(a) - min(a) > k:
    print('NO')
else:
    print('YES')
    m = min(a)
    for num in a:
        print(*[1] * m + list(range(1, 1 + num - m)))


n, k = map(int, input().split())
data = list(map(int, input().split()))

need = 0
res = [list() for _ in range(n)]


def custom_min(data):
    min = None
    for x in data:
        if min is None or x < min:
            min = x

    return 1 if min == 0 else min


def not_all_zeros(data):
    for x in data:
        if x != 0:
            return True
    return False


color = 1
min_v = custom_min(data)

while not_all_zeros(data) != 0:
    min_v = custom_min(data)

    if color > k:
        print("NO")
        break

    for i in range(len(data)):
        if data[i] != 0:
            val = min_v + 1 if (data[i] > min_v and color == 1) else min_v
            data[i] -= val
            res[i].append((color, val))

    color += 1
else:
    print('YES')
    for l in res:
        s = []

        for x in l:
            s += [str(x[0])] * x[1]

        print(' '.join(s))