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: interview

Starter code:

Solutions:
#!/usr/bin/env python3

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().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)
    else:
        if 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()


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
    else:
        if 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

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 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]))
        
        
        


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=[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)))

n, m = list(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
    else:
        if 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=' ')

#parse_int = list(map(int, input().split()))

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: print(line)

#for line in bus: exit_bus.append([ line[1], line[0], line[2], line[3] ])
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])

def __starting_point():
    n, m = list(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))
    

__starting_point()

import sys
import math
import itertools as it
import operator as op
import fractions as fr


n,m = list(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)))


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 = ' ')

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)
    else:
        if 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())
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)
        


'__author__'=='deepak Singh Mehta) learning to code '





def __starting_point():
    n,m = map(int,input().split())
    assert(m>=1 and m<=(4*n))
    if m%2!=0: #odd
        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: #even
        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=' ')

__starting_point()

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
    nonlocal m_c
    nonlocal m
    nonlocal n

    while m_c > 0 and row<n:
        #print(row, left)
        matrix[row][left] = m - m_c + 1
        m_c = m_c - 1

        if m_c <= 0:
            return 0

        #print(row, right)
        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]))

#import numpy as np
#print(np.array(matrix))

print(' '.join(arr3))


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)


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=[[0]*4 for i in range(n)]
for i in range(n):
  if i*2+1<=m: a[i][0]=i*2+1
  if i*2+1+2*n<=m: a[i][1]=i*2+1+2*n
  if i*2+2+n*2<=m: a[i][2]=i*2+2+2*n
  if i*2+2<=m: a[i][3]=i*2+2
for i in range(n):
  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 = list(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 = []
#print(flags)
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(i, mass)
print(' '.join(map(str, mass)))


n,m=[int(c) for c in  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=' ')



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=' ')

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))


n,m=list(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)
    else:
        if 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])