Consider 2n rows of the seats in a bus. n rows of the seats on the left and n rows of the seats on the right. Each row can be filled by two people. So the total capacity of the bus is 4n.

Consider that m (m ≤ 4n) people occupy the seats in the bus. The passengers entering the bus are numbered from 1 to m (in the order of their entering the bus). The pattern of the seat occupation is as below:

1-st row left window seat, 1-st row right window seat, 2-nd row left window seat, 2-nd row right window seat, ... , n-th row left window seat, n-th row right window seat.

After occupying all the window seats (for m > 2n) the non-window seats are occupied:

1-st row left non-window seat, 1-st row right non-window seat, ... , n-th row left non-window seat, n-th row right non-window seat.

All the passengers go to a single final destination. In the final destination, the passengers get off in the given order.

1-st row left non-window seat, 1-st row left window seat, 1-st row right non-window seat, 1-st row right window seat, ... , n-th row left non-window seat, n-th row left window seat, n-th row right non-window seat, n-th row right window seat. [Image] The seating for n = 9 and m = 36. 

You are given the values n and m. Output m numbers from 1 to m, the order in which the passengers will get off the bus.


-----Input-----

The only line contains two integers, n and m (1 ≤ n ≤ 100, 1 ≤ m ≤ 4n) — the number of pairs of rows and the number of passengers.


-----Output-----

Print m distinct integers from 1 to m — the order in which the passengers will get off the bus.


-----Examples-----
Input
2 7

Output
5 1 6 2 7 3 4

Input
9 36

Output
19 1 20 2 21 3 22 4 23 5 24 6 25 7 26 8 27 9 28 10 29 11 30 12 31 13 32 14 33 15 34 16 35 17 36 18

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
def main_function():
	(n, m) = [int(i) for i in input().split(' ')]
	bus = [[[0 for i in range(n)] for h in range(2)] for p in range(2)]
	passenger_count = 0
	for i in range(1, m + 1):
		passenger_count += 1
		if passenger_count <= 2 * n:
			if passenger_count % 2 != 0:
				bus[0][0][(passenger_count - 1) // 2] = i
			else:
				bus[-1][-1][passenger_count // 2 - 1] = i
		elif passenger_count % 2 != 0:
			bus[0][-1][(passenger_count - 2 * n - 1) // 2] = i
		else:
			bus[-1][0][(passenger_count - 2 * n) // 2 - 1] = i
	indices = [[0, -1], [0, 0], [-1, 0], [-1, -1]]
	korea = []
	for i in range(n):
		for k in indices:
			if bus[k[0]][k[1]][i] != 0:
				korea.append(bus[k[0]][k[1]][i])
	print(' '.join([str(i) for i in korea]))
main_function()


(n, m) = map(int, input().split())
L1 = []
L2 = []
L3 = []
L4 = []
for i in range(1, m + 1):
	if i <= 2 * n:
		if i % 2 == 1:
			L1.append(i)
		else:
			L4.append(i)
	elif i % 2 == 1:
		L2.append(i)
	else:
		L3.append(i)
L1.reverse()
L2.reverse()
L3.reverse()
L4.reverse()
ans = []
while L1 or L2 or L3 or L4:
	if L2:
		ans.append(L2.pop())
	if L1:
		ans.append(L1.pop())
	if L3:
		ans.append(L3.pop())
	if L4:
		ans.append(L4.pop())
print(*ans)


a = input().split()
b = int(a[0])
c = int(a[1])
l1 = []
l2 = []
l3 = []
l4 = []
for i in range(1, c + 1):
	if i <= 2 * b:
		if i % 2 == 1:
			l1.append(i)
		else:
			l4.append(i)
	elif i % 2 == 1:
		l2.append(i)
	else:
		l3.append(i)
l = []
i = 0
while i <= int(c) + 1:
	try:
		l.append(l2[i])
	except:
		pass
	try:
		l.append(l1[i])
	except:
		pass
	try:
		l.append(l3[i])
	except:
		pass
	try:
		l.append(l4[i])
	except:
		pass
	i += 1
s = ''
for i in l:
	s = s + str(i) + ' '
print(s)


(n, m) = map(int, input().split())
(a, b, c, d) = ([], [], [], [])
for i in range(n):
	if 2 * i + 1 <= m:
		a.append(2 * i + 1)
for i in range(n, 2 * n):
	if 2 * i + 1 <= m:
		b.append(2 * i + 1)
for i in range(1, n + 1):
	if 2 * i <= m:
		d.append(2 * i)
for i in range(n + 1, 2 * n + 1):
	if 2 * i <= m:
		c.append(2 * i)
ans = []
for i in range(m):
	if len(b):
		ans.append(b[0])
		b.pop(0)
	if len(a):
		ans.append(a[0])
		a.pop(0)
	if len(c):
		ans.append(c[0])
		c.pop(0)
	if len(d):
		ans.append(d[0])
		d.pop(0)
	if len(ans) == m:
		break
print(*ans)


(n, m) = map(int, input().split())
i = 1
startingPoint = n * 2 + 1
lst = []
if n < m:
	for j in range(0, m):
		if startingPoint <= m:
			lst.append(startingPoint)
		lst.append(i)
		startingPoint = startingPoint + 1
		i = i + 1
	if lst[m - 1] > m:
		lst[m - 1] = lst[m]
		print(*lst[:m], sep=' ')
	else:
		print(*lst[:m], sep=' ')
else:
	for item in range(1, n + 1):
		lst.append(item)
	print(*lst[:m], sep=' ')


(n, m) = input().split(' ')
n = int(n)
m = int(m)
L = []
for i in range(1, 2 * n + 1):
	L.append(2 * n + i)
	L.append(i)
for i in range(4 * n):
	if L[i] <= m:
		print(L[i], end=' ')


from functools import partial
from itertools import zip_longest, chain

def solve(n, m):
	LW = range(1, min(n * 2, m) + 1, 2)
	RW = range(2, min(n * 2, m) + 1, 2)
	LM = range(n * 2 + 1, min(n * 4, m) + 1, 2)
	RM = range(n * 2 + 2, min(n * 4, m) + 1, 2)
	return chain.from_iterable(map(partial(filter, None), zip_longest(LM, LW, RM, RW)))
(n, m) = map(int, input().split())
print(' '.join(map(str, solve(n, m))))


linea = input().split(' ')
n = int(linea[0])
m = int(linea[1])
orden = []
L = 1
R = 2
x = 2 * n + 1
y = x + 1
total = 0
for j in range(n):
	orden.append(x)
	orden.append(L)
	orden.append(y)
	orden.append(R)
	x += 2
	L += 2
	y += 2
	R += 2
i = 0
while total < m:
	if orden[i] <= m and total != m - 1:
		print(orden[i], end=' ')
		total += 1
	elif orden[i] <= m:
		print(orden[i])
		total += 1
	i += 1


(n, m) = map(int, input().split())
ma = []
for i in range(2 * n):
	li = [i + 1]
	ma.append(li)
for i in range(2 * n, m):
	ma[i % (n * 2)].append(i + 1)
for i in range(2 * n):
	if i >= m:
		break
	if i == 2 * n - 1:
		print(*reversed(ma[i]), end='')
	else:
		print(*reversed(ma[i]), end=' ')
print()


(n, m) = input().split()
(n, m) = (int(n), int(m))
temp = 1
groos = n * 2 + 1
while groos <= m:
	print(groos, end=' ')
	print(temp, end=' ')
	(groos, temp) = (groos + 1, temp + 1)
while temp <= min(n * 2, m):
	print(temp, end=' ')
	temp += 1


(n, m) = map(int, input().split())
for i in range(1, m + 1):
	if i + 2 * n > m:
		if i > 2 * n:
			break
		print(i, end=' ')
	else:
		print(2 * n + i, i, end=' ')


(n, m) = map(int, input().split())
A = []
for i in range(1, 2 * n, 2):
	A += [2 * n + i, i, 2 * n + i + 1, i + 1]
print(*(a for a in A if a <= m))


(n, m) = map(int, input().split())
div = m / n
if div <= 2:
	print(' '.join(map(str, range(1, m + 1))))
else:
	full_len = n * 4
	full = [None] * full_len
	half_len = n * 2
	for i in range(half_len):
		full[i * 2 + 1] = i + 1
	for i in range(half_len):
		full[i * 2] = half_len + i + 1
	if div == 4:
		print(' '.join(map(str, full)))
		exit()
	result = [None] * m
	count = 0
	for i in range(full_len):
		cur = full[i]
		if cur <= m:
			result[count] = cur
			count += 1
			if count == m:
				break
	print(' '.join(map(str, result)))


s = input().split()
(n, m) = (int(s[0]), int(s[1]))
t = [0, 0, 0, 0]
x = []
k = 0
for i in range(n):
	x.append(t.copy())
for i in range(n):
	for j in (0, 3):
		if k == m:
			break
		k = k + 1
		x[i][j] = k
for i in range(n):
	for j in (1, 2):
		if k == m:
			break
		k = k + 1
		x[i][j] = k
s = ''
for i in range(n):
	for j in (1, 0, 2, 3):
		if x[i][j] != 0:
			s += str(x[i][j]) + ' '
print(s)


(n, m) = map(int, input().split())
left = []
right = []
for i in range(n):
	left.append([])
	right.append([])
for i in range(m):
	if i < 2 * n:
		if i % 2 == 0:
			left[i // 2].append(i + 1)
		else:
			right[i // 2].append(i + 1)
	elif i % 2 == 0:
		left[(i - 2 * n) // 2].append(i + 1)
	else:
		right[(i - 2 * n) // 2].append(i + 1)
s = ''
for i in range(n):
	for j in range(len(left[i]) - 1, -1, -1):
		s += str(left[i][j]) + ' '
	for j in range(len(right[i]) - 1, -1, -1):
		s += str(right[i][j]) + ' '
print(s[:-1])


(n, m) = map(int, input().split())
flags = [False for i in range(n * 4 + 1)]
for i in range(1, len(flags)):
	if i <= m:
		flags[i] = True
mass = []
for i in range(1, n * 2, 2):
	if flags[i + n * 2]:
		mass.append(i + n * 2)
	if flags[i]:
		mass.append(i)
	if flags[i + n * 2 + 1]:
		mass.append(i + n * 2 + 1)
	if flags[i + 1]:
		mass.append(i + 1)
print(' '.join(map(str, mass)))


(n, m) = [int(x) for x in input().split()]
people_order = [lambda x: 2 * n + x, lambda x: x, lambda x: 2 * n + x + 1, lambda x: x + 1]
result = []
for i in range(1, 2 * n + 1, 2):
	for f in people_order:
		k = f(i)
		if k <= m:
			result.append(str(k))
print(' '.join(result))


def get_ints():
	return list(map(int, input().split()))
(N, M) = get_ints()
for i in range(1, min(2 * N, M) + 1):
	if 2 * N + i <= M:
		print(2 * N + i, end=' ')
	print(i, end=' ')


(n, k) = map(int, input().split())
m = [[-1 for i in range(4)] for j in range(n)]
for i in range(min(2 * n, k)):
	if i % 2 == 0:
		m[i // 2][0] = i
	else:
		m[i // 2][3] = i
for i in range(k - 2 * n):
	if i % 2 == 0:
		m[i // 2][1] = i + 2 * n
	else:
		m[i // 2][2] = i + 2 * n
res = []
for i in range(n):
	for j in range(1, -1, -1):
		if m[i][j] != -1:
			res.append(m[i][j] + 1)
	for j in range(2, 4):
		if m[i][j] != -1:
			res.append(m[i][j] + 1)
print(*res)


(n, m) = map(int, input().split())
s = [[i for i in range(j + 1, 4 * n + 1, 2)] for j in range(2)]
r = [s[0][0:n], s[0][n:]]
l = [s[1][n:], s[1][0:n]]
a = []
for i in range(n):
	if r[1][i] <= m:
		a.append(r[1][i])
	if r[0][i] <= m:
		a.append(r[0][i])
	if l[0][i] <= m:
		a.append(l[0][i])
	if l[1][i] <= m:
		a.append(l[1][i])
print(*a)


(n, m) = map(int, input().split())
if m <= 2 * n:
	print(str.join(' ', [str(i + 1) for i in range(m)]))
else:
	r = []
	for i in range(1, 2 * n + 1):
		if 2 * n + i <= m:
			print(2 * n + i, end=' ')
		print(i, end=' ')


(n, m) = map(int, input().split())
r = []
for i in range(n):
	l = [2 * n + 1 + i * 2, 1 + i * 2]
	r += l + [l[0] + 1, l[1] + 1]
for x in r:
	if x <= m:
		print(x, end=' ')


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]
(n, m) = idata()
ans = [2 * n + 1, 1]
for i in range(4 * n - 2):
	ans += [ans[-2] + 1]
for i in range(len(ans)):
	if ans[i] <= m:
		print(ans[i], end=' ')


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


def solve():
	(N, M) = list(map(int, input().split()))
	ans = []

	def app(x):
		if x < M:
			ans.append(str(x + 1))
	for i in range(0, N * 2, 2):
		app(N * 2 + i)
		app(i)
		app(N * 2 + i + 1)
		app(i + 1)
	print(' '.join(ans))

def __starting_point():
	solve()
__starting_point()


def main():
	(n, m) = map(int, input().split())
	bus = [[None for _ in range(4)] for _ in range(n)]
	half = 2 * n
	for i in range(0, 2 * n, 2):
		row = i // 2
		bus[row][0] = i + 1
		bus[row][3] = i + 2
		bus[row][1] = half + i + 1
		bus[row][2] = half + i + 2
	out = []
	for row in bus:
		if row[1] <= m:
			out.append(row[1])
		if row[0] <= m:
			out.append(row[0])
		if row[2] <= m:
			out.append(row[2])
		if row[3] <= m:
			out.append(row[3])
	print(' '.join((str(x) for x in out)))
main()


(N, M) = list(map(int, input().split(' ')))
half = min(2 * N, M)
for i in range(half):
	if half + i + 1 <= M:
		print(half + i + 1, end=' ')
	print(i + 1, end=' ')
print()


import sys
import math
import itertools as it
import operator as op
import fractions as fr
(n, m) = map(int, sys.stdin.readline().split())
A = [[-1 for _ in range(4)] for _ in range(n)]
(i, j) = (0, 0)
for k in range(1, m + 1):
	A[i][j] = k
	if i == n - 1 and j == 3:
		(i, j) = (0, 2)
	elif j > 1:
		i += 1
	j = [3, 2, 1, 0][j]
(i, j) = (0, 1)
B = []
for _ in range(4 * n):
	if A[i][j] != -1:
		B.append(A[i][j])
	if j == 3:
		i += 1
	j = [2, 0, 3, 1][j]
print(' '.join(map(str, B)))


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


(rows, pas) = map(int, input().split())
(lw, lc, rw, rc) = ([], [], [], [])
for i in range(rows * 2):
	if i % 2:
		rw.append(i + 1)
	else:
		lw.append(i + 1)
for i in range(rows * 2, rows * 4):
	if i % 2:
		rc.append(i + 1)
	else:
		lc.append(i + 1)
out = []
for i in range(4 * rows):
	if i % 4 == 0:
		out.append(lc.pop(0))
	if i % 4 == 1:
		out.append(lw.pop(0))
	if i % 4 == 2:
		out.append(rc.pop(0))
	if i % 4 == 3:
		out.append(rw.pop(0))
for i in out:
	if i <= pas:
		print(i, end=' ')


from sys import stdin, stdout

def row(i, n):
	return [i * 2 - 1, 2 * n + 2 * i - 1, 2 * n + 2 * i, i * 2]
(n, m) = map(int, stdin.readline().strip().split())
ans = ''
i = 1
while i <= n and i * 2 - 1 <= m:
	r = row(i, n)
	for x in [1, 0, 2, 3]:
		if r[x] <= m:
			ans += str(r[x]) + ' '
	i += 1
ans = ans.strip()
stdout.write(ans + '\n')


(n, m) = map(int, input().split())
s = ''

def rr(n, m, i, j):
	if j == 0:
		if 2 * i + 1 <= m:
			return 2 * i + 1
		else:
			return 0
	elif j == 1:
		if 2 * n + 2 * i + 1 <= m:
			return 2 * i + 2 * n + 1
		else:
			return 0
	elif j == 2:
		if 2 * i + 2 + 2 * n <= m:
			return 2 * i + 2 + 2 * n
		else:
			return 0
	elif 2 * i + 2 <= m:
		return 2 * i + 2
	else:
		return 0
for i in range(n):
	for j in (1, 0, 2, 3):
		a = rr(n, m, i, j)
		if a != 0:
			s += str(a) + ' '
print(s)


(n, m) = map(int, input().split())
for i in range(1, 2 * n, 2):
	for j in (2 * n + i, i, 2 * n + i + 1, i + 1):
		if j <= m:
			print(j, end=' ')


line = input()
n = int(line.split()[0])
m = int(line.split()[1])
seats = [[None for column in range(4)] for row in range(n)]

def entry_state_transition(col, row):
	if col == 0:
		col = 3
	elif col == 3:
		col = 0
		row += 1
	elif col == 1:
		col = 2
	elif col == 2:
		col = 1
		row += 1
	if row == n:
		row = 0
		col += 1
	return (col, row)

def exit_state_transition(col, row):
	if col == 1:
		col = 0
	elif col == 0:
		col = 2
	elif col == 2:
		col = 3
	elif col == 3:
		col = 1
		row += 1
	return (col, row)
row = 0
col = 0
for i in range(m):
	seats[row][col] = i + 1
	(col, row) = entry_state_transition(col, row)
row = 0
col = 1
for i in range(m):
	while seats[row][col] is None:
		(col, row) = exit_state_transition(col, row)
	print(seats[row][col], end=' ')
	(col, row) = exit_state_transition(col, row)


(n, m) = [int(x) for x in input().split()]
l = []
p1 = 1
p2 = 2 * n + 1
while p1 <= 2 * n:
	if p2 <= m:
		l.append(str(p2))
	p2 += 1
	if p1 <= 2 * n and p1 <= m:
		l.append(str(p1))
	p1 += 1
print(' '.join(l))


def main():
	(n, m) = (int(x) for x in input().split())
	seatings = solver(n, m)
	for x in seatings:
		if x != None:
			print(x, end=' ')

def solver(n, m):
	seatings = [None] * (4 * n + 1)
	i = 1
	while i < m and i <= 2 * n:
		seatings[2 * i] = i
		i += 1
	while i <= m:
		seatings[2 * i - 4 * n - 1] = i
		i += 1
	return seatings
main()


(n, m) = map(int, input().split())
if m <= 2 * n:
	for i in range(m):
		print(i + 1, end=' ')
	print()
else:
	beg = 2 * n + 1
	i = 1
	while beg <= m:
		print(beg, i, end=' ')
		beg += 1
		i += 1
	while i <= 2 * n:
		print(i, end=' ')
		i += 1
	print()


(n, m) = map(int, input().split())
op = []
if m <= 2 * n:
	for i in range(1, m + 1):
		print(i, end=' ')
else:
	p = m - 2 * n
	l = p % 2
	p = p // 2
	for i in range(1, p + 1):
		op.append(2 * n + 2 * i - 1)
		op.append(2 * i - 1)
		op.append(2 * n + 2 * i)
		op.append(2 * i)
	if l == 1:
		op.append(m)
	for i in range(2 * p + l, 2 * n + 1):
		op.append(i)
	op2 = []
	for i in op:
		if i not in op2:
			print(i, end=' ')
			op2.append(i)


(n, m) = map(int, input().split())
c = 1
b = []
for i in range(n):
	temp = []
	for j in range(4):
		temp.append(0)
	b.append(temp)
i = 0
jr = 3
jl = 0
while c <= m:
	if c % 2 == 0:
		b[i][jr] = c
		i += 1
	else:
		b[i][jl] = c
	c += 1
	if i == n:
		i = 0
		jr = 2
		jl = 1
i = 0
j = 1
l = []
while i < n:
	if b[i][j] != 0:
		l.append(b[i][j])
	if j == 1:
		j = 0
	elif j == 0:
		j = 2
	elif j == 2:
		j = 3
	elif j == 3:
		j = 1
		i += 1
print(*l)


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


(n, m) = map(int, input().split())
a = [[0] * 4 for i in range(n)]
for i in range(n):
	a[i][0] = 2 * i
	a[i][1] = 2 * (i + n)
	a[i][2] = 2 * (i + n) + 1
	a[i][3] = 2 * i + 1
ans = []
for i in range(n):
	ans.append(a[i][1])
	ans.append(a[i][0])
	ans.append(a[i][2])
	ans.append(a[i][3])
for i in range(4 * n):
	if ans[i] < m:
		print(ans[i] + 1, end=' ')


from math import ceil
(n, m) = map(int, input().split())
if m > 2 * n:
	p = 2 * n
	A = []
	r = 1 + 2 * n
	for i in range(n):
		if r <= m and r > 0:
			A.append(r)
		r = r - p
		if r <= m and r > 0:
			A.append(r)
		r = r + 1 + p
		if r <= m and r > 0:
			A.append(r)
		r = r - p
		if r <= m and r > 0:
			A.append(r)
		r += 1 + p
	print(*A)
elif m <= 2 * n:
	print(*[i for i in range(1, m + 1)])


(n, m) = map(int, input().split())
seats = [[0] * n for _ in range(4)]
for i in range(min(2 * n, m)):
	if i % 2 == 0:
		seats[0][i // 2] = i + 1
	else:
		seats[3][i // 2] = i + 1
for i in range(2 * n, m):
	if i % 2 == 0:
		seats[1][(i - 2 * n) // 2] = i + 1
	else:
		seats[2][(i - 2 * n) // 2] = i + 1
ans = []
for i in range(n):
	for x in [seats[1][i], seats[0][i], seats[2][i], seats[3][i]]:
		if x != 0:
			ans.append(x)
print(*ans)


t = list(map(int, input().split()))
n = t[0]
m = t[1]
seat = [[0 for i in range(n)] for j in range(4)]
for i in range(1, min(2 * n, m) + 1):
	j = (i - 1) // 2
	if i % 2 == 0:
		seat[3][j] = i
	else:
		seat[0][j] = i
for i in range(2 * n + 1, m + 1):
	j = (i - 2 * n - 1) // 2
	if i % 2 == 0:
		seat[2][j] = i
	else:
		seat[1][j] = i

def check(i, j):
	if seat[i][j] != 0:
		print(seat[i][j], end=' ')
for i in range(n):
	check(1, i)
	check(0, i)
	check(2, i)
	check(3, i)


import sys
import math
from dataclasses import dataclass
(n, m) = map(int, input().split())
(a, b, c, d) = (1, 2 * n + 1, 2 * n + 2, 2)
while c <= 4 * n:
	if b <= m:
		print('%d ' % b, end='')
	if a <= m:
		print('%d ' % a, end='')
	if c <= m:
		print('%d ' % c, end='')
	if d <= m:
		print('%d ' % d, end='')
	(a, b, c, d) = (a + 2, b + 2, c + 2, d + 2)
print('')


import sys
(n, m) = map(int, input().split())
seat = [[0, 0, 0, 0] for _ in range(n)]
i = 1
for j in range(n):
	if i <= m:
		seat[j][0] = i
	i += 1
	if i <= m:
		seat[j][-1] = i
	i += 1
for j in range(n):
	if i <= m:
		seat[j][1] = i
	i += 1
	if i <= m:
		seat[j][2] = i
	i += 1
ans = []
for i in range(n):
	for j in (1, 0, 2, 3):
		if seat[i][j] != 0:
			ans.append(seat[i][j])
print(*ans)


args = input().split()
n = int(args[0])
m = int(args[1])
bus = [[0 for x in range(4)] for x in range(n)]
for i in range(1, m + 1):
	if i <= 2 * n and i % 2 == 0:
		bus[i // 2 - 1][3] = i
	elif i <= 2 * n and i % 2 == 1:
		bus[(i - 1) // 2][0] = i
	elif i > 2 * n and i % 2 == 0:
		bus[(i - 2 * n) // 2 - 1][2] = i
	elif i > 2 * n and i % 2 == 1:
		bus[(i - 2 * n - 1) // 2][1] = i
ans = []
for i in range(n):
	for j in [1, 0, 2, 3]:
		if bus[i][j] != 0:
			ans.append(bus[i][j])
ans = list(map(str, ans))
print(' '.join(ans))


(n, m) = map(int, input().split())
half = min(2 * n, m)
for i in range(half):
	if half + i + 1 <= m:
		print(half + i + 1, end=' ')
	print(i + 1, end=' ')


import sys
sys.stderr = sys.stdout

def bus(n, m):
	B = [[None] * 4 for _ in range(n)]
	n2 = 2 * n
	n4 = 4 * n
	for i in range(0, min(m, n2), 2):
		B[i // 2][0] = i + 1
	for i in range(1, min(m, n2), 2):
		B[i // 2][3] = i + 1
	for i in range(n2, min(m, n4), 2):
		B[(i - n2) // 2][1] = i + 1
	for i in range(n2 + 1, min(m, n4), 2):
		B[(i - n2) // 2][2] = i + 1
	L = [b for i in range(n) for b in (B[i][1], B[i][0], B[i][2], B[i][3]) if b is not None]
	assert len(L) == m
	return L

def main():
	(n, m) = readinti()
	print(' '.join(map(str, bus(n, m))))

def readint():
	return int(input())

def readinti():
	return map(int, input().split())

def readintt():
	return tuple(readinti())

def readintl():
	return list(readinti())

def readinttl(k):
	return [readintt() for _ in range(k)]

def readintll(k):
	return [readintl() for _ in range(k)]

def log(*args, **kwargs):
	print(*args, **kwargs, file=sys.__stderr__)
main()


(n, m) = map(int, input().split())
arr = [[0, 0, 0, 0] for i in range(n)]
i = 1
pos = 0
while 1:
	if i > m or pos == n:
		break
	if i <= m:
		arr[pos][0] = i
		i += 1
	if i <= m:
		arr[pos][3] = i
		i += 1
	pos += 1
pos = 0
while 1:
	if i > m or pos == n:
		break
	if i <= m:
		arr[pos][1] = i
		i += 1
	if i <= m:
		arr[pos][2] = i
		i += 1
	pos += 1
for i in arr:
	if i[1]:
		print(i[1], end=' ')
	if i[0]:
		print(i[0], end=' ')
	if i[2]:
		print(i[2], end=' ')
	if i[3]:
		print(i[3], end=' ')


ans = []

def fillin1(m, n, r1, r2, r3, r4):
	if m > 2 * n:
		temp = m - 2 * n + 2
		if temp < 4:
			if temp == 3:
				ans.extend([r2, r1, r4])
			elif temp == 2:
				ans.extend([r1, r4])
			fillin1(m - temp, n - 1, r1 + 2, r2 + 2, r3 + 2, r4 + 2)
		else:
			ans.extend([r2, r1, r3, r4])
			fillin1(m - 4, n - 1, r1 + 2, r2 + 2, r3 + 2, r4 + 2)
	else:
		ans.extend(list(range(r1, r1 + m)))
(n, m) = map(int, input().split(' '))
fillin1(m, n, 1, n * 2 + 1, n * 2 + 2, 2)
ans = map(lambda x: str(x), ans)
print(' '.join(ans))


(n, m) = map(int, input().split())
a = [[] for i in range(4)]
for i in range(4 * n):
	cur = i + 1 if i < m else -1
	if len(a[0]) < n or len(a[3]) < n:
		if len(a[0]) == len(a[3]):
			a[0].append(cur)
		else:
			a[3].append(cur)
	elif len(a[1]) == len(a[2]):
		a[1].append(cur)
	else:
		a[2].append(cur)
for v in a:
	v.reverse()
for i in range(n):
	for col in (1, 0, 2, 3):
		if a[col][-1] != -1:
			print(a[col][-1], end=' ')
		a[col].pop()
print()


def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def MAP2():
	return map(float, input().split())

def LIST():
	return list(map(int, input().split()))

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
(n, m) = MAP()
odd = []
even = []
for i in range(1, m + 1):
	if i % 2 == 0:
		even.append(i)
	else:
		odd.append(i)
a = []
b = []
for i in range(n):
	a.append([])
for i in range(n):
	b.append([])
j = 0
for i in range(len(odd)):
	if i == n:
		j = 0
		a[j].append(odd[i])
		j += 1
	else:
		a[j].append(odd[i])
		j += 1
j = 0
for i in range(len(even)):
	if i == n:
		j = 0
		b[j].append(even[i])
		j += 1
	else:
		b[j].append(even[i])
		j += 1
res = []
flag = 0
for i in range(n):
	x = a[i]
	y = b[i]
	x = list(reversed(x))
	y = list(reversed(y))
	for i in x:
		res.append(i)
	for i in y:
		res.append(i)
print(*res)


import sys
import math
(n, k) = map(int, input().split())
(l, r, i, ok) = (n * 2 + 1, 1, 1, False)
while l <= k or (r <= k and (l <= 4 * n and r <= 2 * n)):
	if l <= k and l <= 4 * n:
		print(l, end=' ')
		l = l + 1
	if r <= k and r <= 2 * n:
		print(r, end=' ')
		r = r + 1


'__author__' == 'deepak Singh Mehta) learning to code '
(n, m) = map(int, input().split())
assert m >= 1 and m <= 4 * n
if m % 2 != 0:
	k = n * 4 // 2
	k += 1
	for i in range(1, n * 4 // 2 + 1):
		if k <= m:
			print(k, end=' ')
			k += 1
		if i <= m:
			print(i, end=' ')
else:
	k = n * 4 // 2
	k += 1
	for i in range(1, n * 4 // 2 + 1):
		if k <= m:
			print(k, end=' ')
			k += 1
		if i <= m:
			print(i, end=' ')


(n, m) = map(int, input().split())
if m <= 2 * n:
	print(*[i for i in range(1, m + 1)])
else:
	x = [i for i in range(1, 2 * n + 1)]
	y = [i for i in range(2 * n + 1, m + 1)]
	for i in range(m):
		k = min(len(x), len(y))
		if i // 2 < k:
			print(y[i // 2] if i % 2 == 0 else x[i // 2], end=' ')
		else:
			print(*(x[i // 2:] if k == len(y) else y[i // 2:]))
			break


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


(rows, ppl) = input().split(' ')
rows = int(rows)
ppl = int(ppl)
ary = []
for i in range(1, 2 * rows + 1):
	ary.append(2 * rows + i)
	ary.append(i)
for i in range(4 * rows):
	if ary[i] <= ppl:
		print(ary[i], end=' ')


(n, m) = [int(x) for x in input().split()]
M = [[0, 0, 0, 0] for i in range(n)]
for i in range(1, min(m, 2 * n) + 1, 2):
	M[i // 2][1] = i
for i in range(2, min(m, 2 * n) + 1, 2):
	M[i // 2 - 1][3] = i
for i in range(2 * n + 1, m + 1, 2):
	M[i // 2 - n][0] = i
for i in range(2 * n + 2, m + 1, 2):
	M[i // 2 - n - 1][2] = i
for i in range(n):
	for j in range(4):
		if M[i][j] != 0:
			print(M[i][j], end=' ')


(n, m) = map(int, input().split())
a = [[0 for i in range(4)] for j in range(n)]
for i in range(min(n, m // 2 + m % 2)):
	a[i][0] = 2 * i + 1
for i in range(min(n, m // 2)):
	a[i][3] = 2 * i + 2
for i in range((m - 2 * n) // 2 + (m - 2 * n) % 2):
	a[i][1] = 2 * n + 2 * i + 1
for i in range((m - 2 * n) // 2):
	a[i][2] = 2 * n + 2 * i + 2
row = 0
for i in range(n):
	if a[i][1] != 0:
		print(a[i][1], end=' ')
	if a[i][0] != 0:
		print(a[i][0], end=' ')
	if a[i][2] != 0:
		print(a[i][2], end=' ')
	if a[i][3] != 0:
		print(a[i][3], end=' ')


(n, m) = map(int, input().strip().split())
seats = [[1, 2 * n + 1, 2 * n + 2, 2]]
for _ in range(1, n):
	new_seat = []
	new_seat += [seats[-1][-1] + 1]
	new_seat += [seats[-1][2] + 1]
	new_seat += [new_seat[-1] + 1]
	new_seat += [new_seat[0] + 1]
	seats += [new_seat]
ans = []
for seat in seats:
	if seat[1] <= m:
		ans += [seat[1]]
	if seat[0] <= m:
		ans += [seat[0]]
	if seat[2] <= m:
		ans += [seat[2]]
	if seat[-1] <= m:
		ans += [seat[-1]]
print(*ans)


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)

def hnbhai():
	(n, m) = sd()
	leftW = []
	rightW = []
	i = 0
	while len(leftW) < n and len(rightW) < n and (i < m):
		leftW.append(i + 1)
		if i + 1 == m:
			i += 1
			break
		rightW.append(i + 2)
		i += 2
	left = []
	right = []
	while i < m and len(left) < n and (len(right) < n):
		left.append(i + 1)
		if i + 1 == m:
			i += 1
			break
		right.append(i + 2)
		i += 2
	while True:
		if len(left) > 0:
			print(left.pop(0), end=' ')
		if len(leftW) > 0:
			print(leftW.pop(0), end=' ')
		if len(right) > 0:
			print(right.pop(0), end=' ')
		if len(rightW) > 0:
			print(rightW.pop(0), end=' ')
		if len(left) == 0 and len(right) == 0 and (len(leftW) == 0) and (len(rightW) == 0):
			break
	print()
for _ in range(1):
	hnbhai()


P = lambda : map(int, input().split())
(n, m) = P()
l = list()
for i in range(m):
	if i + 1 <= 2 * n:
		l.append([i + 1])
	else:
		l[i % (2 * n)].append(i + 1)
for i in l:
	print(*i[::-1], end=' ')


(n, m) = map(int, input().split())
a = []
for i in range(0, 4 * n):
	a.append(0)
if m < 2 * n:
	for i in range(0, m):
		print(i + 1, ' ')
else:
	for i in range(0, 4 * n, 2):
		a[i + 1] = i // 2 + 1
	for i in range(0, 2 * m - 4 * n, 2):
		a[i] = 2 * n + i // 2 + 1
print(' '.join((str(i) for i in a if i != 0)))


import sys
import math
import bisect

def solve(n, m):
	A = []
	for i in range(n):
		A.append([0] * 4)
	cur = 1
	for i in range(n):
		A[i][0] = cur
		cur += 1
		A[i][3] = cur
		cur += 1
	for i in range(n):
		A[i][1] = cur
		cur += 1
		A[i][2] = cur
		cur += 1
	B = []
	for i in range(n):
		B.append(A[i][1])
		B.append(A[i][0])
		B.append(A[i][2])
		B.append(A[i][3])
	C = []
	for a in B:
		if a <= m:
			C.append(a)
	return C

def main():
	(n, m) = map(int, input().split())
	ans = solve(n, m)
	print(' '.join(list((str(a) for a in ans))))
main()


(a, b) = map(int, input().split())
c = []
e = ''
for x in range(1, b + 1):
	c.append(x)
if b == 1:
	print(b)
else:
	for x in range(a * 2):
		if x > b - 1:
			break
		if x + 2 * a <= b - 1:
			e += str(c[x + 2 * a]) + ' '
		e += str(c[x]) + ' '
print(e[:-1])


a = [int(i) for i in input().split()]
sign = 0
b = []
c = []
for i in range(0, a[0]):
	b.append(1 + 4 * i)
	b.append(1 + 4 * i + 3)
for i in range(1, a[0] + 1):
	b.append(1 + 4 * i - 3)
	b.append(1 + 4 * i - 2)
for i in range(4 * a[0]):
	if i > a[1] - 1:
		b[i] = 0
for i in range(0, a[0]):
	if 1 + 4 * i + 1 in b:
		c.append(b.index(1 + 4 * i + 1) + 1)
	if 1 + 4 * i in b:
		c.append(b.index(1 + 4 * i) + 1)
	if 1 + 4 * i + 2 in b:
		c.append(b.index(1 + 4 * i + 2) + 1)
	if 1 + 4 * i + 3 in b:
		c.append(b.index(1 + 4 * i + 3) + 1)
for i in c:
	print(i, end=' ')


import sys
import math
import collections
from pprint import pprint as pp
mod = 998244353
MAX = 10 ** 15

def inp():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat
(n, m) = inp()
a = matrix(n, 4)
j = 0
temp = 1
for i in range(m):
	if i < 2 * n:
		a[j][temp] = i + 1
		temp = (temp + 2) % 4
	else:
		a[j][temp - 1] = i + 1
		temp = (temp + 2) % 4
	if temp == 1:
		j = (j + 1) % n
(i, j) = (0, 0)
temp = 0
while i < m:
	if a[j][temp] != 0:
		print(a[j][temp], end=' ')
		i += 1
	temp = (temp + 1) % 4
	if temp == 0:
		j += 1


(n, m) = map(int, input().split())
for x in range(1, 2 * n + 1):
	num = 2 * n + x
	if num <= m:
		print(num, end=' ')
	num = x
	if num <= m:
		print(num, end=' ')


(n, m) = list(map(int, input().split()))
y = [2 * n - 1, -1, 2 * n, 0]
k = 2
count = 0
t = 0
i = -1
while t < m:
	i += 1
	if y[i % 4] + k <= m:
		print(y[i % 4] + k, end=' ')
		count += 1
		t += 1
	else:
		count += 1
	if count == 4:
		k += 2
		count = 0
	else:
		continue


def mp():
	return list(map(int, input().split()))

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)
(n, m) = mp()
if m <= 2 * n:
	print(' '.join([str(i + 1) for i in range(m)]))
else:
	d = (m - 2 * n) // 2
	L = []
	for i in range(d):
		L += [2 * n + 2 * i + 1, 2 * i + 1, 2 * n + 2 * i + 2, 2 * i + 2]
	c = m - 2 * n - 2 * d
	if c == 1:
		L.append(m)
	for i in range(d, n):
		L += [2 * i + 1, 2 * i + 2]
	print(' '.join([str(x) for x in L]))


s = input().split()
n = int(s[0])
m = int(s[1])
bus = [0 for i in range(0, 4 * n)]
u = 1
i = 0
while u < m and i < n:
	bus[4 * i] = u
	bus[4 * i + 3] = u + 1
	u = u + 2
	i = i + 1
if u == m and i < n:
	bus[4 * i] = u
	u = u + 1
i = 0
while u < m and i < n:
	bus[4 * i + 1] = u
	bus[4 * i + 2] = u + 1
	u = u + 2
	i += 1
if u == m and i < n:
	bus[4 * i + 1] = u
	u = u + 1
for y in range(n):
	if bus[4 * y + 1] != 0:
		print(bus[4 * y + 1], end=' ')
	if bus[4 * y] != 0:
		print(bus[4 * y], end=' ')
	if bus[4 * y + 2] != 0:
		print(bus[4 * y + 2], end=' ')
	if bus[4 * y + 3] != 0:
		print(bus[4 * y + 3], end=' ')


(m, n) = map(int, input().split())
r = []
x = 2 * m
for i in range(1, x + 1):
	if i + 2 * m <= n:
		r += [i + x]
	if i <= n:
		r += [i]
print(*r)


def bus_seats(n, m):
	w = 0
	e = 0
	v = []
	a = [0] * n
	b = [0] * n
	c = [0] * n
	d = [0] * n
	for i in range(1, m + 1):
		w += 1
		if w > 2 * n:
			e = 1
		if w % 2 == 1 and e == 0:
			a[a.index(0)] = i
		elif w % 2 == 0 and e == 0:
			d[d.index(0)] = i
		elif w % 2 == 1 and e == 1:
			b[b.index(0)] = i
		elif w % 2 == 0 and e == 1:
			c[c.index(0)] = i
	for i in range(n):
		if b[i] != 0:
			v.append(b[i])
		if a[i] != 0:
			v.append(a[i])
		if c[i] != 0:
			v.append(c[i])
		if d[i] != 0:
			v.append(d[i])
	return v
(n, m) = input().strip().split()
a = bus_seats(int(n), int(m))
print(' '.join((str(i) for i in a)))


tab = [int(i) for i in input().split()]
n = tab[0]
m = tab[1]
x = ''
if m == 4 * n:
	for i in range(n):
		x = x + str(2 * n + 1 + 2 * i) + ' ' + str(2 * i + 1) + ' ' + str(2 * n + 2 + 2 * i) + ' ' + str(2 * i + 2) + ' '
else:
	for i in range(n):
		if 2 * n + 2 * i + 1 <= m:
			x = x + str(2 * n + 2 * i + 1) + ' '
		if 2 * i + 1 <= m:
			x = x + str(2 * i + 1) + ' '
		if 2 * n + 2 * i + 2 <= m:
			x = x + str(2 * n + 2 * i + 2) + ' '
		if 2 * i + 2 <= m:
			x = x + str(2 * i + 2) + ' '
x = x[:-1]
print(x)


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
mod = 998244353
(n, m) = il()
a = [[0, 0, 0, 0] for i in range(n)]
i1 = 0
i2 = 0
fl = 0
for i in range(m):
	a[i1][i2] = i + 1
	if fl == 0:
		i2 += 3
		if i2 > 3:
			i2 = 0
			i1 += 1
		if i1 >= n:
			fl = 1
			i2 = 1
			i1 = 0
	else:
		i2 += 1
		if i2 > 2:
			i2 = 1
			i1 += 1
ans = []
for i in range(n):
	if a[i][1] != 0:
		ans.append(a[i][1])
	if a[i][0] != 0:
		ans.append(a[i][0])
	if a[i][2] != 0:
		ans.append(a[i][2])
	if a[i][3] != 0:
		ans.append(a[i][3])
print(*ans)


__metaclass__ = type
__author__ = 'xdlove'
(n, m) = map(int, input().split())
(L, R) = (1, 2 * n + 1)
res = list()
while L <= 2 * n:
	if R <= m:
		res.append(R)
	if L <= m:
		res.append(L)
	R += 1
	L += 1
print(' '.join([str(x) for x in res]))


(n, m) = [int(i) for i in input().split()]
a = [[0] * 4 for i in range(n)]
for i in range(m):
	if i < 2 * n:
		if i % 2 == 0:
			a[i // 2][0] = i + 1
		else:
			a[i // 2][1] = i + 1
	elif i % 2 == 0:
		a[(i - 2 * n) // 2][2] = i + 1
	else:
		a[(i - 2 * n) // 2][3] = i + 1
j = 0
while j < m:
	for i in range(n):
		if a[i][2] > 0:
			print(a[i][2], end=' ')
			j += 1
		if a[i][0] > 0:
			print(a[i][0], end=' ')
			j += 1
		if a[i][3] > 0:
			print(a[i][3], end=' ')
			j += 1
		if a[i][1] > 0:
			print(a[i][1], end=' ')
			j += 1


(n, m) = list(map(int, input().strip().split()))
re = []
if m <= 2 * n:
	for i in range(1, m + 1):
		re.append(i)
else:
	for i in range(1, 2 * n + 1):
		if m >= i + 2 * n:
			re.append(i + 2 * n)
			re.append(i)
		else:
			re.append(i)
print(' '.join(map(str, re)))


def main():
	from itertools import chain
	(n, m) = map(int, input().split())
	(b1, b2, b3, b4) = ([0] * m for _ in range(4))
	it = iter(range(1, m + 1))
	try:
		for i in range(n):
			b1[i] = next(it)
			b4[i] = next(it)
		for i in range(n):
			b2[i] = next(it)
			b3[i] = next(it)
	except StopIteration:
		pass
	print(' '.join(map(str, filter(None, chain.from_iterable(zip(b2, b1, b3, b4))))))
main()


from collections import Counter
(n, k) = list(map(lambda x: int(x), input().split()))
result = []
window = 1
non_window = 2 * n + 1
for row in range(1, n + 1):
	temp = []
	temp.append(non_window)
	temp.append(window)
	temp.append(non_window + 1)
	temp.append(window + 1)
	window += 2
	non_window += 2
	for elem in temp:
		if elem > k:
			continue
		result.append(elem)
result = list(map(lambda x: str(x), result))
print(' '.join(result))


(n, m) = map(int, input().split())
ans = []
if m == 1:
	print(1)
if (m <= n or m <= 2 * n) and m != 1:
	for i in range(1, m + 1):
		if i <= m:
			ans.append(i)
		else:
			break
if m > 2 * n:
	for i in range(1, 2 * n + 1):
		if 2 * n + i <= m:
			ans.append(2 * n + i)
		if i <= m:
			ans.append(i)
print(*ans, end=' ')


(n, m) = map(int, input().split())
c2 = 2 * n + 1
c1 = 1
for i in range(n * 2):
	if c2 <= m:
		print(c2, end=' ')
		c2 += 1
	if c1 <= m:
		print(c1, end=' ')
		c1 += 1
print('')


(n, m) = map(int, input().split())
a = [[] for i in range(4)]
for i in range(1, m + 1):
	if i <= n + n:
		if i % 2:
			a[0].append(i)
		else:
			a[3].append(i)
	elif (i - n - n) % 2:
		a[1].append(i)
	else:
		a[2].append(i)
for i in range(n):
	if i < len(a[1]):
		print(a[1][i], end=' ')
	if i < len(a[0]):
		print(a[0][i], end=' ')
	if i < len(a[2]):
		print(a[2][i], end=' ')
	if i < len(a[3]):
		print(a[3][i], end=' ')


(n, m) = list(map(int, input().split(' ')))
m_c = m
matrix = [[0 for x in range(4)] for x in range(n)]

def fillM(matrix, left):
	right = 3 - left
	row = 0
	count = 0
	global m_c
	global m
	global n
	while m_c > 0 and row < n:
		matrix[row][left] = m - m_c + 1
		m_c = m_c - 1
		if m_c <= 0:
			return 0
		matrix[row][right] = m - m_c + 1
		m_c = m_c - 1
		row += 1
fillM(matrix, 0)
fillM(matrix, 1)
arr3 = []
for row in range(n):
	if not matrix[row][1] == 0:
		arr3.append(str(matrix[row][1]))
	if not matrix[row][0] == 0:
		arr3.append(str(matrix[row][0]))
	if not matrix[row][2] == 0:
		arr3.append(str(matrix[row][2]))
	if not matrix[row][3] == 0:
		arr3.append(str(matrix[row][3]))
print(' '.join(arr3))


OUT = (1, 0, 2, 3)
try:
	while True:
		(n, m) = map(int, input().split())
		bus = [[None] * 4 for i in range(n)]
		cur = 1
		for row in range(n << 1):
			if row >= n:
				i = row - n
				k = b = 1
			else:
				i = row
				k = 3
				b = 0
			for j in range(2):
				if cur <= m:
					bus[i][k * j + b] = cur
					cur += 1
		for i in range(n):
			for j in range(4):
				if bus[i][OUT[j]] is not None:
					print(bus[i][OUT[j]], end=' ')
		print()
except EOFError:
	pass


(n, m) = map(int, input().rstrip().split(' '))
if 2 * n > m:
	l1 = m
	l2 = 0
elif m < 4 * n:
	l1 = 2 * n
	l2 = m
else:
	l1 = 2 * n
	l2 = 4 * n
r1 = [i for i in range(1, l1 + 1, 2)]
r2 = [i for i in range(2, l1 + 1, 2)]
r3 = [i for i in range(n * 2 + 1, l2 + 1, 2)]
r4 = [i for i in range(n * 2 + 2, l2 + 1, 2)]
lens = max([len(r1), len(r2), len(r3), len(r4)])
for i in range(lens):
	if i < len(r3):
		print(r3[i], end=' ')
	if i < len(r1):
		print(r1[i], end=' ')
	if i < len(r4):
		print(r4[i], end=' ')
	if i < len(r2):
		print(r2[i], end=' ')


import math
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
(n, m) = M()
(lw, rw, l, r) = ([], [], [], [])
for i in range(1, 2 * n + 1):
	if i > m:
		break
	if i % 2 != 0:
		lw.append(i)
	else:
		rw.append(i)
for i in range(2 * n + 1, m + 1):
	if i % 2 != 0:
		l.append(i)
	else:
		r.append(i)
i = 0
x = []
while i <= m + 1:
	if len(l) > i:
		x.append(l[i])
	if len(lw) > i:
		x.append(lw[i])
	if len(r) > i:
		x.append(r[i])
	if len(rw) > i:
		x.append(rw[i])
	i += 1
print(*x)


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime
(n, m) = map(int, input().split())
seat = 2 * n
ans = []
for i in range(1, seat + 1):
	if i + seat <= m:
		ans.append(i + seat)
	if i <= m:
		ans.append(i)
print(*ans)


from collections import deque, defaultdict, Counter
from itertools import product, groupby, permutations, combinations
from math import gcd, floor, inf, log2, sqrt, log10
from bisect import bisect_right, bisect_left
from statistics import mode
from string import ascii_uppercase
(n, m) = map(int, input().split())
if 2 * n >= m:
	print(*[i for i in range(1, m + 1)])
else:
	seats = [i for i in range(1, 2 * n + 1)]
	remained = [i for i in range(2 * n + 1, m + 1)][::-1]
	ans = []
	for (i, number) in enumerate(seats):
		if remained:
			ans.append(remained.pop())
		ans.append(number)
	print(*ans)


import math
(n, m) = [int(i) for i in input().split()]
l = [i + 1 for i in range(m)]
l.sort(key=lambda x: ((x - 1) % (2 * n) // 2, 1 - x % 2, int(x < 2 * n + 1)))
print(' '.join([str(i) for i in l]))


(n, m) = map(int, input().split())
A = [[0] * 4 for i in range(n + 1)]
now = 1
for i in range(1, n + 1):
	if now <= m:
		A[i][0] = now
		now += 1
	if now <= m:
		A[i][3] = now
		now += 1
for i in range(1, n + 1):
	if now <= m:
		A[i][1] = now
		now += 1
	if now <= m:
		A[i][2] = now
		now += 1
for i in range(1, n + 1):
	if A[i][1]:
		print(A[i][1], end=' ')
	if A[i][0]:
		print(A[i][0], end=' ')
	if A[i][2]:
		print(A[i][2], end=' ')
	if A[i][3]:
		print(A[i][3], end=' ')


(n, m) = map(int, input().split())
order_enter = []
order_exit = []
for i in range(n):
	order_enter.append((i, 0))
	order_enter.append((i, 3))
for i in range(n):
	order_enter.append((i, 1))
	order_enter.append((i, 2))
for i in range(n):
	order_exit.append((i, 1))
	order_exit.append((i, 0))
	order_exit.append((i, 2))
	order_exit.append((i, 3))
bus = [[-1, -1, -1, -1] for _ in range(n)]
for (i, (x, y)) in enumerate(order_enter):
	if i == m:
		break
	bus[x][y] = i
for (x, y) in order_exit:
	if bus[x][y] != -1:
		print(bus[x][y] + 1, end=' ')


(n, m) = map(int, input().split())
import math
res = []
mx = n if m >= 2 * n - 1 else math.ceil(m / 2)
for i in range(mx):
	k = 2 * i + 1
	l = 2 * n + k
	if l <= m:
		res.append(l)
	res.append(k)
	if l + 1 <= m:
		res.append(l + 1)
	if k + 1 <= m:
		res.append(k + 1)
print(*res)


from functools import cmp_to_key
from collections import deque, Counter
from heapq import heappush, heappop
from math import log, ceil
import sys
import os
from io import BytesIO, IOBase
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')
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def ii():
	return int(inp())

def si():
	return str(inp())

def li(lag=0):
	l = list(map(int, inp().split()))
	if lag != 0:
		for i in range(len(l)):
			l[i] += lag
	return l

def mi(lag=0):
	matrix = list()
	for i in range(n):
		matrix.append(li(lag))
	return matrix

def lsi():
	return list(map(str, inp().split()))

def print_list(lista, space=' '):
	print(space.join(map(str, lista)))

def bisect_left(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] < x:
			left = mid + 1
		else:
			right = mid
	return left

def bisect_right(a, x):
	left = 0
	right = len(a)
	while left < right:
		mid = (left + right) // 2
		if a[mid] > x:
			right = mid
		else:
			left = mid + 1
	return left

def bisect_elements(a, x):
	return bisect_right(a, x) - bisect_left(a, x)
MOD = 10 ** 9 + 7
maxN = 5
FACT = [0] * maxN
INV_FACT = [0] * maxN

def add(x, y):
	return (x + y) % MOD

def multiply(x, y):
	return x * y % MOD

def power(x, y):
	if y == 0:
		return 1
	elif y % 2:
		return multiply(x, power(x, y - 1))
	else:
		a = power(x, y // 2)
		return multiply(a, a)

def inverse(x):
	return power(x, MOD - 2)

def divide(x, y):
	return multiply(x, inverse(y))

def allFactorials():
	FACT[0] = 1
	for i in range(1, maxN):
		FACT[i] = multiply(i, FACT[i - 1])

def inverseFactorials():
	n = len(INV_FACT)
	INV_FACT[n - 1] = inverse(FACT[n - 1])
	for i in range(n - 2, -1, -1):
		INV_FACT[i] = multiply(INV_FACT[i + 1], i + 1)

def coeffBinom(n, k):
	if n < k:
		return 0
	return multiply(FACT[n], multiply(INV_FACT[k], INV_FACT[n - k]))

def create_graph(n, m, undirected=1, unweighted=1):
	graph = [[] for i in range(n)]
	if unweighted:
		for i in range(m):
			[x, y] = li(lag=-1)
			graph[x].append(y)
			if undirected:
				graph[y].append(x)
	else:
		for i in range(m):
			[x, y, w] = li(lag=-1)
			w += 1
			graph[x].append([y, w])
			if undirected:
				graph[y].append([x, w])
	return graph

def create_tree(n, unweighted=1):
	children = [[] for i in range(n)]
	if unweighted:
		for i in range(n - 1):
			[x, y] = li(lag=-1)
			children[x].append(y)
			children[y].append(x)
	else:
		for i in range(n - 1):
			[x, y, w] = li(lag=-1)
			w += 1
			children[x].append([y, w])
			children[y].append([x, w])
	return children

def dist(tree, n, A, B=-1):
	s = [[A, 0]]
	(massimo, massimo_nodo) = (0, 0)
	distanza = -1
	v = [-1] * n
	while s:
		(el, dis) = s.pop()
		if dis > massimo:
			massimo = dis
			massimo_nodo = el
		if el == B:
			distanza = dis
		for child in tree[el]:
			if v[child] == -1:
				v[child] = 1
				s.append([child, dis + 1])
	return (massimo, massimo_nodo, distanza)

def diameter(tree):
	(_, foglia, _) = dist(tree, n, 0)
	(diam, _, _) = dist(tree, n, foglia)
	return diam

def dfs(graph, n, A):
	v = [-1] * n
	s = [[A, 0]]
	v[A] = 0
	while s:
		(el, dis) = s.pop()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def bfs(graph, n, A):
	v = [-1] * n
	s = deque()
	s.append([A, 0])
	v[A] = 0
	while s:
		(el, dis) = s.popleft()
		for child in graph[el]:
			if v[child] == -1:
				v[child] = dis + 1
				s.append([child, dis + 1])
	return v

def parents_children_root_unrooted_tree(tree, n, root=0):
	q = deque()
	visited = [0] * n
	parent = [-1] * n
	children = [[] for i in range(n)]
	q.append(root)
	while q:
		all_done = 1
		visited[q[0]] = 1
		for child in tree[q[0]]:
			if not visited[child]:
				all_done = 0
				q.appendleft(child)
		if all_done:
			for child in tree[q[0]]:
				if parent[child] == -1:
					parent[q[0]] = child
					children[child].append(q[0])
			q.popleft()
	return (parent, children)

def all_longest_path_passing_from_node(parent, children, n):
	q = deque()
	visited = [len(children[i]) for i in range(n)]
	downwards = [[0, 0] for i in range(n)]
	upward = [1] * n
	longest_path = [1] * n
	for i in range(n):
		if not visited[i]:
			q.append(i)
			downwards[i] = [1, 0]
	while q:
		node = q.popleft()
		if parent[node] != -1:
			visited[parent[node]] -= 1
			if not visited[parent[node]]:
				q.append(parent[node])
		else:
			root = node
		for child in children[node]:
			downwards[node] = sorted([downwards[node][0], downwards[node][1], downwards[child][0] + 1], reverse=True)[0:2]
	s = [node]
	while s:
		node = s.pop()
		if parent[node] != -1:
			if downwards[parent[node]][0] == downwards[node][0] + 1:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][1])
			else:
				upward[node] = 1 + max(upward[parent[node]], downwards[parent[node]][0])
		longest_path[node] = downwards[node][0] + downwards[node][1] + upward[node] - min([downwards[node][0], downwards[node][1], upward[node]]) - 1
		for child in children[node]:
			s.append(child)
	return longest_path
(n, m) = li()
seats = [[-1, -1, -1, -1] for i in range(n)]
for i in range(1, m + 1):
	if i <= 2 * n:
		if i % 2 == 1:
			seats[(i - 1) // 2][0] = i
		else:
			seats[(i - 1) // 2][3] = i
	elif i % 2 == 1:
		seats[(i - 1 - 2 * n) // 2][1] = i
	else:
		seats[(i - 1 - 2 * n) // 2][2] = i
res = list()
for i in range(n):
	(lw, lc, rc, rw) = seats[i]
	if lc != -1:
		res.append(lc)
	if lw != -1:
		res.append(lw)
	if rc != -1:
		res.append(rc)
	if rw != -1:
		res.append(rw)
print_list(res)


(n, m) = map(int, input().split())
A = [list(range(1, 2 * n + 1, 2)), list(range(2 * n + 1, 4 * n + 1, 2)), list(range(2 * n + 2, 4 * n + 1, 2)), list(range(2, 2 * n + 1, 2))]
B = [list(range(2, 4 * n + 1, 4)), list(range(1, 4 * n + 1, 4)), list(range(3, 4 * n + 1, 4)), list(range(4, 4 * n + 1, 4))]
C = []
for i in range(4):
	for j in range(n):
		if A[i][j] <= m:
			C += [(B[i][j], A[i][j])]
C.sort()
print(' '.join(map(str, [i for (x, i) in C])))


(lines, ppl) = list(map(int, input().split()))
bus = [[2 * i - 1, 2 * lines + 2 * i - 1, 2 * lines + 2 * i, 2 * i] for i in range(1, lines + 1)]
for line in bus:
	(line[1], line[0]) = (line[0], line[1])
exit_seq = [man for line in bus for man in line if man <= ppl]
for _ in exit_seq[:len(exit_seq) - 1]:
	print(_, end=' ')
print(exit_seq[-1])


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