#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k;
    scanf("%d %d", &n, &k);
    if (k == 0) {
      for (int i = 1; i <= n; i++)
        printf("%d ", i);
      printf("\n");
    } else if (n % (2 * k))
      printf("-1\n");
    else {
      int sign = 0;
      for (int i = 1; i <= n; i++) {
        sign ? printf("%d ", i - k) : printf("%d ", i + k);
        if (i % k == 0)
          sign = !sign;
      }
      printf("\n");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     127f <main+0x15f>
lea    0xea4(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11ba <main+0x9a>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     11a7 <main+0x87>
mov    -0x14(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117c <main+0x5c>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127a <main+0x15a>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11e2 <main+0xc2>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1275 <main+0x155>
movl   $0x0,-0x18(%rbp)
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1267 <main+0x147>
cmpl   $0x0,-0x18(%rbp)
je     121f <main+0xff>
mov    -0x1c(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1233 <main+0x113>
mov    -0x1c(%rbp),%esi
add    -0x10(%rbp),%esi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
cltd
idivl  -0x10(%rbp)
cmp    $0x0,%edx
jne    1254 <main+0x134>
cmpl   $0x0,-0x18(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x18(%rbp)
jmp    1259 <main+0x139>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11f0 <main+0xd0>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    127a <main+0x15a>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeae(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
subl   $0x1,0x14(%rsp)
jae    1179 <main+0x39>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe80(%rip),%r14
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe75(%rip),%rbx
jmp    11b3 <main+0x73>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0xe63(%rip),%rdi
call   1040 <puts@plt>
subl   $0x1,0x14(%rsp)
jb     1168 <main+0x28>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%ecx
test   %esi,%esi
je     1230 <main+0xf0>
lea    (%rsi,%rsi,1),%edi
mov    %ecx,%eax
cltd
idiv   %edi
test   %edx,%edx
jne    11a0 <main+0x60>
mov    %r14,%r12
test   %ecx,%ecx
jle    1270 <main+0x130>
xor    %r13d,%r13d
mov    $0x1,%ebp
jmp    1219 <main+0xd9>
add    %ebp,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%esi
mov    %ebp,%eax
cltd
idiv   %esi
test   %edx,%edx
mov    %r15b,%r14b
cmove  %r14d,%r13d
lea    0x1(%rbp),%eax
cmp    0xc(%rsp),%ebp
mov    %eax,%ebp
jge    1270 <main+0x130>
xor    %r14d,%r14d
test   %r13d,%r13d
sete   %r15b
je     11f0 <main+0xb0>
neg    %esi
jmp    11f0 <main+0xb0>
nopl   0x0(%rax)
test   %ecx,%ecx
jle    1255 <main+0x115>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    0xc(%rsp),%ebp
jl     1240 <main+0x100>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11ac <main+0x6c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%r14
lea    0xc(%rsp),%r15
lea    0x10(%rsp),%r12
jmp    11ac <main+0x6c>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d \00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [4 x i8] c"-1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %9
9: ; preds = %74, %0
%10 = load i32, i32* %2
%11 = add nsw i32 %10, -1
store i32 %11, i32* %2
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %75
13: ; preds = %9
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
%15 = load i32, i32* %4
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %30
17: ; preds = %13
store i32 1, i32* %5
br label %18
18: ; preds = %25, %17
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp sle i32 %19, %20
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32, i32* %5
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %25
25: ; preds = %22
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %18
28: ; preds = %18
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %74
30: ; preds = %13
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = mul nsw i32 2, %32
%34 = srem i32 %31, %33
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %30
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %73
38: ; preds = %30
store i32 0, i32* %6
store i32 1, i32* %7
br label %39
39: ; preds = %68, %38
%40 = load i32, i32* %7
%41 = load i32, i32* %3
%42 = icmp sle i32 %40, %41
br i1 %42, label %43, label %71
43: ; preds = %39
%44 = load i32, i32* %6
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %51
46: ; preds = %43
%47 = load i32, i32* %7
%48 = load i32, i32* %4
%49 = sub nsw i32 %47, %48
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %49)
br label %56
51: ; preds = %43
%52 = load i32, i32* %7
%53 = load i32, i32* %4
%54 = add nsw i32 %52, %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %51, %46
%57 = phi i32 [ %50, %46 ], [ %55, %51 ]
%58 = load i32, i32* %7
%59 = load i32, i32* %4
%60 = srem i32 %58, %59
%61 = icmp eq i32 %60, 0
br i1 %61, label %62, label %67
62: ; preds = %56
%63 = load i32, i32* %6
%64 = icmp ne i32 %63, 0
%65 = xor i1 %64, true
%66 = zext i1 %65 to i32
store i32 %66, i32* %6
br label %67
67: ; preds = %62, %56
br label %68
68: ; preds = %67
%69 = load i32, i32* %7
%70 = add nsw i32 %69, 1
store i32 %70, i32* %7
br label %39
71: ; preds = %39
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %73
73: ; preds = %71, %36
br label %74
74: ; preds = %73, %28
br label %9
75: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %d\00"
@.str.2 = [4 x i8] c"%d \00"
@str = [3 x i8] c"-1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = add nsw i32 %6, -1
store i32 %7, i32* %1
%8 = icmp eq i32 %6, 0
br i1 %8, label %58, label %9
9: ; preds = %0
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
br label %12
12: ; preds = %9, %54
%13 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 0
%16 = load i32, i32* %2
br i1 %15, label %17, label %27
17: ; preds = %12
%18 = icmp slt i32 %16, 1
br i1 %18, label %19, label %21
19: ; preds = %21, %17
%20 = call i32 @putchar(i32 10)
br label %54
21: ; preds = %17, %21
%22 = phi i32 [ %24, %21 ], [ 1, %17 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %22)
%24 = add nuw nsw i32 %22, 1
%25 = load i32, i32* %2
%26 = icmp slt i32 %22, %25
br i1 %26, label %21, label %19
27: ; preds = %12
%28 = shl nsw i32 %14, 1
%29 = srem i32 %16, %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = icmp slt i32 %16, 1
br i1 %32, label %35, label %37
33: ; preds = %27
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %54
35: ; preds = %37, %31
%36 = call i32 @putchar(i32 10)
br label %54
37: ; preds = %31, %37
%38 = phi i32 [ %46, %37 ], [ %14, %31 ]
%39 = phi i32 [ %51, %37 ], [ 1, %31 ]
%40 = phi i32 [ %50, %37 ], [ 0, %31 ]
%41 = icmp eq i32 %40, 0
%42 = sub i32 0, %38
%43 = select i1 %41, i32 %38, i32 %42
%44 = add i32 %39, %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %44)
%46 = load i32, i32* %3
%47 = srem i32 %39, %46
%48 = icmp eq i32 %47, 0
%49 = zext i1 %41 to i32
%50 = select i1 %48, i32 %49, i32 %40
%51 = add nuw nsw i32 %39, 1
%52 = load i32, i32* %2
%53 = icmp slt i32 %39, %52
br i1 %53, label %37, label %35
54: ; preds = %33, %35, %19
%55 = load i32, i32* %1
%56 = add nsw i32 %55, -1
store i32 %56, i32* %1
%57 = icmp eq i32 %55, 0
br i1 %57, label %58, label %12
58: ; preds = %54, %0
ret i32 0
}