A modified Kaprekar number is a positive whole number with a special property.  If you square it, then split the number into two integers and sum those integers, you have the same value you started with.

Consider a positive whole number $n$ with $\boldsymbol{d}$ digits.  We square $n$ to arrive at a number that is either $2\times d$ digits long or $(2\times d)-1$ digits long.  Split the string representation of the square into two parts, $\boldsymbol{l}$ and $\textbf{r}$.  The right hand part, $\textbf{r}$ must be $\boldsymbol{d}$ digits long.  The left is the remaining substring.  Convert those two substrings back to integers, add them and see if you get $n$.

Example  

$n=5$ 

$\boldsymbol{d}=1$  

First calculate that $n^2=25$. Split that into two strings and convert them back to integers $2$ and $5$.  Test $2+5=7\neq5$, so this is not a modified Kaprekar number.  If $n=9$, still $\boldsymbol{d}=1$, and $n^2=81$.  This gives us $1+8=9$, the original $n$. 

Note: r may have leading zeros.  

Here's an explanation from Wikipedia about the ORIGINAL Kaprekar Number (spot the difference!):  

In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For instance, 45 is a Kaprekar number, because 45² = 2025 and 20+25 = 45.

Given two positive integers $\boldsymbol{p}$ and $\textit{q}$ where $\boldsymbol{p}$ is lower than $\textit{q}$, write a program to print the modified Kaprekar numbers in the range between $\boldsymbol{p}$ and $\textit{q}$, inclusive.  If no modified Kaprekar numbers exist in the given range, print INVALID RANGE.  

Function Description  

Complete the kaprekarNumbers function in the editor below.  

kaprekarNumbers has the following parameter(s):  

int p: the lower limit     
int q: the upper limit   

Prints  

It should print the list of modified Kaprekar numbers, space-separated on one line and in ascending order.  If no modified Kaprekar numbers exist in the given range, print INVALID RANGE.  No return value is required.  

Input Format

The first line contains the lower integer limit $\boldsymbol{p}$. 

The second line contains the upper integer limit $\textit{q}$.  

Note: Your range should be inclusive of the limits.

Constraints

$0<p<q<100000$ 

Sample Input
STDIN   Function
-----   --------
1       p = 1
100     q = 100

Sample Output

1 9 45 55 99  

Explanation

$\mbox{1}$, $\mbox{9}$, $45$, $55$, and $\mbox{99}$ are the modified Kaprekar Numbers in the given range.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
low = input()
hi = input()

def is_kaprekar_number(num):
	square = str(num * num)
	mid = len(square) // 2
	num1 = 0
	try:
		num1 = int(square[0:mid])
	except:
		pass
	num2 = 0
	try:
		num2 = int(square[mid:])
	except:
		pass
	if num1 + num2 == num:
		return True
	return False
found = False
for i in range(int(low), int(hi) + 1):
	if is_kaprekar_number(i):
		found = True
		print(i, end=' ')
if found == False:
	print('INVALID RANGE')


def is_kaprekar_number(n):
	digits = list(str(n ** 2))
	left = ''.join(digits[:len(digits) // 2])
	right = int(''.join(digits[len(digits) // 2:]))
	if len(left) == 0:
		left = 0
	else:
		left = int(left)
	return n == left + right
low = int(input())
high = int(input())
kaperkar_numbers = []
for i in range(low, high + 1):
	if is_kaprekar_number(i):
		kaperkar_numbers.append(i)
if len(kaperkar_numbers) == 0:
	print('INVALID RANGE')
else:
	out_str = ''
	for num in kaperkar_numbers:
		out_str += str(num) + ' '
	print(out_str)


p = int(input())
q = int(input())
result = []
for i in range(p, q + 1, 1):
	k = i ** 2
	r = k % 10 ** len(str(i))
	l = k // 10 ** len(str(i))
	if i == int(r) + int(l):
		result.append(i)
result = list(set(result))
result.sort()
if len(result) == 0:
	print('INVALID RANGE')
else:
	print(' '.join([str(i) for i in result]))


nums = [1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4950, 5050, 7272, 7777, 9999, 17344, 22222, 77778, 82656, 95121, 99999, 142857, 148149, 181819, 187110, 208495, 318682, 329967, 351352, 356643, 390313, 461539, 466830, 499500, 500500, 533170]
p = int(input())
q = int(input())
x = [str(x) for x in nums if p <= x <= q]
if len(x) == 0:
	print('INVALID RANGE')
else:
	print(' '.join((str(x) for x in nums if p <= x <= q)))


def k(n):
	l = len(str(n))
	n2 = str(n ** 2)
	a = n2[-l:]
	b = n2.replace(a, '') or 0
	if int(a) + int(b) == n:
		return n
n = int(input())
m = int(input()) + 1
ans = ' '.join([str(x) for x in range(n, m) if k(x)])
if len(ans) > 0:
	print(ans)
else:
	print('INVALID RANGE')


def isKaprekar(n):
	numstr = str(n * n)
	rLength = int(len(numstr))
	if numstr[:rLength // 2] != '':
		a = int(numstr[:rLength // 2])
	else:
		a = 0
	if numstr[rLength // 2:] != '':
		b = int(numstr[rLength // 2:])
	else:
		b = 0
	result = int(int(a) + int(b))
	return n == result
p = int(input())
q = int(input())
count = 0
for i in range(p, q + 1):
	if isKaprekar(i):
		print(i, end=' ')
		count = 1
if count == 0:
	print('INVALID RANGE')


from bisect import *
kap = [1, 9]
for i in range(10, 100000):
	j = str(i * i)
	lj = len(j)
	d = len(str(i))
	if int(j[:d - 1 if lj & 1 else d]) + int(j[-d:]) == i:
		kap.append(i)
lst = kap[bisect_left(kap, int(input())):bisect(kap, int(input()))]
print(' '.join([str(x) for x in lst]) if len(lst) else 'INVALID RANGE')


p = int(input())
q = int(input())
invalid = 1
for i in range(p, q + 1):
	s = str(i * i)
	tmp = str(i)
	d = len(tmp)
	l = 0
	if len(s[0:len(s) - d]) > 0:
		l = int(s[0:len(s) - d])
	r = 0
	if len(s[len(s) - d:len(s)]) > 0:
		r = int(s[len(s) - d:len(s)])
		if r <= 0:
			continue
	if l + r == i:
		invalid = 0
		print(i, end=' ')
		continue
if invalid == 1:
	print('INVALID RANGE')


def isKaprekarNumber(n):
	if 1 <= n < 4:
		if n == 1:
			return True
		else:
			return False
	else:
		m = n * n
		m = str(m)
		splitLen = len(m) // 2
		right = m[splitLen:]
		left = m[:splitLen]
		left = int(left)
		right = int(right)
	return left + right == n
p = input()
q = input()
p = int(p)
q = int(q)
kaprekar = []
for i in range(p, q + 1):
	if isKaprekarNumber(i):
		kaprekar.append(i)
if len(kaprekar) == 0 or kaprekar == []:
	print('INVALID RANGE')
else:
	for i in range(len(kaprekar)):
		print(kaprekar[i], end=' ')


import math
low = int(input())
high = int(input())
count = 0
for i in range(low, high + 1):
	square = i ** 2
	sq = str(square)
	digits = len(sq)
	half = int(math.floor(digits / 2))
	if digits == 1:
		if int(sq[0]) == i:
			count += 1
			print(i, end=' ')
	else:
		right = ''
		for j in range(0, half):
			right += sq[j]
		left = ''
		for j in range(half, digits):
			left += sq[j]
		sumf = int(right) + int(left)
		if sumf == i:
			count += 1
			print(i, end=' ')
if count == 0:
	print('INVALID RANGE')


first = int(input(''))
second = int(input(''))
ans = 0
nn = ''
for g in range(first, second + 1):
	m = g * g
	ll = str(m)
	r = ''
	rr = ''
	t = len(str(g * g)) - len(str(g))
	for y in range(t):
		r += ll[y]
	for y in range(t, len(ll)):
		rr += ll[y]
	if len(r) == 0:
		r = '0'
	if int(r) + int(rr) == g:
		nn += str(g) + ' '
if nn == '':
	print('INVALID RANGE')
else:
	print(nn)


def isKaprekar(num):
	numsq = str(num * num)
	lenNum = len(str(num))
	len1 = len(numsq) - lenNum
	num1 = numsq[len1:]
	num2 = numsq[0:len1]
	if num2 == '':
		num2 = '0'
	if int(num1) + int(num2) == num:
		return 1
	else:
		return 0
p = int(input())
q = int(input())
ans = ''
for num in range(p, q + 1):
	if isKaprekar(num):
		ans = ans + ' ' + str(num)
ans = ans.strip()
if ans == '':
	print('INVALID RANGE')
else:
	print(ans)


p = int(input())
q = int(input())

def findKaprekar(n):
	square = str(n * n)
	l = square[:int(len(square) / 2)]
	r = square[int(len(square) / 2):]
	if len(l) == 0:
		l = '0'
	if n == int(l) + int(r):
		return True
	else:
		return False
kaprekarNums = []
for i in range(p, q + 1):
	if findKaprekar(i) == True:
		kaprekarNums.append(i)
		if i < q:
			print(i, end=' ')
		else:
			print(i)
if len(kaprekarNums) == 0:
	print('INVALID RANGE')


t = [1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4950, 5050, 7272, 7777, 9999, 17344, 22222, 77778, 82656, 95121, 99999]
a = int(input())
b = int(input())
l = [i for i in t if a <= i <= b]
if len(l) == 0:
	print('INVALID RANGE')
else:
	print(' '.join([str(x) for x in l]))


def kaprekar(n):
	d = len(str(n))
	n_sqr = str(n * n)
	right = int(n_sqr[len(n_sqr) - d:])
	left = n_sqr[:len(n_sqr) - d]
	if left == '':
		left = 0
	left = int(left)
	return left + right == n
p = int(input())
q = int(input())
a = []
for i in range(p, q + 1):
	if kaprekar(i):
		a.append(i)
if len(a) == 0:
	print('INVALID RANGE')
else:
	print(' '.join((str(c) for c in a)))


p = int(input())
q = int(input())

def is_kaprekar(n):
	d = len(str(n))
	square = str(n ** 2)
	r = square[len(square) - d:]
	l = square[:len(square) - d]
	if len(r) == 0:
		r = 0
	if int(r) == 0:
		return False
	if len(l) == 0:
		l = 0
	if int(r) + int(l) == n:
		return True
	return False
printed = False
for i in range(p, q + 1):
	if is_kaprekar(i):
		printed = True
		print(i, end=' ')
if not printed:
	print('INVALID RANGE')


def isKaprekar(N):
	d = len(str(N))
	sq = str(N ** 2)
	left = 0 if len(sq) == 1 else int(sq[:-d])
	right = int(sq[-d:])
	return N == left + right
p = int(input())
q = int(input())
K = [N for N in range(p, q + 1) if isKaprekar(N)]
if K:
	print(' '.join(map(str, K)))
else:
	print('INVALID RANGE')


def main():
	p = int(input())
	q = int(input())
	Kaprekar(p, q)

def Kaprekar(p, q):
	l = []
	for i in range(p, q + 1):
		if isKapr(i):
			l.append(str(i))
	if not l:
		print('INVALID RANGE')
		return
	else:
		print(' '.join(l))

def isKapr(n):
	num = n
	sq = n ** 2
	square = sq
	d = 1
	while num > 0:
		d *= 10
		num = num // 10
		sq = sq // 10
	return square - d * sq + sq == n
main()


lower = int(input())
upper = int(input())
answers = []
for i in range(lower, upper + 1):
	square = str(i ** 2)
	d = len(str(i))
	if 1 <= i <= 9:
		if i == 1 or i == 9:
			answers.append(str(i))
	elif int(square[-d:]) + int(square[:-d]) == i:
		answers.append(str(i))
if not answers:
	print('INVALID RANGE')
else:
	for answer in answers:
		print(answer + ' ', end='')


import sys
p = int(sys.stdin.readline())
q = int(sys.stdin.readline())
Kaprekar_set = ()
for n in range(p, q + 1):
	d = len(str(n))
	n_squared = str(n * n)
	r = int(n_squared[-d:])
	if len(n_squared) - d == 0:
		l = 0
	else:
		l = int(n_squared[:len(n_squared) - d])
	if r + l == n:
		Kaprekar_set += (n,)
if Kaprekar_set:
	for n in Kaprekar_set:
		print(n, ' ', sep='', end='')
else:
	print('INVALID RANGE')


nums = [1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4950, 5050, 7272, 7777, 9999, 17344, 22222, 77778, 82656, 95121, 99999]
p = int(input())
q = int(input())
c = 0
for num in nums:
	if p <= num <= q:
		c += 1
		print(num, end=' ')
if c == 0:
	print('INVALID RANGE')


lower_bound = int(input())
upper_bound = int(input())
result = []
for i in range(lower_bound, upper_bound + 1):
	d = len(str(i))
	num = i
	num_sqr = num * num
	num_sqr_str = str(num_sqr)
	left_digits = len(num_sqr_str) - d
	left = 0
	if left_digits > 0:
		left = num_sqr_str[0:left_digits]
	right = 0
	if left_digits < len(num_sqr_str):
		right = num_sqr_str[left_digits:]
	if int(left) + int(right) == num:
		result.append(num)
if len(result) > 0:
	print(' '.join((str(k) for k in result)))
else:
	print('INVALID RANGE')


from sys import stdin
p = int(stdin.readline())
q = int(stdin.readline())

def isk(n):
	s = n ** 2
	d = len(str(n))
	ss = str(s)
	return int('0' + ss[:-d], 10) + int('0' + ss[-d:], 10) == n
s = False
for n in range(p, q + 1):
	if isk(n):
		print(n, end=' ')
		s = True
if not s:
	print('INVALID RANGE')


__author__ = 'Joel Krebs'
import sys

def main():
	lower = int(sys.stdin.readline())
	upper = int(sys.stdin.readline())
	numbers = kaprekar(lower, upper)
	if not numbers:
		sys.stdout.write('INVALID RANGE\n')
	else:
		sys.stdout.write(' '.join(numbers))
		sys.stdout.write('\n')

def kaprekar(lower, upper):
	result = []
	for value in range(lower, upper + 1):
		digits = len(str(value))
		square = str(value * value)
		if len(square) - digits == 0:
			left = 0
		else:
			left = int(square[:len(square) - digits])
		right = int(square[-digits:])
		if left + right == value:
			result.append(str(value))
	return result
main()


k_numbers = []
p = int(input())
q = int(input())
for i in range(p, q + 1):
	square = i ** 2
	split_by = int('1' + '0' * len(str(i)))
	if square // split_by + square % split_by == i:
		k_numbers.append(i)
if len(k_numbers) == 0:
	print('INVALID RANGE')
else:
	print(' '.join(map(str, k_numbers)))


import math

def isKaprekar(num):
	if num == 1:
		return True
	square = num ** 2
	squarestr = str(square)
	digits = len(squarestr)
	(r, l) = (squarestr[:int(math.floor(digits / 2.0))], squarestr[int(math.floor(digits / 2.0)):])
	if num < 4:
		r = 1
		l = 0
	return num == int(r) + int(l)
p = int(input())
q = int(input())
kaps = []
invalid = True
for i in range(p, q + 1):
	if isKaprekar(i):
		kaps.append(str(i))
		invalid = False
if invalid:
	print('INVALID RANGE')
else:
	print(' '.join(kaps))


__author__ = 'Mehul Agrawal'
p = int(input())
q = int(input())
flag = 0
for i in range(p, q + 1):
	sq = str(i ** 2)
	l = len(sq)
	if i == int(sq[l // 2:]) + int('0' + sq[:l // 2]):
		print(i, end=' ')
		flag = 1
if flag == 0:
	print('INVALID RANGE')


P = int(input())
Q = int(input())
flag = 0
for number in range(P, Q + 1):
	square = number ** 2
	Lhalf = str(square)[:len(str(square)) // 2]
	Rhalf = str(square)[len(str(square)) // 2:]
	if len(str(square)) == 1:
		Lhalf = '0'
	if int(Lhalf) + int(Rhalf) == number:
		print(number, end=' ')
		flag = 1
if flag == 0:
	print('INVALID RANGE')


start = int(input())
end = int(input())
smith = []

def kap(n):
	num = n
	count = 0
	while num > 0:
		count += 1
		num //= 10
	r = n ** 2 % 10 ** count
	l = n ** 2 // 10 ** count
	return l + r == n
for i in range(start, end + 1):
	if kap(i):
		smith.append(i)
if not smith:
	print('INVALID RANGE')
else:
	for i in smith:
		print(i, end=' ')


def kaprekar(n):
	l = len(str(n))
	d = 10 ** l
	nsq = n ** 2
	r = nsq % d
	nsq = int(nsq / d)
	return r + nsq
p = int(input())
q = int(input())
c = 0
for i in range(p, q + 1):
	s = kaprekar(i)
	if i == s:
		c += 1
		print(i, end=' ')
if c == 0:
	print('INVALID RANGE')


p = int(input())
q = int(input())
ans = ''
for i in range(p, q + 1):
	d = len(str(i))
	strSq = str(i * i)
	ln = len(strSq)
	num1 = int(strSq[ln - d:ln])
	num2 = 0
	if ln - d > 0:
		num2 = int(strSq[0:ln - d])
	if num1 + num2 == i:
		ans += str(i) + ' '
if len(ans) > 0:
	print(ans)
else:
	print('INVALID RANGE')


def ls(x):
	if int(x) < 10:
		return 0
	else:
		return int(x[:int(len(x) / 2)])

def rs(x):
	return int(x[int(len(x) / 2):])
l = int(input())
h = int(input())
flag = 1
for x in range(l, h + 1):
	sqx = x * x
	sqx = str(sqx)
	if ls(sqx) + rs(sqx) == x:
		print(x, end=' ')
		flag = 0
if flag == 1:
	print('INVALID RANGE')


def chk(aa):
	bb = str(aa * aa)
	re = ''
	cc = math.floor(len(bb) / 2)
	while cc <= math.ceil(len(bb) / 2):
		if cc == 0:
			break
		if aa == int(bb[:cc]) + int(bb[cc:]) and int(bb[:cc]) > 0 and (int(bb[cc:]) > 0):
			re = ' ' + str(aa)
			break
		cc += 1
		break
	return re
b = ''
import math
for a in range(int(input()), int(input()) + 1):
	if a == 1:
		b = b + '1'
	if a > 0:
		b = b + chk(a)
if len(b.strip()) == 0:
	b = 'INVALID RANGE'
print(b.strip())


def isKaprekar(n):
	str_n = str(n)
	d = len(str_n)
	str_n2 = str(n * n)
	r = int(str_n2[-d:])
	if r > n:
		return False
	l_str = str_n2[:len(str_n2) - d]
	if l_str == '':
		l = 0
	else:
		l = int(l_str)
	return l + r == n
p = int(input())
q = int(input())
nums = []
if p == 0:
	p = 1
for i in range(p, q + 1):
	if isKaprekar(i):
		nums.append(i)
if len(nums) > 0:
	print(' '.join([str(num) for num in nums]))
else:
	print('INVALID RANGE')


def is_kaprekar(n):
	tmp = str(n ** 2)
	r = tmp[-len(str(n)):]
	l = tmp[:-len(str(n))] or 0
	if n == int(r) + int(l):
		return True
	else:
		return False

def main():
	p = int(input())
	q = int(input())
	count = 0
	for x in range(p, q + 1):
		if is_kaprekar(x):
			print(x, end=' ')
			count += 1
	if count == 0:
		print('INVALID RANGE')
main()


import math

def isKaprekar(num):
	square = str(num ** 2)
	left = square[0:math.floor(len(square) / 2)]
	right = square[math.floor(len(square) / 2):len(square)]
	if left == '':
		return int(right) == num
	else:
		return int(left) + int(right) == num

def kaprekar(low, high):
	result = []
	for i in range(low, high + 1):
		if isKaprekar(i):
			result.append(i)
	if len(result) == 0:
		return 'INVALID RANGE'
	string = ''
	for i in result:
		string = string + str(i) + ' '
	return string
low = int(input())
high = int(input())
print(kaprekar(low, high))


KAPREKAR_CONSTANTS = [1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4950, 5050, 7272, 7777, 9999, 17344, 22222, 77778, 82656, 95121, 99999]
(start, end) = (int(input()), int(input()))
found = False
for x in KAPREKAR_CONSTANTS:
	if x >= start and x <= end:
		found = True
		print(x, end=' ')
if found == False:
	print('INVALID RANGE')


a = int(input())
b = int(input())
c = []
for i in range(a, b + 1):
	sq = i ** 2
	st = str(sq)
	l = len(st)
	st1 = 0
	st2 = 0
	if l == 1:
		su = sq
	else:
		hl = int(l / 2)
		st1 = st[0:hl]
		st2 = st[hl:l]
		su = int(st1) + int(st2)
	if su == i:
		c.append(i)
l2 = len(c)
if l2 == 0:
	print('INVALID RANGE')
else:
	st3 = str(c[0])
	for d in range(1, l2):
		st3 = st3 + ' ' + str(c[d])
print(st3)


import math
lowestVal = int(input())
highestVal = int(input())
pRange = []
for i in range(lowestVal, highestVal + 1):
	sqr = i ** 2
	strSqr = str(sqr)
	if len(strSqr) == 1:
		if sqr == i:
			pRange.append(i)
	else:
		firstpart = strSqr[:math.floor(len(strSqr) / 2)]
		secondpart = strSqr[math.floor(len(strSqr) / 2):]
		firstNum = int(firstpart)
		secondNum = int(secondpart)
		if firstNum + secondNum == i:
			pRange.append(i)
if len(pRange) == 0:
	print('INVALID RANGE')
else:
	strPrint = ''
	for s in pRange:
		strPrint += str(s) + ' '
	print(strPrint)


(p, q) = (int(input()), int(input()))
print(' '.join((str(n) for n in range(p, q + 1) if int(str(n ** 2)[:-len(str(n))] or 0) + int(str(n ** 2)[-len(str(n)):] or 0) == n)) or 'INVALID RANGE')


def strToInt(str):
	if str == '':
		return 0
	else:
		return int(str)
p = int(input())
q = int(input())
vals = []
for i in range(p, q + 1):
	s = str(i ** 2)
	split = int(len(s) / 2)
	str1 = s[:split]
	str2 = s[split:]
	val1 = strToInt(str1)
	val2 = strToInt(str2)
	if val1 + val2 == i:
		vals.append(i)
if len(vals) == 0:
	print('INVALID RANGE')
else:
	for i in vals:
		print(i, end=' ')


import sys

def is_kaprekar_number(n):
	if n < 1:
		return False
	elif n == 1:
		return True
	else:
		s = str(n ** 2)
		a = int(s[:-len(str(n))]) if len(s) > 1 else 0
		b = int(s[-len(str(n)):])
		return b > 0 and a + b == n
p = int(sys.stdin.readline())
q = int(sys.stdin.readline())
kaprekars = [n for n in range(p, q + 1) if is_kaprekar_number(n)]
print(' '.join(map(str, kaprekars)) if kaprekars else 'INVALID RANGE')


def split(n):
	str_n = str(n)
	l = int(str_n[:len(str_n) // 2])
	r = int(str_n[len(str_n) // 2:])
	return [l, r]

def is_kaprekar(n):
	if n < 4:
		return n == 1
	return sum(split(n ** 2)) == n
p = int(input())
q = int(input())
string = ' '.join(map(str, filter(lambda x: is_kaprekar(x), range(p, q + 1))))
if string == '':
	print('INVALID RANGE')
else:
	print(string)


import math
p = int(input())
q = int(input())
L = []
for i in range(p, q + 1):
	num = i ** 2
	numstr = str(num)
	if len(numstr) % 2 == 1:
		numstr = '0' + numstr
	n = len(numstr) // 2
	if int(numstr[0:n]) + int(numstr[n:]) == i:
		L.append(i)
if len(L) != 0:
	print(' '.join(map(str, L)))
else:
	print('INVALID RANGE')


def Kaprekar(a, b):
	answer = []
	for i in range(a, b):
		if i < 10:
			if i == 1 or i == 9:
				answer.append(i)
			continue
		square = str(i * i)
		(firsthalf, secondhalf) = (square[:len(square) // 2], square[len(square) // 2:])
		thesum = int(firsthalf) + int(secondhalf)
		if thesum == i:
			answer.append(i)
	if len(answer) == 0:
		print('INVALID RANGE')
	else:
		print(*answer)
a = int(input())
b = int(input())
Kaprekar(a, b + 1)


def iskaprekar(val, origin):
	if val == 1:
		return True
	strval = str(val)
	if len(strval) > 1:
		le = int(len(strval) / 2)
		left = strval[:le]
		right = strval[le:]
		if int(left) + int(right) == origin:
			return True
	return False

def kaprekar(lower_val, upper_val):
	arr = []
	for i in range(lower_val, upper_val + 1):
		sqr = i ** 2
		if iskaprekar(sqr, i):
			arr.append(i)
	if len(arr) == 0:
		print('INVALID RANGE')
	for i in arr:
		print(i, end=' ')
lower_val = int(input())
upper_val = int(input())
kaprekar(lower_val, upper_val)


def is_kaprekar(n):
	d = len(str(n))
	n2 = str(n ** 2)
	d2 = len(n2)
	r = int(n2[d2 - d:])
	l = int(n2[:d2 - d]) if d2 > d else 0
	return n == l + r
p = int(input())
q = int(input())
kaprekar_numbers = [i for i in range(p, q + 1) if is_kaprekar(i)]
print(' '.join(map(str, kaprekar_numbers)) if len(kaprekar_numbers) > 0 else 'INVALID RANGE')


import sys

def is_kaprekar_number(n):
	if n < 1:
		return False
	elif n == 1:
		return True
	else:
		s = str(n ** 2)
		a = int(s[:-len(str(n))]) if len(s) > 1 else 0
		b = int(s[-len(str(n)):])
		return b > 0 and a + b == n
p = int(sys.stdin.readline())
q = int(sys.stdin.readline())
kaprekars = [n for n in range(p, q + 1) if is_kaprekar_number(n)]
print(' '.join(map(str, kaprekars)) if kaprekars else 'INVALID RANGE')


p = int(input())
q = int(input())
kp = []
for i in range(p, q + 1):
	dp = len(str(i))
	np = i
	np2 = np ** 2
	snp2 = str(np2)
	ll = len(snp2) - dp
	lr = dp
	right = snp2[-dp:]
	if ll == dp or ll == dp - 1:
		left = snp2[0:ll]
		if left != '':
			k = int(left) + int(right)
		else:
			k = int(right)
	if k == i:
		kp.append(str(i))
if kp != []:
	print(' '.join(kp))
else:
	print('INVALID RANGE')


import sys

def kaprekar(n):
	n_digit_count = len(str(n))
	m_str = str(n * n)
	r_str = m_str[-n_digit_count:]
	l_str = m_str[:-n_digit_count]
	l = 0 if len(l_str) == 0 else int(l_str)
	r = int(r_str)
	return l + r == n
p = int(sys.stdin.readline())
q = int(sys.stdin.readline())
exists = False
for i in range(p, q + 1, 1):
	if kaprekar(i):
		print(i, end=' ')
		exists = True
if not exists:
	print('INVALID RANGE')


nums = []
for num in range(int(input()), int(input()) + 1):
	sq = '0' + str(num ** 2)
	if num == int(sq[:len(sq) // 2 + len(sq) % 2]) + int(sq[len(sq) // 2 + len(sq) % 2:]):
		nums.append(num)
if len(nums) == 0:
	print('INVALID RANGE')
else:
	print(' '.join((str(num) for num in nums)))


def EhNumeroKaprekar(n):
	numero_digitos = len(list(str(n)))
	nro_quadrado = pow(n, 2)
	lista_numero = list(str(nro_quadrado))
	texto1 = ''.join(lista_numero[:len(lista_numero) - numero_digitos])
	if texto1 == '':
		texto1 = 0
	texto2 = ''.join(lista_numero[len(lista_numero) - numero_digitos:])
	if texto2 == '':
		texto2 = 0
	return int(texto1) + int(texto2) == n
p = int(input())
q = int(input())
numeros = []
for i in range(p, q + 1):
	if EhNumeroKaprekar(i):
		numeros.append(i)
if len(numeros) == 0:
	print('INVALID RANGE')
else:
	print(' '.join([str(x) for x in numeros]))


import math
p = int(input())
q = int(input())
kaps = []
done = False
for i in range(p, q + 1):
	str_i = str(i)
	d = len(str_i)
	num = i * i
	digits = str(num)
	sum_of_digits = 0
	if num == i:
		print(i, end=' ')
		done = True
	if len(digits) > 1:
		num1 = int(digits[:len(digits) - d])
		num2 = int(digits[d - len(digits) % 2:])
		if num1 + num2 == i:
			print(i, end=' ')
			done = True
if done == False:
	print('INVALID RANGE')


kaprekars = [1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4950, 5050, 7272, 7777, 9999, 17344, 22222, 77778, 82656, 95121, 99999]
a = int(input())
b = int(input())
ans = []
for i in range(a, b + 1):
	if i in kaprekars:
		ans.append(i)
if len(ans) > 0:
	print(' '.join(map(str, ans)))
else:
	print('INVALID RANGE')


p = int(input())
q = int(input())
a = list()
for i in range(p, q + 1):
	i2 = str(i * i)
	lenby2 = int(len(i2) / 2)
	r = int(i2[lenby2:len(i2)])
	if lenby2 == 0:
		l = 0
	else:
		l = int(i2[0:lenby2])
	if r + l == i:
		a.append(str(i))
if len(a) == 0:
	print('INVALID RANGE')
else:
	print(' '.join(a))


def is_kaprekar(n):
	sqrn = n * n
	sn = str(n)
	ssn = str(sqrn)
	if len(ssn) % 2 == 0:
		l = ssn[:len(sn)]
		r = ssn[len(sn):]
	else:
		l = ssn[:len(sn) - 1]
		r = ssn[len(sn) - 1:]
	if len(l) > 0:
		if n == int(l) + int(r):
			return True
		else:
			return False
	elif n == int(r):
		return True
	else:
		return False
p = int(input())
q = int(input())
flag = 0
for i in range(p, q + 1):
	if is_kaprekar(i):
		print(i, end=' ')
		flag = 1
if flag == 0:
	print('INVALID RANGE')


(l, h) = (int(input()), int(input()))
ot = []
for x in range(l, h + 1):
	sq = x ** 2
	l = list(map(int, str(sq)))
	h = int(''.join(map(str, l[int(len(l) / 2):])))
	l = int(''.join(map(str, l[:int(len(l) / 2)]))) if x > 3 else 0
	if l + h == x:
		ot.append(x)
if len(ot) != 0:
	print(' '.join((str(x) for x in ot)), end=' ')
else:
	print('INVALID RANGE')


(p, q) = (int(input()), int(input()))
l = []
i = 0
for x in range(p, q + 1):
	if x == 1:
		l.append(1)
	elif x > 3:
		y = x * x
		if len(str(y)) % 2 == 0:
			if int(str(y)[:len(str(x))]) + int(str(y)[len(str(x)):]) == x:
				l.append(x)
		elif int(str(y)[:len(str(x)) - 1]) + int(str(y)[len(str(x)) - 1:]) == x:
			l.append(x)
if len(l) == 0:
	print('INVALID RANGE')
else:
	print(' '.join(list(map(str, l))))


def is_kaprekar_number(n):
	if n < 1:
		return False
	elif n == 1:
		return True
	else:
		s = str(n ** 2)
		a = int(s[:-len(str(n))]) if len(s) > 1 else 0
		b = int(s[-len(str(n)):])
		return b > 0 and a + b == n
lower = int(input())
upper = int(input())
kaprekars = [n for n in range(lower, upper + 1) if is_kaprekar_number(n)]
print(' '.join(map(str, kaprekars)) if kaprekars else 'INVALID RANGE')


def is_kaprekar(num):
	n = len(str(num))
	sqr = str(num * num)
	left = int(sqr[:-n]) if len(sqr) > n else 0
	right = int(sqr[-n:])
	return num == left + right

def generate_kaprekar(a, b):
	return [str(x) for x in range(a, b + 1) if is_kaprekar(x)]
(a, b) = (int(input()), int(input()))
numbers = generate_kaprekar(a, b)
print(' '.join(numbers) if len(numbers) else 'INVALID RANGE')


p = int(input())
q = int(input())
result = []
for i in range(p, q + 1):
	squre = i * i
	if i < 10:
		r = squre % 10
		l = int(squre / 10)
		if r + l == i:
			result.append(str(i))
	elif i < 100:
		r = squre % 100
		l = int(squre / 100)
		if r + l == i:
			result.append(str(i))
	elif i < 1000:
		r = squre % 1000
		l = int(squre / 1000)
		if r + l == i:
			result.append(str(i))
	elif i < 10000:
		r = squre % 10000
		l = int(squre / 10000)
		if r + l == i:
			result.append(str(i))
	else:
		r = squre % 100000
		l = int(squre / 100000)
		if r + l == i:
			result.append(str(i))
if len(result) > 0:
	print(' '.join(result))
else:
	print('INVALID RANGE')


p = int(input())
q = int(input())
Kaprekar = []
for x in range(p, q + 1):
	d = len(str(x))
	X = str(x * x)
	if x == 1:
		Kaprekar.append(1)
	if len(X) == 1:
		continue
	if x == int(X[len(X) - d:]) + int(X[:len(X) - d]):
		Kaprekar.append(x)
if len(Kaprekar) == 0:
	print('INVALID RANGE')
else:
	print(' '.join([str(x) for x in Kaprekar]))


p = int(input())
q = int(input())
st = ''
for k in range(p, q + 1):
	s = str(k * k)
	if len(s) == 1:
		if int(s) == k:
			st = st + str(k) + ' '
	elif len(s) == 2:
		if int(s[0]) + int(s[1]) == k:
			st = st + str(k) + ' '
	elif len(s) == 3:
		if int(s[0]) + int(s[1:]) == k:
			st = st + str(k) + ' '
	elif len(s) % 2 == 0:
		if int(s[0:int(len(s) / 2)]) + int(s[int(len(s) / 2):]) == k:
			st = st + str(k) + ' '
	elif int(s[0:int(len(s) / 2)]) + int(s[int(len(s) / 2):]) == k:
		st = st + str(k) + ' '
if len(st) == 0:
	print('INVALID RANGE')
else:
	print(st)


def is_kaprekar(n):
	square = str(n ** 2)
	half = len(square) // 2
	firstpart = square[:half]
	firstpart = int(firstpart) if firstpart else 0
	secondpart = int(square[half:])
	return n == firstpart + secondpart
lower_bound = int(input())
upper_bound = int(input())
kaprekars = []
for n in range(lower_bound, upper_bound + 1):
	if is_kaprekar(n):
		kaprekars.append(n)
if not kaprekars:
	print('INVALID RANGE')
else:
	print(*kaprekars)


p = int(input())
q = int(input())
if p > q:
	exit(0)
resul = ''
for i in range(p, q + 1):
	qa = i ** 2
	pos = int(len(str(qa)) / 2)
	if len(str(qa)) == 1:
		right = 0
		left = qa
	else:
		right = int(str(qa)[pos:])
		left = int(str(qa)[:pos])
	if i == sum([right, left]):
		resul = resul + str(i) + ' '
if resul != '':
	print(resul)
else:
	print('INVALID RANGE')


__author__ = 'danielbaeck'
p = int(input())
q = int(input())
op = []

def kaprekar(x):
	xx = x * x
	d = len(str(x))
	l = str(xx)[:-d]
	r = str(xx)[len(str(xx)) - d:]
	if len(l) == 0:
		l = '0'
	return x == int(str(l)) + int(str(r))
for n in range(p, q + 1):
	if kaprekar(n):
		op.append(n)
if len(op) == 0:
	print('INVALID RANGE')
else:
	print(' '.join([str(x) for x in op]))


def kaprekar(n):
	square = str(n * n)
	end = int(len(square))
	mid = int(end / 2)
	l = square[0:mid]
	if l == '':
		l = 0
	else:
		l = int(l)
	r = int(square[mid:end])
	return n == l + r
flag = True
for i in range(int(input()), int(input()) + 1):
	if kaprekar(i):
		flag = False
		print(i, end=' ')
if flag:
	print('INVALID RANGE')


p = int(input())
q = int(input())
numbers = []
while p <= q:
	square = str(p ** 2)
	if len(square) > 1:
		half = len(square) // 2
		left = int(square[:half])
		right = int(square[half:])
		if left + right == p:
			numbers.append(p)
	elif p == 1:
		numbers.append(p)
	p += 1
if numbers:
	numbers = list(map(str, numbers))
	print(' '.join(numbers))
else:
	print('INVALID RANGE')


l = int(input())
r = int(input())
none = 1
for i in range(l, r + 1):
	flag = 0
	sq = i * i
	sqStr = str(sq)
	strlen = len(sqStr)
	half = int(strlen / 2)
	left = sqStr[:half]
	right = sqStr[half:]
	rightNum = int(right)
	if len(left) == 0:
		leftNum = 0
		flag = 1
	else:
		leftNum = int(left)
	if leftNum == 0:
		if flag == 1 and leftNum + rightNum == i:
			print(i, end=' ')
			none = 0
	elif leftNum + rightNum == i:
		print(i, end=' ')
		none = 0
if none == 1:
	print('INVALID RANGE')


def split_digits(N, t=10):
	digits = []
	value = N
	if N == 0:
		digits.append(0)
	else:
		while value:
			digits.insert(0, value % t)
			value //= t
	return digits

def count_digits(N):
	count = 0
	value = abs(N)
	if N == 0:
		count += 1
	else:
		while value:
			count += 1
			value //= 10
	return count

def kaprekar_number(p, q):
	numbers = []
	for i in range(p, q + 1):
		if sum(split_digits(i ** 2, 10 ** count_digits(i))) == i:
			numbers.append(i)
	return numbers

def main():
	p = int(input())
	q = int(input())
	numbers = kaprekar_number(p, q)
	if numbers:
		print(' '.join((str(n) for n in numbers)))
	else:
		print('INVALID RANGE')
main()


import sys
a = int(input())
b = int(input())
count = 0
flag = 0
for i in range(a, b + 1):
	c = str(i * i)
	q = int(len(c) / 2)
	l = c[:q]
	r = c[q:]
	if len(l) != 0:
		if int(l) + int(r) == i:
			print(i, '', end='')
			count = 1
	elif int(r) == i:
		print(i, '', end='')
		flag = 1
if count != 1 and flag != 1:
	print('INVALID RANGE')


p = int(input())
q = int(input())
flag = True
for x in range(p, q + 1):
	xx = x ** 2
	l = len(str(x))
	d = int(str(xx)[-l:])
	l = len(str(xx)) - l
	if l != 0:
		d += int(str(xx)[0:l])
	if x == d:
		flag = False
		print(x, end=' ')
if flag:
	print('INVALID RANGE')


p = int(input())
q = int(input())
invalid_range = True
for n in range(p, q + 1):
	d = len(str(n))
	sq = n * n
	r = sq % 10 ** d
	l = sq // 10 ** d
	if l + r == n:
		invalid_range = False
		print(n, end=' ')
if invalid_range:
	print('INVALID RANGE')


a = int(input())
b = int(input())
k = []
for i in range(a, b + 1):
	sq = i ** 2
	ssq = str(sq)
	d = len(str(i))
	r = int(ssq[-d:])
	ls = len(ssq)
	if ls - d > 0:
		l = int(ssq[:ls - d])
	else:
		l = 0
	if l + r == i:
		k.append(i)
if len(k) == 0:
	print('INVALID RANGE')
else:
	[print(i, end=' ') for i in k]


import math
p = int(input())
q = int(input())
result = []
for n in range(p, q + 1):
	n2 = n ** 2
	dt = 0
	dn2 = n2
	while dn2 > 0:
		dt += 1
		dn2 = dn2 // 10
	d = math.ceil(dt / 2)
	p = 10 ** d
	(l, r) = divmod(n2, p)
	if l + r == n:
		result.append(str(n))
if result:
	print(' '.join(result))
else:
	print('INVALID RANGE')


def kaprekar(n):
	N = str(n * n)
	d = len(str(n))
	if len(N) == 1:
		N = '0' + N
	r = int(str(N)[-1 * d:])
	l = int(str(N)[0:-1 * d])
	return l + r == n
p = int(input().strip())
q = int(input().strip())
found = False
for n in range(p, q + 1):
	if kaprekar(n):
		found = True
		print(n, end=' ')
if not found:
	print('INVALID RANGE')


from math import floor, ceil
(p, q) = (int(input()), int(input()))
lst = []
for i in range(p, q + 1):
	if i == 1:
		lst.append(i)
	if i > 8:
		sqr = str(i * i)
		ilen = len(str(sqr))
		if int(sqr[:floor(ilen / 2)]) + int(sqr[floor(ilen / 2):]) == i or (sqr, sqr[:ceil(ilen / 2)], sqr[ceil(ilen / 2):]) == i:
			lst.append(i)
if lst:
	print(*lst, sep=' ')
else:
	print('INVALID RANGE')


z = 0

def kaprekar(n):
	if n == 1:
		print('1 ', end='')
		return
	elif n < 8:
		return
	c = n ** 2
	c = str(c)
	d = len(c)
	d = int(d / 2)
	a = int(c[:d])
	b = int(c[d:])
	if a + b == n and b > 0:
		global z
		z = 1
		print(str(n) + ' ', end='')

def main():
	a = int(input(''))
	b = int(input(''))
	for i in range(a, b + 1, 1):
		kaprekar(i)
	global z
	if z == 0:
		print('INVALID RANGE')
main()


def is_kaprekar_number(n):
	if n < 10:
		return n == 1 or n == 9
	s = str(n ** 2)
	half = len(s) // 2
	l = s[:half]
	r = s[half:]
	return int(l) + int(r) == n
p = int(input())
q = int(input())
nums = [str(i) for i in range(p, q + 1) if is_kaprekar_number(i)]
if nums:
	print(' '.join(nums))
else:
	print('INVALID RANGE')


p = int(input())
q = int(input())

def is_kaprekar(n):
	d = len(str(n))
	square = str(n * n)
	r = int(square[-d:])
	if square[:-d]:
		l = int(square[:-d])
	else:
		l = 0
	if r + l == n:
		return True

def get_kaprekar(p, q):
	arr = []
	for n in range(p, q + 1):
		if is_kaprekar(n):
			arr.append(n)
	return arr
nums = get_kaprekar(p, q)
if nums:
	print(*nums)
else:
	print('INVALID RANGE')


min = int(input())
max = int(input())
nos = []
for i in range(min, max + 1):
	square = i * i
	squarestr = str(square)
	if len(squarestr) == 1:
		a = 0
		b = int(squarestr)
	elif len(squarestr) == 2:
		a = int(squarestr[0])
		b = int(squarestr[1])
	elif len(squarestr) == 3:
		a = int(squarestr[0])
		b = int(squarestr[1:2])
	elif len(squarestr) % 2 == 0:
		a = int(squarestr[0:len(squarestr) // 2])
		b = int(squarestr[-(len(squarestr) // 2):])
	else:
		a = int(squarestr[:len(squarestr) // 2])
		b = int(squarestr[len(squarestr) // 2:])
	if a + b == i:
		nos.append(str(i))
if len(nos) == 0:
	print('INVALID RANGE')
else:
	print(' '.join(nos))


def sqr(s):
	if int(s) < 16:
		return int(s)
	s1 = int(s[0:len(s) // 2])
	s2 = int(s[len(s) // 2:])
	return s1 + s2
l = int(input())
u = int(input())
a = []
for x in range(l, u + 1, 1):
	s = x * x
	if x == sqr(str(s)):
		a.append(x)
if len(a) == 0:
	print('INVALID RANGE')
else:
	for x in a:
		print(x, end=' ')


def is_kaprekar(n):
	(s, d) = (str(n * n), len(str(n)))
	return int(s[len(s) - d:]) + int(s[0:len(s) - d] if len(s) - d > 0 else 0) == n
(p, q) = (int(input()), int(input()))
output = [str(x) for x in range(p, q + 1) if is_kaprekar(x)]
if len(output) == 0:
	print('INVALID RANGE')
else:
	print(' '.join(output))


def extract_right(n, digits):
	result = 0
	power_of_ten = 1
	for x in range(digits):
		result += n % 10 * power_of_ten
		power_of_ten *= 10
		n //= 10
	return result

def count_digits(n):
	digit_count = 0
	while n != 0:
		n //= 10
		digit_count += 1
	return digit_count

def split_in_two(n, digits_in_right):
	right = extract_right(n, digits_in_right)
	left = (n - right) // 10 ** digits_in_right
	return (left, right)

def is_karprekar(n):
	digits_in_n = count_digits(n)
	square = n * n
	(left, right) = split_in_two(square, digits_in_n)
	return left + right == n
p = int(input())
q = int(input())
found = False
for candidate in range(p, q + 1):
	if is_karprekar(candidate):
		print(candidate, end=' ')
		found = True
if not found:
	print('INVALID RANGE')


import sys

def is_kaprekar_number(n):
	if n < 1:
		return False
	elif n == 1:
		return True
	else:
		s = str(n ** 2)
		a = int(s[:-len(str(n))]) if len(s) > 1 else 0
		b = int(s[-len(str(n)):])
		return b > 0 and a + b == n
p = int(sys.stdin.readline())
q = int(sys.stdin.readline())
kaprekars = [n for n in range(p, q + 1) if is_kaprekar_number(n)]
print(' '.join(map(str, kaprekars)) if kaprekars else 'INVALID RANGE')


def isk(i):
	n = i * i
	n = list(str(n))
	a = ''
	for j in range(0, len(n)):
		n[j] = int(n[j])
		a = a + str(n[j])
	if len(n) == 1:
		if int(n[0]) == i:
			return True
		else:
			return False
	elif int(a[0:int(len(a) / 2)]) + int(a[int(len(a) / 2):len(a)]) == i:
		return True
	else:
		return False
n1 = int(input())
n2 = int(input())
x = 0
for i in range(n1, n2 + 1):
	if isk(i):
		print(i, end=' ')
		x = 1
	else:
		continue
if x == 0:
	print('INVALID RANGE')


low = int(input())
high = int(input())

def testNum(i):
	square = i ** 2
	strSquare = str(square)
	if len(strSquare) == 1:
		strSquare = '0' + strSquare
	leftLen = len(strSquare) // 2
	if int(strSquare[0:leftLen]) + int(strSquare[leftLen:]) == i:
		return True

def calcNumbers(low, high):
	myStr = ''
	for i in range(low, high + 1):
		if testNum(i):
			myStr += str(i) + ' '
	if myStr == '':
		print('INVALID RANGE')
	else:
		print(myStr)
calcNumbers(low, high)


def is_kaprekar(x):
	d = len(str(x))
	y = str(x * x)
	left = int(y[:-d]) if y[:-d] else 0
	right = int(y[-d:])
	return left + right == x
p = int(input())
q = int(input())
output = [x for x in range(p, q + 1) if is_kaprekar(x)]
if output:
	print(*output)
else:
	print('INVALID RANGE')


ans = 0
a = [1]
p = int(input())
q = int(input())
for i in range(p, q + 1):
	s = str(i ** 2)
	if len(s) > 1:
		e = int(s[:int(len(s) / 2)]) + int(s[int(len(s) / 2):])
		if e == i:
			a.append(e)
if len(a) == 1:
	print('INVALID RANGE')
else:
	aa = ''
	for x in a:
		if x >= p and x <= q:
			aa += str(x)
			aa += ' '
	print(aa)


import sys

def is_kaprekar_number(n):
	if n < 1:
		return False
	elif n == 1:
		return True
	else:
		s = str(n ** 2)
		a = int(s[:-len(str(n))]) if len(s) > 1 else 0
		b = int(s[-len(str(n)):])
	return b > 0 and a + b == n
p = int(input())
q = int(input())
kaprekars = [n for n in range(p, q + 1) if is_kaprekar_number(n)]
print(' '.join(map(str, kaprekars)) if kaprekars else 'INVALID RANGE')


p = int(input())
q = int(input())

def isKaprekar(n):
	d = len(str(n))
	sq = n * n
	D = len(str(sq))
	(a, b) = (int(str(sq)[0:D - d]) if str(sq)[0:D - d] else 0, int(str(sq)[D - d:D]))
	return a + b == n
kaprekars = [str(n) for n in range(p, q + 1) if isKaprekar(n)]
print(' '.join(kaprekars) if kaprekars else 'INVALID RANGE')


(p, q) = map(int, (input(), input()))

def is_kaprekar(n):
	n_sqr = str(n ** 2)
	d = len(str(n))
	r = n_sqr[::-1][:d][::-1]
	l = n_sqr[::-1][d:][::-1]
	return int(r or 0) + int(l or 0) == n

def find_kaprekar(p, q):
	for i in range(p, q + 1):
		if is_kaprekar(i):
			yield i
nums = list(find_kaprekar(p, q))
print(*nums) if nums else print('INVALID RANGE')


def main():
	p = int(input())
	q = int(input())
	flag = False
	if p <= 1:
		print(1, end=' ')
		flag = True
	if p < 8 and q > 8:
		p = 8
	for i in range(p, q + 1):
		sq = str(i * i)
		h = len(sq) // 2
		l = int(sq[:h])
		r = int(sq[h:])
		if l + r == i:
			flag = True
			print(i, end=' ')
	if not flag:
		print('INVALID RANGE')
main()


def splitAndAdd(sqrNum, d):
	if len(str(sqrNum)) == 1:
		return sqrNum
	numStr = str(sqrNum)
	r = numStr[-d:]
	l = numStr[:-d]
	return int(r) + int(l)
low = int(input())
high = int(input())
found = False
for i in range(low, high + 1):
	iSqr = pow(i, 2)
	kapTest = splitAndAdd(iSqr, len(str(i)))
	if kapTest == i:
		print(i, end=' ')
		found = True
if not found:
	print('INVALID RANGE')


def is_kaprekar(n):
	if n == 1:
		return True
	s = str(n ** 2)
	if len(s) == 1:
		return False
	d = len(str(n))
	if abs(len(s) - 2 * d) > 1:
		return False
	if len(s) < 2 * d:
		s = '0%s' % s
	r = s[-d:]
	l = s[:d]
	if int(l) + int(r) == int(n):
		return True
	else:
		return False
p = int(input())
q = int(input())
answer = [str(x) for x in range(p, q + 1) if is_kaprekar(x)]
if len(answer) < 1:
	print('INVALID RANGE')
else:
	print(' '.join(answer))


a = int(input())
b = int(input()) + 1
s = ''
for i in range(a, b):
	square = str(i * i)
	str_i = str(i)
	d = len(str_i)
	r = int(square[-d:])
	l = square[:-d]
	if l == '':
		l = 0
	Sum = int(l) + r
	if str_i == str(Sum):
		s += str_i + ' '
if s == '':
	s = 'INVALID RANGE'
print(s)


from_num = int(input())
to_num = int(input())

def is_kaprekar(num: int):
	if num == 1:
		return True
	num_str = str(num ** 2)
	num_str_len = len(num_str)
	if num_str_len < 2:
		return False
	half = int(num_str_len / 2)
	left_sum = int(num_str[0:half])
	right_sum = int(num_str[half:num_str_len])
	if right_sum > 0 and right_sum + left_sum == num:
		return True
invalid = True
for i in range(from_num, to_num + 1):
	if is_kaprekar(i):
		invalid = False
		print(i, end=' ')
if invalid:
	print('INVALID RANGE')


def is_kaprekar_number(x):
	x_squared_string = str(x ** 2)
	index = -len(str(x))
	left_side = int('0' + x_squared_string[:index])
	right_side = int(x_squared_string[index:])
	kaprekar_sum = left_side + right_side
	if x == kaprekar_sum:
		return True
	else:
		return False
lower_bound = int(input())
upper_bound = int(input())
number_of_kaprekar_numbers = 0
for i in range(lower_bound, upper_bound + 1):
	if is_kaprekar_number(i):
		print(i, end=' ')
		number_of_kaprekar_numbers += 1
if number_of_kaprekar_numbers == 0:
	print('INVALID RANGE')