The Greatest Secret Ever consists of n words, indexed by positive integers from 1 to n. The secret needs dividing between k Keepers (let's index them by positive integers from 1 to k), the i-th Keeper gets a non-empty set of words with numbers from the set U_{i} = (u_{i}, 1, u_{i}, 2, ..., u_{i}, |U_{i}|). Here and below we'll presuppose that the set elements are written in the increasing order.

We'll say that the secret is safe if the following conditions are hold:  for any two indexes i, j (1 ≤ i < j ≤ k) the intersection of sets U_{i} and U_{j} is an empty set;  the union of sets U_1, U_2, ..., U_{k} is set (1, 2, ..., n);  in each set U_{i}, its elements u_{i}, 1, u_{i}, 2, ..., u_{i}, |U_{i}| do not form an arithmetic progression (in particular, |U_{i}| ≥ 3 should hold). 

Let us remind you that the elements of set (u_1, u_2, ..., u_{s}) form an arithmetic progression if there is such number d, that for all i (1 ≤ i < s) fulfills u_{i} + d = u_{i} + 1. For example, the elements of sets (5), (1, 10) and (1, 5, 9) form arithmetic progressions and the elements of sets (1, 2, 4) and (3, 6, 8) don't.

Your task is to find any partition of the set of words into subsets U_1, U_2, ..., U_{k} so that the secret is safe. Otherwise indicate that there's no such partition.


-----Input-----

The input consists of a single line which contains two integers n and k (2 ≤ k ≤ n ≤ 10^6) — the number of words in the secret and the number of the Keepers. The numbers are separated by a single space.


-----Output-----

If there is no way to keep the secret safe, print a single integer "-1" (without the quotes). Otherwise, print n integers, the i-th of them representing the number of the Keeper who's got the i-th word of the secret.

If there are multiple solutions, print any of them.


-----Examples-----
Input
11 3

Output
3 1 2 1 1 2 3 2 2 3 1

Input
5 2

Output
-1

Difficulty: interview

Starter code:

Solutions:
import re
import itertools
from collections import Counter, deque

class Task:
    n, k = 0, 0
    answer = []
	
    def getData(self):
        self.n, self.k = [int(x) for x in input().split(' ')]
        #inFile = open('input.txt', 'r')
        #inFile.readline().rstrip()
        #self.childs = inFile.readline().rstrip()

    def solve(self):
        n, k = self.n, self.k
        if n < 3 * k:
            self.answer = '-1'
            return

        keeper = 1
        while keeper < k:
            self.answer += [keeper, keeper, keeper + 1]
            self.answer += [keeper, keeper + 1, keeper + 1]
            keeper += 2
        if keeper > k:
            self.answer += [k] * (n - len(self.answer))
            return
        else:
            self.answer += [keeper] * (n - len(self.answer))
            self.answer[-1] = 1
            self.answer[3] = keeper

    def printAnswer(self):
        print(re.sub(r'[\[\],]', '', str(self.answer)))
        #print(self.answer[:6])
        #outFile = open('output.txt', 'w')
        #outFile.write(self.answer)

task = Task()
task.getData()
task.solve()
task.printAnswer()


n, k = map(int, input().split())
if n < 3 * k: print(-1)
else:
    d = n // k
    p = [min(1 + i // d, k) for i in range(n)]
    
    for i in range(d, n, 2 * d):
        p[i], p[i - 1] = p[i - 1], p[i]
    if k > 2: p[0], p[-1] = p[-1], p[0]
    print(' '.join(str(i) for i in p))

n, k = map(int, input().split())
if n < 3 * k: print(-1)
else:
    d = n // k - 1
    t = list(str(i) + ' ' for i in range(1, k + 1))
    print(''.join(t) + ''.join(i * d for i in t) + t[-1] * (n - (d + 1) * k))

n, k = map(int, input().split())
if n < 3 * k: print(-1)
else:
    t = list(str(i) + ' ' for i in range(1, k + 1))
    print(''.join(t) + ''.join(i * 2 for i in t) + t[-1] * (n - 3 * k))

import sys

def solve():
    n, k = map(int, input().split())
    if n // k < 3 or n < 6:
        print(-1)
        return
    res = list()
    for i in range(1, k + 1):
        res.append(i)
        res.append(i)
    for i in range(1, k + 1):
        res.append(i)
    while len(res) < n: res.append(1);
    print(" ".join(map(str, res)))
    
solve()

import sys

def solve():
    n, k = map(int, input().split())
    if n // k < 3 or n < 6:
        print(-1)
        return
    res = list()
    for i in range(1, k + 1):
        res.append(i)
        res.append(i)
    for i in range(1, k + 1):
        res.append(i)
    while len(res) < n: res.append(1);
    print(" ".join(map(str, res)))
    
solve()

n, k = list(map(int, input().split()))
if n // k < 3:
    print(-1)
else:
    v = [0] * n
    for i in range(k):
        v[2 * i] = v[2 * i + 1] = i + 1
    for i in range(2 * k, n):
        v[i] = (i - 2 * k) % k + 1
    print(' '.join(map(str, v)))


import sys;

class MyReader:
#    file = null;
    def __init__(self):
        filename = "file.in";
        if self.isLocal():
            self.file = open(filename);
        self.str = [""];
        self.ind = 1;
            
    def isLocal(self):
        return len(sys.argv) > 1 and sys.argv[1] == "SCHULLZ";

    def nextString(self):
        if self.isLocal():
            return self.file.read();
        else:
            return input();
        
    def nextInt(self):
        return int(self.nextToken());

    def nextToken(self):
        if (self.ind >= len(self.str)):
            self.ind = 0;
            self.str = self.nextString().split();
        self.ind += 1;
        return self.str[self.ind - 1];

def SoLvE():
    rdr = MyReader();

    n = rdr.nextInt();
    m = rdr.nextInt();
    if n // m < 3:
        print((-1));
        return;

    a = [];
    for i in range(0, n):
        a.append(-1);

    cur = 0;
    for i in range(0, m):
        a[cur] = i + 1;
        cur += 1;
    for i in range(0, m):
        a[cur] = i + 1;
        cur += 1;
        

    for i in range(0, m - 1):        
        a[cur] = i + 2;
        cur += 1;
        
    a[cur] = 1;
    cur += 1;

    for cc in range(cur, n):
        a[cc] = cc % m + 1;
        cc += 1;

    for i in range(0, n):
        sys.stdout.write(str(a[i]));
        sys.stdout.write(" ");
    sys.stdout.flush()

SoLvE();






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

if n < 3 * k: print(-1)

else:

    d = n // k - 1

    t = list(str(i) + ' ' for i in range(1, k + 1))

    print(''.join(t) + ''.join(i * d for i in t) + t[-1] * (n - (d + 1) * k))



# Made By Mostafa_Khaled


import sys

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

if n // k < 3 or k == 1:
    print(-1)
    return

num = 1
output = []
for i in range(k):
    for j in range(2):
        output.append(str(i+1))
        num = num + 1

l = num + k
for i in range(k):
    output.append(str(i+1))
    num = num + 1

while num < n+1:
    output.append("1")
    num = num + 1

print(" ".join(output))

n, m = list(map(int, input().split()))
if n // m < 3:
    print(-1)
    return
res = []
for i in range(m):
    res.append(i+1)
    res.append(i+1)
for i in range(m):
    res.append(i+1)
print(' '.join(map(str, res)), '1 ' * (n - 3*m))


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

div_size = n // k

if div_size < 3:
    print(-1)
else:
    keepers = []

    for i in range(k):
        keepers.append(i + 1)

    for i in range(k):
        for _ in range(div_size - 1):
            keepers.append(i + 1)

    shortage = n - len(keepers)

    for _ in range(shortage):
        keepers.append(k)

    print(*keepers)

n, k = list(map(int, input().split()))
if k * 3 > n:
    print(-1)
else:
    ans = []
    for i in range(1, k * 2 + 1):
        ans.append(k if i % k == 0 else i % k)
    if k % 2:
        ans.append(k)
        for i in range(k - 1, 0, -1):
            if i % 2:
                ans.append(ans[-1] + i)
            else:
                ans.append(ans[-1] - i)
    else:
        ans.extend([i for i in range(k, 0, -1)])
    ans.extend([(k - (i % k)) for i in range(k * 3 + 1, n + 1)])
    print(*ans)


import sys

data = sys.stdin.read().split()
data_ptr = 0

def data_next():
    nonlocal data_ptr, data
    data_ptr += 1
    return data[data_ptr - 1]

N = int(data_next())
K = int(data_next())

if N // K < 3:
    print(-1)
else:
    ans = [K] * N
    pos = 1
    for i in range(1, K):
        if i % 2 == 1:
            ans[pos] = ans[pos + 1] = ans[pos + 3] = i
        else:
            ans[pos - 1] = ans[pos + 1] = ans[pos + 2] = i
        pos += 3
    print(*ans)




n,k=map(int,input().split())
if n//k <3:
    print("-1")
    return
ans=list()
for i in range(n):
    if i<2*k:
        ans.append(i // 2 + 1)
    elif (i//k)%2==0:
        ans.append(i%k+1)
    else :
        ans.append(k-i%k)
print(*ans)

n, m = map(int, input().split())
if n // m < 3:
    print(-1)
    return
res = []
for i in range(m):
    res.append(i+1)
    res.append(i+1)
for i in range(m):
    res.append(i+1)
print(' '.join(map(str, res)), '1 ' * (n - 3*m))

n, k = map(int, input().split())
if n < 3 * k: print(-1)
else:
    t = list(str(i) + ' ' for i in range(1, k + 1))
    print(''.join(t) + ''.join(i * 2 for i in t) + t[-1] * (n - 3 * k))

import sys

n, k = list(map(int, input().split()))
 
if k * 3 > n:
    print(-1)
    return
    
    
ans = [1] * n
if n == k * 3 and n % 2 == 1:
    if n == 3:
        print(-1)
        return
    l = n - (n % 6) - 6
    l = max(0, l)
    
    filled = 0
    f, s = 1, 2
    for i in range(l):
        if f > k:
            f = 1
        if s > k:
            s = 1
        if filled == k:
            break
        j = i % 6
        r = [f, f, s, f, s, s][j]
        ans[i] = r
        if j == 5:
            f, s = f + 2, s + 2
            filled += 1
        if j == 3:
            filled += 1
    tail = [k - 2, k - 2, k, k - 2, k - 1, k - 1, k, k, k - 1]
    for i in range(9):
        ans[l + i] = tail[i]
else:
    filled = 0
    f, s = 1, 2
    for i in range(n):
        if f > k:
            f = 1
        if s > k:
            s = 1
        if filled == k:
            break
        j = i % 6
        r = [f, f, s, f, s, s][j]
        ans[i] = r
        if j == 5:
            f, s = f + 2, s + 2
            filled += 1
        if j == 3:
            filled += 1
 
s = ' '.join(map(str, ans))
sys.stdout.write(s)