A permutation p is an ordered group of numbers p_1,   p_2,   ...,   p_{n}, consisting of n distinct positive integers, each is no more than n. We'll define number n as the length of permutation p_1,   p_2,   ...,   p_{n}.

Simon has a positive integer n and a non-negative integer k, such that 2k ≤ n. Help him find permutation a of length 2n, such that it meets this equation: $\sum_{i = 1}^{n}|a_{2 i - 1} - a_{2i}|-|\sum_{i = 1}^{n} a_{2 i - 1} - a_{2i}|= 2 k$.


-----Input-----

The first line contains two integers n and k (1 ≤ n ≤ 50000, 0 ≤ 2k ≤ n).


-----Output-----

Print 2n integers a_1, a_2, ..., a_2n — the required permutation a. It is guaranteed that the solution exists. If there are multiple solutions, you can print any of them.


-----Examples-----
Input
1 0

Output
1 2
Input
2 1

Output
3 2 1 4

Input
4 0

Output
2 7 4 6 1 3 5 8



-----Note-----

Record |x| represents the absolute value of number x. 

In the first sample |1 - 2| - |1 - 2| = 0.

In the second sample |3 - 2| + |1 - 4| - |3 - 2 + 1 - 4| = 1 + 3 - 2 = 2.

In the third sample |2 - 7| + |4 - 6| + |1 - 3| + |5 - 8| - |2 - 7 + 4 - 6 + 1 - 3 + 5 - 8| = 12 - 12 = 0.

Difficulty: MEDIUM
Tags: Dynamic programming

Mathematics

Constructive algorithms
Skill types: Dynamic programming

Starter code:

Solutions:
def former(n, k):
	lst = [i for i in range(1, 2 * n + 1)]
	f = len(lst) - 2
	for i in range(k):
		(lst[f], lst[-1]) = (lst[-1], lst[f])
		f -= 1
	print(*lst)
	return ''
(a, b) = map(int, input().strip().split())
print(former(a, b))


(n, k) = map(int, input().split())
l = [[1, 2 * n]]
a = 2
for i in range(n - 1):
	l.append([a, a + 1])
	a += 2
x = 2 * n - 1 + n - 1
y = x - 2 * k
c = 0
ans = []
for i in range(n):
	if c <= y:
		ans.extend(l[i][::-1])
		c += l[i][1] - l[i][0]
	else:
		ans.extend(l[i])
		c -= l[i][1] - l[i][0]
print(*ans)


(n, k) = map(int, input().split())
l = [x + 1 for x in range(2 * n)]
for i in range(2 * k):
	if i % 2 != 0:
		(l[2 * i], l[2 * i + 1]) = (l[2 * i + 1], l[2 * i])
print(*l)


(n, k) = map(int, input().split())
if k == 0:
	for i in range(1, 2 * n + 1):
		print(i, end=' ')
else:
	l = [i for i in range(1, 2 * n + 1)]
	for i in range(1, k + 1):
		j = 2 * i - 1
		m = 2 * i
		while j <= m:
			temp = l[j - 1]
			l[j - 1] = l[m - 1]
			l[m - 1] = temp
			j = j + 1
			m = m - 1
	for i in range(2 * n):
		print(l[i], end=' ')


def checkKey(dict, key):
	if key in dict:
		return True
	return False
(n, k) = map(int, input().split())
l = [0]
for i in range(1, 2 * n + 1):
	l.append(i)
index = 2
while k > 0:
	(l[index], l[index - 1]) = (l[index - 1], l[index])
	index += 2
	k -= 1
for i in range(1, 2 * n + 1):
	print(l[i], end=' ')
print()


import math

def f(perm):
	a1 = 0
	a2 = 0
	for i in range(len(perm) // 2):
		a1 += abs(perm[2 * i] - perm[2 * i + 1])
	for i in range(len(perm)):
		if i % 2 == 0:
			a2 += perm[i]
		else:
			a2 -= perm[i]
	a2 = abs(a2)
	return (a1 - a2) // 2
perm = [7, 1, 2, 3, 4, 5, 6, 8, 9, 10]
(n, k) = list(map(int, input().split(' ')))
res = []
if k == 0:
	for i in range(1, 2 * n + 1):
		res.append(i)
	print(res.__str__().replace(',', '').replace('[', '').replace(']', ''))
	return
if n % 2 == 0:
	znak = 1 + k
elif k == n:
	znak = k + 2
else:
	znak = k + 1
res.append(znak)
res.append(1)
pointer = 2
if pointer == znak:
	pointer += 1
for i in range(n - 1):
	a = pointer
	pointer += 1
	if pointer == znak:
		pointer += 1
	b = pointer
	pointer += 1
	if pointer == znak:
		pointer += 1
	res.append(a)
	res.append(b)
print(res.__str__().replace(',', '').replace('[', '').replace(']', ''))


(n, k) = map(int, input().split())
t = [i + 1 for i in range(2 * n)]
t = t[::-1]
index = t.index(k + 1)
if k > 0:
	if k % 2 == 1:
		for i in range(2 * n - 1, index, -1):
			t[i] = t[i - 1]
		t[index] = 1
	else:
		index = t.index(2 * k)
		for i in range(index, 2 * n - 1, 2):
			(t[i], t[i + 1]) = (t[i + 1], t[i])
for i in range(2 * n):
	print(t[i], end=' ')


(n, k) = map(int, input().split())
b = []
for i in range(2 * n):
	b.append(i + 1)
for i in range(k):
	t = b[2 * i]
	b[2 * i] = b[2 * i + 1]
	b[2 * i + 1] = t
print(*b, sep=' ')


(n, k) = map(int, input().split())
ans = []
for i in range(1, 2 * n + 1):
	ans.append(i)
for i in range(0, 2 * k, 2):
	(ans[i], ans[i + 1]) = (ans[i + 1], ans[i])
print(*ans)


(n, k) = list(map(int, input().split()))
a = [i for i in range(1, 2 * n + 1)]
for i in range(k):
	(a[2 * i], a[2 * i + 1]) = (a[2 * i + 1], a[2 * i])
print(*a)


(n, k) = map(int, input().split())
if k == 0:
	print('1', end='')
	for i in range(2, 2 * n + 1):
		print(' ' + str(i), end='')
	print()
elif 2 * k == n:
	i = n - k // 2
	j = n + k // 2
	if j - i != k:
		j += 1
	print(i, j, end='')
	start = 1
	end = 2 * n
	while start < end:
		if start == i or start == j:
			start += 1
			continue
		if end == j or end == i:
			end -= 1
			continue
		print(' ' + str(end), str(start), end='')
		start += 1
		end -= 1
	print()
else:
	L = list(range(1, 2 * n + 1))
	print('1 ', end=str(k + 1))
	for i in range(2 * n, 0, -1):
		if i == 1 or i == k + 1:
			continue
		print(' ' + str(i), end='')
	print()


(n, k) = map(int, input().split())
r = 2 * n - 2 * k
for i in range(2 * n, r, -2):
	print(i - 1, i, end=' ')
for i in range(r, 1, -2):
	print(i, i - 1, end=' ')


(n, k) = input().split()
n = int(n)
k = int(k)
arr = [i + 1 for i in range(2 * n)]
for i in range(k):
	(arr[2 * i], arr[2 * i + 1]) = (arr[2 * i + 1], arr[2 * i])
for i in arr:
	print(i)


(n, k) = map(int, input().split())
A = [i for i in range(2 * n, 0, -1)]
for i in range(k):
	if i > n:
		i %= n
	(A[2 * i], A[2 * i + 1]) = (A[2 * i + 1], A[2 * i])
print(' '.join(map(str, A)))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
MOD = 1000000007
PMOD = 998244353
T = 1
for _ in range(T):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	for i in range(n):
		if i > 0:
			print(' ', end='')
		if k > 0:
			print(str(2 * i + 2) + ' ' + str(2 * i + 1), end='')
		else:
			print(str(2 * i + 1) + ' ' + str(2 * i + 2), end='')
		k -= 1


def main():
	(n, k) = [int(x) for x in input().split()]
	for i in range(n):
		if k > 0:
			print(2 * i + 1, 2 * i + 2, end=' ')
			k -= 1
		else:
			print(2 * i + 2, 2 * i + 1, end=' ')
main()


(n, k) = map(int, input().split())
a = [[i + 1, i] for i in range(1, 2 * n + 1, 2)]
dp = {}
dp[0] = a
for i in range(k):
	a[i] = a[i][::-1]
	dp[i + 1] = a
x = [i for row in dp[k] for i in row]
print(' '.join((str(y) for y in x)))


(n, k) = [int(x) for x in input().split()]
for i in range(1, n + 1):
	if i <= k:
		print(2 * i - 1, end=' ')
		print(2 * i, end=' ')
	else:
		print(2 * i, end=' ')
		print(2 * i - 1, end=' ')


import math
import sys
(n, k) = map(int, input().split())
s = list(range(1, 2 * n + 1))
j = 0
for i in range(k):
	(s[j], s[j + 1]) = (s[j + 1], s[j])
	j += 2
print(' '.join((str(x) for x in s)))


(n, k) = map(int, input().split())
ans = []
for i in range(1, k + 1):
	ans.append(f'{2 * i - 1} {2 * i}')
for i in range(k + 1, n + 1):
	ans.append(f'{2 * i} {2 * i - 1}')
print(' '.join(ans))


a = input()
(n, k) = a.split(' ')
n = int(n)
k = int(k)
b = list()
b += [0]
for i in range(1, 2 * n + 1):
	b += [i]
for i in range(1, k + 1):
	(b[2 * i], b[2 * i - 1]) = (b[2 * i - 1], b[2 * i])
for i in range(1, 2 * n + 1):
	print(b[i], end=' ')


(n, k) = map(int, input().split())
if n == 0:
	print(0)
else:
	arr = [0] * 2 * n
	for i in range(2 * n):
		arr[i] = i + 1
for i in range(0, 2 * k, 2):
	temp = arr[i]
	arr[i] = arr[i + 1]
	arr[i + 1] = temp
for i in range(2 * n):
	print(arr[i], sep=' ', end=' ')


import math
from math import log2, sqrt
from bisect import bisect_left, bisect_right
import bisect
import sys
from sys import stdin, stdout
import os
sys.setrecursionlimit(pow(10, 7))
import collections
from collections import defaultdict
from statistics import median
from queue import Queue
inf = float('inf')
(n, k) = map(int, input().split())
l = [i + 1 for i in range(2 * n)]
for i in range(k):
	(l[2 * i], l[2 * i + 1]) = (l[2 * i + 1], l[2 * i])
print(*l)


(n, k) = map(int, input().split())
l = [0]
for i in range(1, 2 * n + 1):
	l.append(i)
for i in range(1, 2 * n + 1, 4):
	if k == 0:
		break
	(l[i], l[i + 1]) = (l[i + 1], l[i])
	k -= 1
for i in range(1, 2 * n + 1):
	print(l[i], end=' ')


(n, k) = map(int, input().split())
c = 1
ans = []
while k:
	k -= 1
	ans.append(c)
	c += 1
	ans.append(c)
	c += 1
	ans.append(c + 1)
	ans.append(c)
	c += 2
for i in range(c - 1, 2 * n, 2):
	ans.append(c)
	ans.append(c + 1)
	c += 2
print(*ans)


def mi():
	return map(int, input().split())
(n, k) = mi()
a = list(range(2 * n + 1))
for i in range(1, k + 1):
	(a[2 * i], a[2 * i - 1]) = (a[2 * i - 1], a[2 * i])
print(*a[1:])


import sys
input = sys.stdin.readline
import math
import copy
import collections
from collections import deque
(n, k) = list(map(int, input().split()))
ans = []
for i in range(n):
	if k > 0:
		ans.append(2 * n - 2 * i - 1)
		ans.append(2 * n - 2 * i)
		k -= 1
	else:
		ans.append(2 * n - 2 * i)
		ans.append(2 * n - 2 * i - 1)
for num in ans:
	print(num, end=' ')
print()


(n, k) = [int(a) for a in input().split()]
chk = [False] * (2 * n + 1)
for num in range(1, 2 * n, 2):
	print(num)
	chk[num] = True
	if num == 1:
		chk[2 * k + 2] = True
		print(2 * k + 2)
	elif chk[num - 1]:
		chk[num + 1] = True
		print(num + 1)
	else:
		chk[num - 1] = True
		print(num - 1)


(n, k) = map(int, input().split())
res = [i for i in range(1, 2 * n + 1)]
for i in range(1, k + 1):
	res[2 * i - 1] = 2 * i - 1
	res[2 * i - 2] = 2 * i
print(*res)


(n, k) = input().split()
n = int(n)
k = int(k)
l = []
l.append(0)
for i in range(1, 2 * n + 1):
	l.append(i)
for i in range(1, k + 1):
	x = 2 * i - 1
	y = 2 * i
	(l[x], l[y]) = (l[y], l[x])
for i in range(1, 2 * n + 1):
	print(l[i], end=' ')


(n, k) = map(int, input().split())
i = 1
s = []
while k:
	s.append(i + 1)
	s.append(i)
	i = i + 2
	k = k - 1
while i <= 2 * n:
	s.append(i)
	i = i + 1
print(*s)


(n, k) = list(map(int, input().strip().split()))
if k != 0:
	ans = [1 + k, 1]
else:
	ans = [1, 2]
i = 2
z = ans[1]
while i < 2 * n:
	z += 1
	if z == 1 + k:
		continue
	ans.append(z)
	i += 1
print(*ans)


import sys
input = sys.stdin.buffer.readline
(n, k) = map(int, input().split())
for i in range(1, n + 1):
	if k == 0:
		print(2 * i - 1, 2 * i, end=' ')
	else:
		print(2 * i, 2 * i - 1, end=' ')
		k -= 1


import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd
from collections import deque
from collections import Counter as c
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(var)

def l():
	return list(map(int, data().split()))

def sl():
	return list(map(str, data().split()))

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [[val for i in range(n)] for j in range(m)]
(n, k) = sp()
answer = [i for i in range(1, 2 * n + 1)]
for i in range(k):
	j = i
	(answer[2 * j + 1], answer[2 * j]) = (answer[2 * j], answer[2 * j + 1])
print(*answer)


(n, k) = map(int, input().split())
arr = [x + 1 for x in range(2 * n)]
for x in range(k):
	(arr[2 * x], arr[2 * x + 1]) = (arr[2 * x + 1], arr[2 * x])
for x in arr:
	print(x, end=' ')
print()


(n, k) = map(int, input().split())
a = [i for i in range(1, 2 * n + 1)]
i = 0
while k > 0:
	(a[i], a[i + 1]) = (a[i + 1], a[i])
	i += 2
	k -= 1
print(*a)


(n, k) = map(int, input().split())
gp1 = []
gp2 = []
for i in range(1, 2 * n + 1):
	if i % 2:
		gp2.append(i)
	else:
		gp1.append(i)
gp1.sort()
gp2.sort()
ans = 0
for i in range(n):
	if ans != 2 * k:
		ans += 2
		(gp1[i], gp2[i]) = (gp2[i], gp1[i])
for i in range(n):
	print(gp2[i], gp1[i], end=' ')


(n, k) = list(map(int, input().split()))
p = [str(i) for i in range(1, 2 * n + 1)]
for i in range(k):
	(p[2 * i], p[2 * i + 1]) = (p[2 * i + 1], p[2 * i])
print(' '.join(p))


from sys import stdin, stdout
from math import gcd
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, k) = iia()
ans = []
for i in range(1, 2 * n + 1, 2):
	if k > 0:
		ans.extend([i + 1, i])
		k -= 1
	else:
		ans.extend([i, i + 1])
print(*ans)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
from collections import deque
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	(n, k) = map(int, input().split())
	odd = [x for x in range(1, 2 * n + 1, 2)]
	even = [x for x in range(2, 2 * n + 2, 2)]
	odd.reverse()
	even.reverse()
	i = 0
	while k > 0:
		(odd[i], odd[i + 1]) = (odd[i + 1], odd[i])
		i += 2
		k -= 1
	res = []
	for i in range(n):
		res.append(even[i])
		res.append(odd[i])
	print(' '.join([str(x) for x in res]))
main()


import sys
(n, k) = map(int, sys.stdin.readline().split())
ans = []
for i in range(2 * n):
	ans.append(i + 1)
for i in range(0, 2 * k, 2):
	t = ans[i + 1]
	ans[i + 1] = ans[i]
	ans[i] = t
print(*ans)


def f(s):
	A = [int(i) for i in s.split()]
	first = 0
	for i in range(0, len(A) - 1, 2):
		first += abs(A[i + 1] - A[i])
	second = 0
	for i in range(0, len(A) - 1, 2):
		second += A[i] - A[i + 1]
	second = abs(second)
	return first - second
(n, k) = [int(i) for i in input().split()]
k = 2 * k
if k == 0:
	print(*[i for i in range(1, 2 * n + 1)])
elif k == 2 * n:
	print(2 * n, end=' ')
	for i in range(2 * n - 2, 0, -1):
		print(i, end=' ')
	print(1)
else:
	for i in range(k + 1, 0, -1):
		print(i, end=' ')
	for i in range(k + 2, 2 * n + 1):
		print(i, end=' ')
	print()


(n, k) = map(int, input().split())
a = [i + 1 for i in range(2 * n)]
for i in range(k):
	(a[2 * i], a[2 * i + 1]) = (a[2 * i + 1], a[2 * i])
a = ' '.join([str(i) for i in a])
print(a)


(i, k) = [int(a) for a in input().split()]
A = []
for i in range(1, 2 * i + 1):
	A.append(str(i))
for i in range(k):
	(A[4 * i], A[4 * i + 1]) = (A[4 * i + 1], A[4 * i])
s = ' '.join(A)
print(s)


import math
ans = []
(n, m) = map(int, input().split())
for i in range(1, n + 1):
	ans.append([2 * i - 1, 2 * i])
current = 0
i = 0
while current != 2 * m and i < n:
	if current < m and i < n:
		(ans[i][0], ans[i][1]) = (ans[i][1], ans[i][0])
		current += 1
	i += 1
for i in ans:
	print(*i, end=' ')


(n, k) = map(int, input().split())
for i in range(1, n + 1):
	(a, b) = (i * 2, i * 2 - 1)
	if k:
		(a, b) = (b, a)
		k -= 1
	print(a, b, end=' ')


from itertools import permutations

def difi(arr):
	adj = 0
	for i in range(0, len(arr) - 1, 2):
		adj += abs(arr[i + 1] - arr[i])
	adj -= abs(sum(arr[0::2]) - sum(arr[1::2]))
	return abs(adj)

def former(n, k):
	lst = [i for i in range(1, 2 * n + 1)]
	f = len(lst) - 2
	for i in range(k):
		(lst[f], lst[-1]) = (lst[-1], lst[f])
		f -= 1
	print(*lst)
	return ''
(a, b) = map(int, input().strip().split())
print(former(a, b))


(n, k) = map(int, input().split())
ans = []
for i in range(1, k + 1):
	ans.append(2 * i)
	ans.append(2 * i - 1)
for x in range(len(ans) + 1, 2 * n + 1):
	ans.append(x)
for i in ans:
	print(i, end=' ')


(n, k) = map(int, input().split())
arr = [i for i in range(1, 2 * n + 1)]
curr = 0
for i in range(k):
	(arr[curr], arr[curr + 1]) = (arr[curr + 1], arr[curr])
	curr += 2
print(*arr)


(n, k) = map(int, input().split())
first_n = k + 1
ans = list(range(1, 2 * n + 1))
ans.remove(first_n)
ans = [first_n] + ans
print(' '.join(map(str, ans)))


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)
(n, k) = map(int, input().split())
l = [i + 1 for i in range(0, 2 * n)]
for i in range(0, 2 * k, 2):
	(l[i], l[i + 1]) = (l[i + 1], l[i])
print(*l)


from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
if k:
	s = {2 * n - k, 2 * n}
	ans = [2 * n - k, 2 * n]
	for i in range(2 * n, 0, -1):
		if i not in s:
			ans.append(i)
else:
	ans = [i for i in range(2 * n, 0, -1)]
stdout.write(' '.join(list(map(str, ans))))


(n, k) = map(int, input().split())
ans = [i for i in range(1, 2 * n + 1)]
j = 0
for i in range(k):
	temp = ans[j]
	ans[j] = ans[j + 1]
	ans[j + 1] = temp
	j += 2
for i in ans:
	print(i, end=' ')


(n, k) = [int(x) for x in input().split()]
if k == 0:
	a = [i + 1 for i in range(2 * n)]
else:
	f = 0
	a = [1, k + 1]
	i = 2
	while i < 2 * n:
		x = i
		y = i + 1
		if x == k + 1:
			x = i + 1
			y = i + 2
			i = y + 1
		elif y == k + 1:
			x = i
			y = i + 2
			i = y + 1
		else:
			i += 2
		a += [y, x]
		if x == 100000 or y == 100000:
			f = 1
print(*a)


(n, k) = map(int, input().split())
temp = 2 * n
ans = []
while temp > 0:
	ans.append(temp)
	temp -= 1
i = 0
while k:
	(ans[i + 1], ans[i]) = (ans[i], ans[i + 1])
	i += 2
	k -= 1
print(*ans)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, k) = map(int, input().split())
	if k == 0:
		print(*[i for i in range(1, 2 * n + 1)])
	else:
		ans = []
		ans.append(k + 1)
		for i in range(1, k + 1):
			ans.append(i)
		for i in range(k + 2, 2 * n + 1):
			ans.append(i)
		print(*ans)

def nouse0():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse1():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse2():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def nouse3():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse4():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')

def nouse5():
	a = 420
	b = 420
	print(f'i am nitish{(a + b) // 2}')
main()


vals = [int(x) for x in input().split()]
n = vals[0]
k = vals[1]
visited = [False] * (2 * n + 1)
permutation = [i + 1 for i in range(2 * n)]
if k != 0:
	i = 0
	val = 1
	while i < 2 * n - 1:
		if not visited[val]:
			permutation[i] = val
			visited[val] = True
			if k != 0:
				nextVal = val + k if val + k <= 2 * n else val + 1
				permutation[i + 1] = nextVal
				visited[nextVal] = True
				i += 2
			else:
				i += 1
		val += 1
	temp = permutation[0]
	permutation[0] = permutation[1]
	permutation[1] = temp
print(' '.join((str(x) for x in permutation)))


R = lambda : map(int, input().split())
(n, k) = R()
arr = [i + 1 for i in range(n * 2)]
for i in range(0, 2 * k, 2):
	(arr[i], arr[i + 1]) = (arr[i + 1], arr[i])
print(' '.join(map(str, arr)))


import sys
import string
from collections import Counter, defaultdict
from math import fsum, sqrt, gcd, ceil, factorial
from itertools import combinations, permutations
flush = lambda : sys.stdout.flush
comb = lambda x, y: factorial(x) // factorial(y) // factorial(x - y)
ip = lambda : input()
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k) = r()
for i in range(n):
	d = i >= k
	print(2 * i + 1 + d, 2 * i + 2 - d, end=' ')


(n, k) = map(int, input().split())
for i in range(k):
	print(4 * i + 2, 4 * i + 1, 4 * i + 3, 4 * i + 4, end=' ')
for i in range(4 * k + 1, 2 * n + 1):
	print(i, end=' ')


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


from os import path
import sys, time
mod = int(1000000000.0 + 7)
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, permutations
from string import ascii_lowercase, ascii_uppercase
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
localsys = 0
start_time = time.time()
nCr = lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)

def ceill(n, x):
	return (n + x - 1) // x
T = 0

def solve():
	(n, k) = lint()
	for i in range(n):
		if k > 0:
			print(2 * i + 2, 2 * i + 1, end=' ')
		else:
			print(2 * i + 1, 2 * i + 2, end=' ')
		k -= 1

def run():
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
run()
T = I() if T else 1
for _ in range(T):
	solve()
if localsys:
	print('\n\nTime Elased :', time.time() - start_time, 'seconds')


from sys import stdin, stdout
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, input().split()))
for i in range(1):
	(n, k) = lst()
	ans = [i for i in range(2 * n + 1)]
	p = 1
	while k > 0:
		(ans[p], ans[p + 1]) = (ans[p + 1], ans[p])
		p += 2
		k -= 1
	print(*ans[1:])