Hiking club "Up the hill" just returned from a walk. Now they are trying to remember which hills they've just walked through.

It is known that there were N stops, all on different integer heights between 1 and N kilometers (inclusive) above the sea level. On the first day they've traveled from the first stop to the second stop, on the second day they've traveled from the second to the third and so on, and on the last day they've traveled from the stop N - 1 to the stop N and successfully finished their expedition.

They are trying to find out which heights were their stops located at. They have an entry in a travel journal specifying how many days did they travel up the hill, and how many days did they walk down the hill.

Help them by suggesting some possible stop heights satisfying numbers from the travel journal.


-----Input-----

In the first line there is an integer non-negative number A denoting the number of days of climbing up the hill. Second line contains an integer non-negative number B — the number of days of walking down the hill (A + B + 1 = N, 1 ≤ N ≤ 100 000).


-----Output-----

Output N space-separated distinct integers from 1 to N inclusive, denoting possible heights of the stops in order of visiting.


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

Output
2 1 

Input
2
1
Output
1 3 4 2

Difficulty: EASY
Tags: Implementation

Constructive algorithms

Starter code:

Solutions:
from sys import stdout, stdin
import math
r = lambda : int(input())
ra = lambda : [*map(int, input().split())]
raw = lambda : [*stdin.readline()]
out = lambda a: stdout.write(''.join(a))
a = r()
b = r()
n = a + b + 1
p = [str(i + 1) + ' ' for i in range(1, n)]
res = []
if (a or b) == 0:
	out('1')
else:
	if a == 0:
		res = p[0:b][::-1] + ['1']
	elif b == 0:
		res = ['1 '] + p[0:n]
	else:
		res = p[n - a - 2:n] + p[0:n - a - 2][::-1] + ['1']
	out(res)


A = int(input())
B = int(input())
N = A + B + 1
print(*[x + 1 if x < A else N + A - x for x in range(N)])


up = int(input())
down = int(input())
maxim = up + down + 1
res = []
if up > down:
	res.append(1)
	curr = maxim - up + 1
	downCurr = curr - 1
	while curr <= maxim:
		res.append(curr)
		curr += 1
	while downCurr > 1:
		res.append(downCurr)
		downCurr -= 1
else:
	res.append(maxim)
	curr = maxim - up - 1
	upCurr = curr + 1
	while curr >= 1:
		res.append(curr)
		curr -= 1
	while upCurr < maxim:
		res.append(upCurr)
		upCurr += 1
print(*res)


n = int(input())
m = int(input())
a = [0] * (m + n + 1)
a[len(a) - m - 1] = m + n + 1
for i in range(n):
	a[i] = i + 1
for j in range(len(a) - m, m + n + 1):
	a[j] = len(a) + n - j
print(*a, sep=' ')


n = int(input())
m = int(input())
s = [str(i) for i in range(n + m + 2 - (n + 1), n + m + 2)]
s1 = [str(i) for i in range(n + m + 2 - (n + 1) - 1, 0, -1)]
s.extend(s1)
print(' '.join(s))


a = int(input())
b = int(input())
n = a + b + 1
if b is 0:
	for i in range(n):
		print(i + 1, end=' ')
elif a is 0:
	for i in range(n):
		print(n - i, end=' ')
else:
	i = 1
	print(i, end=' ')
	i = i + b + 1
	while i <= n:
		print(i, end=' ')
		i = i + 1
	(ct, i) = (1, 1 + b)
	while ct <= b:
		print(i, end=' ')
		i = i - 1
		ct = ct + 1


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x) + '\n')
n = get_int()
m = get_int()
lst = list(range(1, n + m + 2))
print(' '.join(map(str, lst[-n - 1:])) + ' ' + ' '.join(map(str, reversed(lst[:m]))))


h = int(input())
d = int(input())
t = h + d + 1
if h:
	print(1, end=' ')
	for i in range(h - 1, -1, -1):
		print(t - i, end=' ')
	for j in range(d, 0, -1):
		print(1 + j, end=' ')
else:
	for j in range(d, -1, -1):
		print(1 + j, end=' ')


a = int(input())
b = int(input())
n = a + b + 1
if a > 0:
	print(1, end=' ')
for i in range(n - a + 1, n + 1):
	print(i, end=' ')
i = n - a
while i > 1:
	print(i, end=' ')
	i -= 1
if a == 0:
	print(1)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
uh = ii()
dh = ii()
n = uh + dh + 1
for i in range(uh):
	print(i + 1, end=' ')
print(n, end=' ')
for i in range(n - 1, n - 1 - dh, -1):
	print(i, end=' ')


a = int(input())
b = int(input())
print(b + 1, end=' ')
x = b
for i in range(b):
	print(x, end=' ')
	x -= 1
x = b + 2
for i in range(a):
	print(x, end=' ')
	x += 1


u = int(input())
d = int(input())
a = [0 for i in range(u + d + 1)]
for i in range(u):
	a[i] = i + 1
a[u] = d + u + 1
for i in range(u + 1, d + u + 1):
	a[i] = a[i - 1] - 1
print(*a)


a = int(input())
b = int(input())
for i in range(a):
	print(i + 1, end=' ')
print(a + b + 1, end=' ')
for j in range(b):
	print(a + b - j, end=' ')


A = int(input())
B = int(input())
N = A + B + 1
i = 0
c = [0] * N
while i < A:
	c[i] = str(i + 1)
	i += 1
c[i] = str(N)
i += 1
while i < N:
	c[i] = str(N - i + A)
	i += 1
print(' '.join(c))


import sys
import os
a = int(input())
b = int(input())
v = [i + 1 for i in range(a + b + 1)]
for i in v[:a] + v[a:][::-1]:
	print(i, end=' ')
print()


a = int(input())
b = int(input())
c = ''
if a != 0:
	for x in range(1, a + 2):
		c += str(b + x) + ' '
else:
	c += str(b + 1) + ' '
if b != 0:
	for x in range(1, b + 1):
		c += str(b + 1 - x) + ' '
print(c.strip())


a = int(input())
b = int(input())
l = list(range(1, a + b + 2))
if a == 0:
	print(*l[::-1])
else:
	p = l[1:1 + b]
	del l[1:1 + b]
	print(*l + p[::-1])


(A, B) = (int(input()), int(input()))
print(*range(B + 1, A + B + 2), *reversed(range(1, B + 1)))


(a, b) = (int(input()), int(input()))
print(*[*range(b + 1, a + b + 2), *range(b, 0, -1)])


a = int(input())
b = int(input())
l = list(range(b + 1, 0, -1))
if a == 0:
	for i in l:
		print(i, end=' ')
else:
	q = list(range(b + 2, a + b + 2))
	print(1, end=' ')
	for i in q:
		print(i, end=' ')
	for i in l[:-1]:
		print(i, end=' ')


n = int(input())
m = int(input())
for i in range(m + 1, m + n + 2):
	print(i, end=' ')
for i in range(m, 0, -1):
	print(i, end=' ')


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
up = int(input())
down = int(input())
total = up + down + 1
arr = [i for i in range(1, total + 1)][::-1]
beg = arr[:up + 1][::-1]
end = arr[up + 1:]
ans = beg + end
print(*ans)


a = int(input())
b = int(input())
n = a + b + 1
ans = [i for i in range(1, n + 1)]
if b % 2 == 1:
	ans[n // 2 - 1] = ans[n // 2 - 1] + ans[n // 2]
	ans[n // 2] = ans[n // 2 - 1] - ans[n // 2]
	ans[n // 2 - 1] = ans[n // 2 - 1] - ans[n // 2]
	b -= 1
left = 0
right = n - 1
while b > 0:
	ans[left] = ans[left] + ans[right]
	ans[right] = ans[left] - ans[right]
	ans[left] = ans[left] - ans[right]
	left += 1
	right -= 1
	b -= 2
for i in range(n - 1):
	print(ans[i], end=' ')
print(ans[n - 1])


a = int(input())
b = int(input())
n = a + b + 1
print(' '.join(map(str, list(range(n - a, n + 1)) + list(range(1, n - a))[::-1])))


def mountain(a, b):
	z = list()
	for i in range(1, a + 1):
		z.append(i)
	for i in range(a + b + 1, a, -1):
		z.append(i)
	return z
A = int(input())
B = int(input())
print(*mountain(A, B))


a = int(input())
b = int(input())
n = b + 1
ans = str(n) + ' '
for i in range(a):
	n += 1
	ans += str(n) + ' '
n = b + 1
for i in range(b):
	n -= 1
	ans += str(n) + ' '
print(ans)


a = int(input())
b = int(input())
n = a + b + 1
if a == 0 and b > 0:
	while n > 0:
		print(n, end=' ')
		n -= 1
elif a > 0 and b == 0:
	i = 1
	while i <= n:
		print(i, end=' ')
		i += 1
else:
	i = b + 2
	print(1, end=' ')
	while a > 0:
		print(i, end=' ')
		i += 1
		a -= 1
	i = b + 1
	while b > 0:
		print(i, end=' ')
		i -= 1
		b -= 1


a = int(input())
b = int(input())
n = a + b + 1
L = list(range(n - a, n + 1))
for item in L:
	print(item, end=' ')
x = n - a - 1
while x > 0:
	print(x, end=' ')
	x -= 1


a = int(input())
b = int(input())
tot = a + b + 1
x = b + 1
s = ''
for i in range(x, tot + 1):
	s += str(i)
	s += ' '
for I in range(b, 0, -1):
	s += str(I)
	s += ' '
print(s)


a = int(input())
b = int(input())
n = a + b + 1
for i in range(n):
	if i < a:
		print(i + 1, end=' ')
	else:
		print(n + a - i, end=' ')


a = int(input())
b = int(input())
arr1 = [i for i in range(b + 1, a + b + 2)]
arr2 = [j + 1 for j in reversed(range(b))]
arr = arr1 + arr2
print(' '.join(map(str, arr)))


U = int(input())
D = int(input())
last = max(1, 1 + D)
next = last
print(last, end=' ')
while U > 0:
	last += 1
	print(last, end=' ')
	U -= 1
while D > 0:
	next -= 1
	print(next, end=' ')
	D -= 1


a = int(input())
b = int(input())
n = [str(i) for i in range(1, a + b + 2)]
if a == 0:
	print(' '.join(n[::-1]))
elif b == 0:
	print(' '.join(n))
else:
	print(' '.join(n[-a - 1:]) + ' ' + ' '.join(n[:b][::-1]))


import sys
A = int(sys.stdin.readline().strip())
B = int(sys.stdin.readline().strip())
N = A + B + 1
ans = [str(i) for i in range(B + 1, N + 1)] + [str(B - i) for i in range(0, B)]
print(' '.join(ans))


a = int(input())
b = int(input())
ans = [i for i in range(1, a + b + 2)]
i = 0
while i < b:
	i += 1
up = ans[i:]
down = ans[:i]
down.reverse()
print(*up + down)


up = int(input())
down = int(input())
if up > down:
	daf = list(range(1, up + down + 2))
	if down == 0:
		print(*daf)
	else:
		for i in range(down):
			(daf[2 * i], daf[2 * i + 1]) = (daf[2 * i + 1], daf[2 * i])
		print(*daf)
else:
	daf = list(range(up + down + 1, 0, -1))
	if down == 0:
		print(*daf)
	else:
		for i in range(up):
			(daf[2 * i], daf[2 * i + 1]) = (daf[2 * i + 1], daf[2 * i])
		print(*daf)


a = int(input())
b = int(input())
n = a + b + 1
res = [x + 1 for x in range(n - a - 1, n)] + [x for x in range(n - a - 1, 0, -1)]
print(*res)


a = int(input())
b = int(input())
res = list(range(b + 1, 0, -1))
res.extend(list(range(b + 2, a + b + 2)))
print(' '.join(map(str, res)))


a = int(input())
b = int(input())
n = a + b + 1
t = []
for k in range(1, n + 1):
	t.append(k)
print(*t[:a] + t[a:][::-1])