Write a function to convert a given number into words.
Example 1:
Input:
N = 438237764
Output: forty three crore eighty two lakh 
thirty seven thousand seven hundred and 
sixty four
 
Example 2:
Input:
N = 1000
Output: one thousand
Your Task:
You don't need to read input or print anything. Your task is to complete the function convertToWords() which takes the integer n as input parameters and returns a string containing n in words.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 10^{9} - 1

Difficulty: MEDIUM
Tags: Data structures
Skill types: Data structures
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)

Starter code:
#User function Template for python3

class Solution:
    def convertToWords(self, n):
        # code here

Solutions:
class Solution:

	def convertToWords(self, n):
		one = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		ten = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']

		def numToWords(n, s):
			str = ''
			if n > 19:
				str += ten[n // 10] + one[n % 10]
			else:
				str += one[n]
			if n:
				str += s
			return str
		output = ''
		output += numToWords(n // 10000000, 'crore ')
		output += numToWords(n // 100000 % 100, 'lakh ')
		output += numToWords(n // 1000 % 100, 'thousand ')
		output += numToWords(n // 100 % 10, 'hundred ')
		if n > 100 and n % 100:
			output += 'and '
		output += numToWords(n % 100, '')
		return output


class Solution:

	def convertToWords(self, n):
		num = list(map(int, str(n)))
		output = ''
		lst = []
		t = -3
		ones = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 0: ''}
		tens1 = {0: 'ten', 1: 'eleven', 2: 'twelve', 3: 'thirteen', 4: 'fourteen', 5: 'fifteen', 6: 'sixteen', 7: 'seventeen', 8: 'eighteen', 9: 'nineteen'}
		tens = {2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty', 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety', 0: ''}
		final = {-1: '', -2: 'thousand', -3: 'lakh', -4: 'crore'}

		def name(num, lst, n):
			ans = ''
			l = len(lst)
			for k in range(l, 0, -1):
				ans = ans.strip()
				i = -k
				if i == -3:
					if lst[-2] == 0 and lst[-1] == 0 and (lst[-3] != 0):
						ans = ans + ones[lst[i]] + ' hundred'
						break
					elif lst[-3] != 0:
						ans = ans + ones[lst[i]] + ' hundred and'
				elif i == -2:
					if lst[i] == 1:
						ans = ans + ' ' + tens1[lst[-1]]
						break
					else:
						ans = ans + ' ' + tens[lst[i]]
				else:
					ans = ans + ' ' + ones[lst[-1]]
			ans = ans.strip()
			if ans != '':
				if n != -1:
					if num[-1][0] == 0:
						if num[-1][1] == 0 and num[-1][-1] == 0:
							ans = ans + ' ' + final[n]
						elif n == -2:
							ans = ans + ' ' + final[n] + ' and'
						elif n == -3 and num[-2] == [0] * 2:
							ans = ans + ' ' + final[n] + ' and'
						elif n == -4 and num[-3] == [0] * 2 and (num[-2] == [0] * 2):
							ans = ans + ' ' + final[n] + ' and'
						else:
							ans = ans + ' ' + final[n]
					else:
						ans = ans + ' ' + final[n]
				ans = ans.strip()
			return ans
		while abs(t) <= len(num):
			lst.append(num[t:])
			num = num[:t]
			t = -2
		if num != []:
			lst.append(num)
		lst.reverse()
		num = lst
		length = len(num)
		for (index, ele) in enumerate(num):
			v = name(num, ele, index - length)
			output = output + ' ' + v
			output = output.strip()
		return output


def word(k, ans):
	dist = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'}
	dist2 = {10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
	dist3 = {2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty', 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety'}
	if k >= 100:
		ans.append(dist[k // 100])
		ans.append('hundred')
		k %= 100
		if k > 0:
			ans.append('and')
	if 10 <= k <= 19:
		ans.append(dist2[k])
		return
	k1 = k // 10
	k2 = k % 10
	if k1 != 0:
		ans.append(dist3[k1])
	if k2 != 0:
		ans.append(dist[k2])

class Solution:

	def convertToWords(self, n):
		ans = []
		while n > 0:
			if n >= 10000000:
				k = n // 10000000
				n %= 10000000
				word(k, ans)
				ans.append('crore')
			elif n >= 100000:
				k = n // 100000
				n %= 100000
				word(k, ans)
				ans.append('lakh')
			elif n >= 1000:
				k = n // 1000
				n %= 1000
				word(k, ans)
				ans.append('thousand')
			else:
				if len(ans) != 0 and n < 100:
					ans.append('and')
				word(n, ans)
				n = 0
		return ' '.join(ans)


class Solution:

	def convertToWords(self, n):
		ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']

		def numToWord(num, string):
			if num == 0:
				return ''
			if num <= 19:
				return ones[num] + ' ' + string
			if tens[num // 10] == '':
				if string == '':
					return ones[num % 10]
				return ones[num % 10] + ' ' + string
			if ones[num % 10] == '':
				if string == '':
					return tens[num // 10]
				return tens[num // 10] + ' ' + string
			if string == '':
				return tens[num // 10] + ' ' + ones[num % 10]
			return tens[num // 10] + ' ' + ones[num % 10] + ' ' + string
		res = []
		res = res + [numToWord(n // 10 ** 7, 'crore')]
		if res[len(res) - 1] == '':
			res.pop()
		res = res + [numToWord(n // 10 ** 5 % 100, 'lakh')]
		if res[len(res) - 1] == '':
			res.pop()
		res = res + [numToWord(n // 10 ** 3 % 100, 'thousand')]
		if res[len(res) - 1] == '':
			res.pop()
		res = res + [numToWord(n // 100 % 10, 'hundred')]
		if res[len(res) - 1] == '':
			res.pop()
		if n % 100 != 0:
			if len(res) > 0:
				res = res + ['and' + ' ' + numToWord(n % 100, '')]
			if len(res) == 0:
				res = res + [numToWord(n % 100, '')]
		while len(res) > 0 and res[len(res) - 1] == '':
			res.pop()
		s = ''
		for i in range(len(res)):
			if i == len(res) - 1:
				s = s + res[i]
			else:
				s = s + res[i] + ' '
		return s


class Solution:

	def convertToWords(self, num):
		d = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty', 60: 'sixty', 70: 'seventy', 80: 'eighty', 90: 'ninety'}
		d_ = {7: 'crore', 5: 'lakh', 3: 'thousand', 2: 'hundred'}
		s = ''
		x = num
		n = 0
		while x != 0:
			x = x // 10
			n += 1
		if n > 3:
			if n % 2 == 1:
				y = 2
			else:
				y = 1
		elif n == 3:
			y = 1
		elif n == 2:
			y = 2
		else:
			y = 1
		while n - y >= 0:
			p = num // pow(10, n - y)
			num = num % pow(10, n - y)
			if p != 0:
				if p in d.keys():
					s += d[p] + ' '
				else:
					s += d[p // 10 * 10] + ' ' + d[p % 10] + ' '
			if p != 0 and n - y in d_.keys():
				s += d_[n - y] + ' '
			if n - y == 2 and num != 0:
				s += 'and' + ' '
			if n - y == 3:
				y += 1
			else:
				y += 2
		return s


class Solution:

	def convertToWords(self, n):
		a1 = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine'}
		a2 = {10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
		a3 = {2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty', 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety'}
		d = []
		e = []
		while n > 0:
			e.append(n % 10)
			n //= 10
			if len(d) == 0:
				if len(e) == 3:
					d.append(e)
					e = []
			elif len(e) == 2:
				d.append(e)
				e = []
		if len(e) > 0:
			d.append(e)
		o = {1: 'thousand', 2: 'lakh', 3: 'crore'}
		s = ''
		for i in range(len(d) - 1, 0, -1):
			if len(d[i]) == 2 and d[i][-1] > 0:
				if d[i][-1] == 1:
					s1 = d[i][-1] * 10
					if d[i][0] != 0:
						s1 += d[i][0]
					s += a2[s1] + ' '
				else:
					s += a3[d[i][-1]] + ' '
					if d[i][0] > 0:
						s += a1[d[i][0]] + ' '
			elif d[i][0] > 0:
				s += a1[d[i][0]] + ' '
			if sum(d[i]) > 0:
				s += o[i] + ' '
		if len(d[0]) == 1:
			if d[0][0] > 0:
				s += a1[d[0][0]]
				return s
		elif len(d[0]) == 2:
			if d[0][1] == 1:
				g = d[0][1] * 10
				if d[0][0] > 0:
					g += d[0][0]
				s += a2[g]
			else:
				s += a3[d[0][1]] + ' '
				if d[0][0] > 0:
					s += a1[d[0][0]]
			return s
		if len(d[0]) == 3 and d[0][2] != 0:
			s += a1[d[0][2]] + ' '
			s += 'hundred '
		if d[0][0] > 0 or d[0][1] > 0:
			if s != '':
				s += 'and '
		if d[0][1] > 0:
			if d[0][1] == 1:
				e = d[0][1] * 10
				e += d[0][0]
				s += a2[e]
			else:
				s += a3[d[0][1]] + ' '
				if d[0][0] > 0:
					s += a1[d[0][0]]
		elif d[0][0] > 0:
			s += a1[d[0][0]]
		i = len(s) - 1
		while i > 0 and s[i] == ' ':
			i -= 1
		return s


class Solution:

	def convertToWords(self, n):
		l1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
		l2 = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		l3 = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		x = n
		number = []

		def zero_case():
			number = ['zero']

		def number_name(x):
			if x > 9 and x < 20:
				y = x % 10
				number.append(l2[y])
			else:
				y = x % 10
				x = x // 10
				if y != 0:
					if x == 0:
						pass
					else:
						z = x % 10
						x = x // 10
						if z != 1:
							number.append(l3[z])
					number.append(l1[y - 1])
				else:
					number.append(l3[x])
		l4 = ['hundred', 'thousand', 'lakh', 'crore']
		tens_checker = 3
		power = 7
		if x == 0:
			zero_case()
		else:
			if len(str(x)) > 3:
				while power > 2:
					y = x // 10 ** power
					x = x % 10 ** power
					if y > 0:
						number_name(y)
						number.append(l4[tens_checker])
					power -= 2
					tens_checker -= 1
			if len(str(x)) == 3:
				y = x // 100
				x = x % 100
				if y != 0:
					number.append(l1[y - 1])
					number.append(l4[0])
					if x != 0:
						number.append('and')
				number_name(x)
			else:
				if len(number) > 0:
					check = number[::-1]
					if check[0] == 'and':
						pass
					else:
						number.append('and')
				number_name(x)
		ans = ''
		for i in number:
			ans += i
			ans += ' '
		return ans


class Solution:

	def convertToWords(self, n):
		ones = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
		teens = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		tens = ['ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		more = ['crore', 'lakh', 'thousand', 'hundred']
		dv = 10000000
		out = []
		i = 0
		while n > 0 and dv > 0:
			d = n // dv
			n = n % dv
			if d > 0:
				if i == 4 and len(out) > 0:
					out.append('and')
				if d > 10 and d < 20:
					out.append(teens[d - 11])
					d = 0
				elif d >= 10:
					out.append(tens[d // 10 - 1])
					d = d % 10
				if d > 0:
					out.append(ones[d - 1])
				if i <= 3:
					out.append(more[i])
			if i < 2 or i > 2:
				dv = dv // 100
			else:
				dv = dv // 10
			i += 1
		return ' '.join(out)


class Solution:

	def convertToWords(self, n):
		if n == 0:
			return 'zero'
		mp = {}
		mp[1] = 'one'
		mp[2] = 'two'
		mp[3] = 'three'
		mp[4] = 'four'
		mp[5] = 'five'
		mp[6] = 'six'
		mp[7] = 'seven'
		mp[8] = 'eight'
		mp[9] = 'nine'
		mp[10] = 'ten'
		mp[11] = 'eleven'
		mp[12] = 'twelve'
		mp[13] = 'thirteen'
		mp[14] = 'fourteen'
		mp[15] = 'fifteen'
		mp[16] = 'sixteen'
		mp[17] = 'seventeen'
		mp[18] = 'eighteen'
		mp[19] = 'nineteen'
		mp[20] = 'twenty'
		mp[30] = 'thirty'
		mp[40] = 'forty'
		mp[50] = 'fifty'
		mp[60] = 'sixty'
		mp[70] = 'seventy'
		mp[80] = 'eighty'
		mp[90] = 'ninety'
		mp[100] = 'one hundred'

		def traverse(n):
			if n == 0:
				return ''
			if n in mp:
				return mp[n]
			if n >= 10000000:
				if n % 10000000 < 100 and n % 10000000 > 0:
					return traverse(n // 10000000) + ' crore and ' + traverse(n % 10000000) + ' '
				return traverse(n // 10000000) + ' crore ' + traverse(n % 10000000) + ' '
			if n >= 100000:
				if n % 100000 < 100 and n % 100000 > 0:
					return traverse(n // 100000) + ' lakh and ' + traverse(n % 100000) + ' '
				return traverse(n // 100000) + ' lakh ' + traverse(n % 100000) + ' '
			if n >= 1000:
				if n % 1000 < 100 and n % 1000 > 0:
					return traverse(n // 1000) + ' thousand and ' + traverse(n % 1000) + ' '
				return traverse(n // 1000) + ' thousand ' + traverse(n % 1000) + ' '
			if n >= 100:
				if n % 100 > 0:
					return traverse(n // 100) + ' hundred and ' + traverse(n % 100) + ' '
				return traverse(n // 100) + ' hundred ' + traverse(n % 100) + ' '
			return mp[n - n % 10] + ' ' + mp[n % 10]
		return traverse(n)


class Solution:

	def convertToWords(self, n):
		res = ''
		flag = 0
		div = n // 10000000
		if div > 0:
			word = self.getmeword(div)
			res += word + ' crore '
			n = n % 10000000
			flag = 1
		div = n // 100000
		if div > 0:
			word = self.getmeword(div)
			res += word + ' lakh '
			n = n % 100000
			flag = 1
		div = n // 1000
		if div > 0:
			word = self.getmeword(div)
			res += word + ' thousand '
			n = n % 1000
			flag = 1
		div = n // 100
		if div > 0:
			word = self.getmeword(div)
			res += word + ' hundred '
			n = n % 100
			flag = 1
		if n > 0:
			if flag != 0:
				res += 'and '
			word = self.getmeword(n)
			res += word
		return res

	def getmeword(self, n):
		ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		if n > 0 and n <= 19:
			return ones[n]
		else:
			ind1 = n // 10
			ind2 = n % 10
			return tens[ind1] + ' ' + ones[ind2]


class Solution:

	def ten_one(self, ten, one):
		num = ''
		if ten >= 2:
			if ten == 2:
				num = 'twenty'
			elif ten == 3:
				num = 'thirty'
			elif ten == 4:
				num = 'forty'
			elif ten == 5:
				num = 'fifty'
			elif ten == 6:
				num = 'sixty'
			elif ten == 7:
				num = 'seventy'
			elif ten == 8:
				num = 'eighty'
			elif ten == 9:
				num = 'ninety'
			if one == 0:
				num += ''
			elif one == 1:
				num += ' one'
			elif one == 2:
				num += ' two'
			elif one == 3:
				num += ' three'
			elif one == 4:
				num += ' four'
			elif one == 5:
				num += ' five'
			elif one == 6:
				num += ' six'
			elif one == 7:
				num += ' seven'
			elif one == 8:
				num += ' eight'
			elif one == 9:
				num += ' nine'
		elif ten == 0:
			if one == 0:
				num = 0
			elif one == 1:
				num += 'one'
			elif one == 2:
				num += 'two'
			elif one == 3:
				num += 'three'
			elif one == 4:
				num += 'four'
			elif one == 5:
				num += 'five'
			elif one == 6:
				num += 'six'
			elif one == 7:
				num += 'seven'
			elif one == 8:
				num += 'eight'
			elif one == 9:
				num += 'nine'
		elif ten == 1:
			if one == 0:
				num += 'ten'
			elif one == 1:
				num += 'eleven'
			elif one == 2:
				num += 'twelve'
			elif one == 3:
				num += 'thirteen'
			elif one == 4:
				num += 'fourteen'
			elif one == 5:
				num += 'fifteen'
			elif one == 6:
				num += 'sixteen'
			elif one == 7:
				num += 'seventeen'
			elif one == 8:
				num += 'eighteen'
			elif one == 9:
				num += 'nineteen'
		return num

	def convertToWords(self, n):
		ans = ''
		if n > 9999999:
			word = self.ten_one(n // 100000000 % 10, n // 10000000 % 10)
			if word != 0:
				ans += word + ' ' + 'crore'
		if n > 99999:
			word = self.ten_one(n // 1000000 % 10, n // 100000 % 10)
			if word != 0:
				if len(ans) > 0:
					ans += ' '
				ans += word + ' ' + 'lakh'
		if n > 999:
			word = self.ten_one(n // 10000 % 10, n // 1000 % 10)
			if word != 0:
				if len(ans) > 0:
					ans += ' '
				ans += word + ' ' + 'thousand'
		if n > 99:
			word = self.ten_one(0, n // 100 % 10)
			if word != 0:
				if len(ans) > 0:
					ans += ' '
				ans += word + ' ' + 'hundred'
		word = self.ten_one(n // 10 % 10, n % 10)
		if word != 0:
			if len(ans) > 0:
				ans += ' and '
			ans += word
		return ans


class Solution:

	def intToString(self, n, word):
		d19 = {0: '', 1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen'}
		d20above = {2: 'twenty', 3: 'thirty', 4: 'forty', 5: 'fifty', 6: 'sixty', 7: 'seventy', 8: 'eighty', 9: 'ninety'}
		ans = ''
		if n > 0:
			if n > 19:
				ans += d20above[n // 10] + ' '
				if d19[n % 10] == '':
					ans += word + ' '
				else:
					ans += d19[n % 10] + ' ' + word + ' '
			else:
				ans = d19[n] + ' ' + word + ' '
			return ans
		return ''

	def convertToWords(self, n):
		ans = ''
		ans += self.intToString(n // 10 ** 7, 'crore')
		n = n % 10 ** 7
		ans += self.intToString(n // 10 ** 5, 'lakh')
		n = n % 10 ** 5
		ans += self.intToString(n // 10 ** 3, 'thousand')
		n = n % 10 ** 3
		ans += self.intToString(n // 10 ** 2, 'hundred')
		n = n % 10 ** 2
		if n > 0:
			if ans == '':
				ans = self.intToString(n, '')
			else:
				ans = ans + 'and ' + self.intToString(n, '')
		return ans


class Solution:

	def convertToWords(self, n):
		num = []
		list1 = ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
		list2 = ['ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		list3 = ['eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		dictionary = dict()
		m = n
		if m // 10 ** 2 % 10:
			dictionary[m // 10 ** 2] = 'hundred'
		if m // 10 ** 3 % 10:
			dictionary[m // 10 ** 3] = 'thousand'
		elif m // 10 ** 4 % 10:
			dictionary[m // 10 ** 3] = 'thousand'
		if m // 10 ** 5 % 10:
			dictionary[m // 10 ** 5] = 'lakh'
		elif m // 10 ** 6 % 10:
			dictionary[m // 10 ** 5] = 'lakh'
		if m // 10 ** 7 % 10:
			dictionary[m // 10 ** 7] = 'crore'
		elif m // 10 ** 8 % 10:
			dictionary[m // 10 ** 7] = 'crore'
		while n:
			if n in dictionary and dictionary[n] == 'hundred' or n == m // 10 ** 2:
				if n % 10:
					temp = n % 10
					num.append(list1[temp - 1])
					n = n // 10
				else:
					n = n // 10
				if n in dictionary:
					num.append(dictionary[n])
			else:
				if n % 10 != 0:
					if n // 10 % 10 == 1:
						temp = n % 10
						num.append(list3[temp - 1])
						n = n // 100
					elif n // 10 % 10 == 0:
						temp = n % 10
						num.append(list1[temp - 1])
						n = n // 100
					else:
						temp = n % 10
						num.append(list1[temp - 1])
						if n // 10 % 10:
							temp = n // 10 % 10
							num.append(list2[temp - 1])
							n = n // 100
						else:
							n = n // 100
				elif n // 10 % 10:
					temp = n // 10 % 10
					num.append(list2[temp - 1])
					n = n // 100
				else:
					n = n // 100
				if n in dictionary:
					num.append(dictionary[n])
		str = ''
		length = len(num)
		if m > 100:
			if (m // 10 % 10 != 0 and m // 10 % 10 != 1) and m % 10 != 0:
				num.insert(2, 'and')
				length += 1
			elif m // 10 % 10 != 0 and m % 10 == 0:
				num.insert(1, 'and')
				length += 1
			elif m % 10 != 0:
				num.insert(1, 'and')
				length += 1
		for i in reversed(range(length)):
			str += num[i] + ' '
		return str


class Solution:

	def numtoword(self, n, string):
		str = ''
		one = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		tens = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']
		if n > 19:
			str += tens[n // 10] + one[n % 10]
		else:
			str += one[n]
		if n != 0:
			str += string
		return str

	def convertToWords(self, n):
		res = ''
		res += self.numtoword(n // 10000000, 'crore ')
		res += self.numtoword(int(n // 100000 % 100), 'lakh ')
		res += self.numtoword(int(n // 1000 % 100), 'thousand ')
		res += self.numtoword(int(n // 100 % 10), 'hundred ')
		if n > 100 and n % 100 > 0:
			res += 'and '
		res += self.numtoword(n % 100, '')
		return res


class Solution:

	def convertToWords(self, n):
		one = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		ten = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']

		def numToWords(n, s):
			str = ''
			if n > 19:
				str += ten[n // 10] + one[n % 10]
			else:
				str += one[n]
			if n:
				str += s
			return str
		output = ''
		output += numToWords(n // 10000000, 'crore ')
		output += numToWords(n // 100000 % 100, 'lakh ')
		output += numToWords(n // 1000 % 100, 'thousand ')
		output += numToWords(n // 100 % 10, 'hundred ')
		if n > 100 and n % 100:
			output += 'and '
		output += numToWords(n % 100, '')
		return output
if __name__ == '__main__':
	tc = int(input())
	while tc > 0:
		n = int(input())
		ob = Solution()
		ans = ob.convertToWords(n)
		print(ans)
		tc -= 1


class Solution:

	def convertToWords(self, n):

		def num_to_Words(n, suffix):
			ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
			tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
			st = ''
			if n > 19:
				x = int(n % 10)
				y = int(n // 10)
				if x != 0:
					st += tens[y] + ' ' + ones[x]
				else:
					st += tens[y]
			else:
				n = int(n)
				st += ones[n]
			if n:
				st += suffix
			return st
		res = ''
		res += num_to_Words(n // 10000000, ' crore ')
		res += num_to_Words(n / 100000 % 100, ' lakh ')
		res += num_to_Words(n // 1000 % 100, ' thousand ')
		res += num_to_Words(n // 100 % 10, ' hundred ')
		if n > 100 and n % 100 != 0:
			res += 'and '
		res += num_to_Words(n % 100, '')
		return res
if __name__ == '__main__':
	tc = int(input())
	while tc > 0:
		n = int(input())
		ob = Solution()
		ans = ob.convertToWords(n)
		print(ans)
		tc -= 1


class Solution:

	def convertToWords(self, n):
		x = ['crore', 'lakh', 'thousand', '']
		d = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'thirty', 40: 'forty', 50: 'fifty', 60: 'sixty', 70: 'seventy', 80: 'eighty', 90: 'ninety', 0: ''}
		ans = ''
		p = 1000
		i = 1
		while n > 0:
			if i == 0:
				p = 100
			newans = ''
			newn = n % p
			n = n // p
			unit = newn % 10
			newn = newn // 10
			ten = newn % 10
			newn = newn // 10
			hundred = newn
			if hundred != 0:
				newans = d[hundred] + ' ' + 'hundred'
			if i == 1 and (hundred != 0 or ten != 0 or unit != 0):
				newans += ' and'
			if ten != 1:
				newans += ' ' + d[10 * ten] + ' ' + d[unit]
			else:
				newans += ' ' + d[10 + unit]
			i = 0
			if newans.strip() == '':
				x.pop()
				continue
			ans = newans + ' ' + x.pop() + ' ' + ans
		ans = ans.split()
		if ans[-1] == 'and':
			ans.pop()
		elif ans[0] == 'and':
			ans.pop(0)
		return ' '.join((x for x in ans if x != ''))
if __name__ == '__main__':
	tc = int(input())
	while tc > 0:
		n = int(input())
		ob = Solution()
		ans = ob.convertToWords(n)
		print(ans)
		tc -= 1


class Solution:

	def smallConvert(self, num):
		numDict = {'2': 'twenty', '3': 'thirty', '4': 'forty', '5': 'fifty', '6': 'sixty', '7': 'seventy', '8': 'eighty', '9': 'ninety'}
		teenDict = {'10': 'ten', '11': 'eleven', '12': 'twelve', '13': 'thirteen', '14': 'fourteen', '15': 'fifteen', '16': 'sixteen', '17': 'seventeen', '18': 'eighteen', '19': 'nineteen'}
		smallDict = {'1': 'one', '2': 'two', '3': 'three', '4': 'four', '5': 'five', '6': 'six', '7': 'seven', '8': 'eight', '9': 'nine'}
		nos = [10, 1]
		resWord = ''
		if str(num) in teenDict.keys():
			resWord = teenDict[str(num)]
		else:
			for i in nos:
				tmp = num // i
				word = ''
				num %= 10
				if tmp:
					if i == 10:
						word = numDict[str(tmp)]
						resWord = word
					elif i == 1:
						word = smallDict[str(tmp)]
						if resWord == '':
							resWord = word
						else:
							resWord += ' ' + word
		return resWord

	def convertToWords(self, n):
		noDict = {'10000000': 'crore', '100000': 'lakh', '1000': 'thousand', '100': 'hundred', '1': ''}
		finalRes = ''
		nos = [10000000, 100000, 1000, 100, 1]
		for i in nos:
			tmp = n // i
			n = n % i
			word = res = ''
			if tmp:
				word = noDict[str(i)]
				frontWord = self.smallConvert(tmp)
				if i != 1:
					res = frontWord + ' ' + word + ' '
				elif finalRes == '':
					res = frontWord
				else:
					res = 'and ' + frontWord
			finalRes += res
		return finalRes
if __name__ == '__main__':
	tc = int(input())
	while tc > 0:
		n = int(input())
		ob = Solution()
		ans = ob.convertToWords(n)
		print(ans)
		tc -= 1


class Solution:

	def convertToWords(self, n):
		A = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		B = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']

		def helper(n, s):
			str = ''
			if n > 19:
				str += B[n // 10] + A[n % 10]
			else:
				str += A[n]
			if n:
				str += s
			return str
		s = ''
		s += helper(n // 10 ** 7, 'crore ')
		s += helper(n // 10 ** 5 % 100, 'lakh ')
		s += helper(n // 10 ** 3 % 100, 'thousand ')
		s += helper(n // 10 ** 2 % 10, 'hundred ')
		if n > 100 and n % 100:
			s += 'and '
		s += helper(n % 100, '')
		return s


import decimal

class Solution:

	def convertToWords(self, num):
		num = decimal.Decimal(num)
		decimal_part = num - int(num)
		num = int(num)
		if decimal_part:
			return self.convertToWords(num) + ' point ' + ' '.join((self.convertToWords(i) for i in str(decimal_part)[2:]))
		under_20 = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		tens = ['twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		above_100 = {100: 'hundred', 1000: 'thousand', 100000: 'lakh', 10000000: 'crore'}
		if num < 20:
			return under_20[num]
		if num < 100:
			return tens[num // 10 - 2] + ('' if num % 10 == 0 else ' ' + under_20[num % 10])
		pivot = max([key for key in above_100.keys() if key <= num])
		val = ' and' if pivot in above_100 and num % pivot < 100 and (num % pivot != 0) else ''
		return self.convertToWords(num // pivot) + ' ' + above_100[pivot] + val + ('' if num % pivot == 0 else ' ' + self.convertToWords(num % pivot))


class Solution:

	def convertToWords(self, n):
		ones = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		tens = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']

		def numbertoword(n, p):
			strs = ''
			if n > 19:
				strs += tens[n // 10] + ones[n % 10]
			else:
				strs += ones[n]
			if n != 0:
				strs += p
			return strs
		output = ''
		output += numbertoword(n // 10000000, 'crore ')
		output += numbertoword(n // 100000 % 100, 'lakh ')
		output += numbertoword(n // 1000 % 100, 'thousand ')
		output += numbertoword(n // 100 % 10, 'hundred ')
		if n > 100 and n % 100:
			output += 'and '
		output += numbertoword(n % 100, '')
		return output


class Solution:

	def convertToWords(self, n):
		name = ''
		isNum = True if n >= 100 else False
		if n > 0:
			cr = n // 10000000
			if cr > 0:
				name += self.getMeName(cr) + ' crore '
			n = n % 10000000
			lak = n // 100000
			if lak > 0:
				name += self.getMeName(lak) + ' lakh '
			n = n % 100000
			thou = n // 1000
			if thou > 0:
				name += self.getMeName(thou) + ' thousand '
			n = n % 1000
			hund = n // 100
			if hund > 0:
				name += self.getMeName(hund) + ' hundred '
			n = n % 100
			if isNum and n > 0:
				name += 'and '
			fname = self.getMeName(n)
			name += fname
		return name

	def getMeName(self, num):
		name = ''
		ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		if num >= 0 and num <= 19:
			name = ones[num]
		elif num >= 20 and num <= 99:
			numTens = num // 10
			numOnes = num % 10
			name = tens[numTens] + ' ' + ones[numOnes]
		return name.strip()


class Solution:

	def convertToWords(self, n):
		ones = ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen']
		tens = ['', 'Ten', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']
		arr = []
		suffix = ['', ' Hundred', ' Thousand', ' Lakh', ' Crore']
		at = 0
		while n > 0:
			mod = 100
			if at == 1:
				mod = 10
			num = n % mod
			if num == 0:
				pass
			elif num < 20:
				arr.append(ones[num] + suffix[at])
			else:
				string = tens[num // 10]
				if num % 10 > 0:
					string += (' ' if len(string) > 0 else '') + ones[num % 10]
				if at > 0:
					string += suffix[at]
				arr.append(string)
			if at == 0 and len(arr) == 1 and (len(arr[0]) > 0):
				arr[0] = 'and ' + arr[0]
			n //= mod
			at += 1
		if len(arr) == 1:
			if arr[0][:3] == 'and':
				return arr[0][4:].lower()
			return arr[0].lower()
		else:
			return ' '.join(arr[::-1]).lower()


class Solution:

	def convertToWords(self, n):

		def make_number_words(num, useAnd=0):
			numbers = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
			tenth_numbers = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
			inWords = ''
			if n <= 19999:
				useAnd = 1
			while num > 0:
				if len(str(num)) == 5 or len(str(num)) == 4:
					inWords += str(numbers[num // 1000]) + ' thousand'
					num = num % 1000
				elif len(str(num)) == 3:
					inWords += ' ' + str(numbers[num // 100]) + ' hundred'
					num = num % 100
				elif num > 19:
					if useAnd:
						inWords += ' and ' + str(tenth_numbers[num // 10])
					else:
						inWords += ' ' + str(tenth_numbers[num // 10])
					num = num % 10
					inWords += ' ' + str(numbers[num])
					num = 0
				elif len(str(num)) == 2 and num <= 19:
					if useAnd:
						inWords += ' and ' + str(numbers[num])
					else:
						inWords += ' ' + str(numbers[num])
					num = 0
				elif 0 < num < 10:
					if useAnd:
						inWords += ' and ' + str(numbers[num])
					else:
						inWords += ' ' + str(numbers[num])
					num = 0
			return inWords
		if n == 0:
			return 'Zero'
		if n <= 19999:
			sub_num = make_number_words(n).strip()
			if sub_num[0:4] == 'and ':
				sub_num = sub_num[4:]
			return sub_num
		if n <= 99999:
			sub_num = str(make_number_words(n // 1000)).strip() + ' thousand'
			if n % 1000 > 0:
				new_sub_num = str(make_number_words(n % 1000, 1)).strip()
				sub_num += ' ' + new_sub_num
			sub_num = sub_num.strip()
			if sub_num[0:4] == 'and ':
				sub_num = sub_num[4:]
			return sub_num
		if n <= 9999999:
			sub_num = str(make_number_words(n // 100000)).strip() + ' lakh'
			if n % 100000 // 1000 > 0:
				new_sub_num = str(make_number_words(n % 100000 // 1000)).strip() + ' thousand'
				sub_num += ' ' + new_sub_num
			if n % 1000 > 0:
				new_sub_num = str(make_number_words(n % 1000, 1)).strip()
				sub_num += ' ' + new_sub_num
			sub_num = sub_num.strip()
			if sub_num[0:4] == 'and ':
				sub_num = sub_num[4:]
			return sub_num
		if n > 9999999:
			sub_num = str(make_number_words(n // 10000000)).strip() + ' crore'
			if n % 10000000 // 100000 > 0:
				new_sub_num = str(make_number_words(n % 10000000 // 100000)).strip() + ' lakh'
				sub_num += ' ' + new_sub_num
			if n % 100000 // 1000 > 0:
				new_sub_num = str(make_number_words(n % 100000 // 1000)).strip() + ' thousand'
				sub_num += ' ' + new_sub_num
			if n % 1000 > 0:
				new_sub_num = str(make_number_words(n % 1000, 1)).strip()
				sub_num += ' ' + new_sub_num
			sub_num = sub_num.strip()
			if sub_num[0:4] == 'and ':
				sub_num = sub_num[4:]
			return sub_num


class Solution:

	def convertToWords(self, n):
		if n == 0:
			return 'Zero'
		res = ''
		isNumGrtrHundred = True if n > 100 else False
		crore = int(n / 10000000)
		if crore != 0:
			ans = self.getMeWord(crore)
			res += ans + 'crore '
		n = n % 10000000
		lakh = int(n / 100000)
		if lakh != 0:
			ans = self.getMeWord(lakh)
			res += ans + 'lakh '
		n = n % 100000
		thousand = int(n / 1000)
		if thousand != 0:
			ans = self.getMeWord(thousand)
			res += ans + 'thousand '
		n = n % 1000
		hundred = int(n / 100)
		if hundred != 0:
			ans = self.getMeWord(hundred)
			res += ans + 'hundred '
		n = n % 100
		if isNumGrtrHundred and n != 0:
			res = res + 'and '
		if n != 0:
			ans = self.getMeWord(n)
			res += ans
		return res

	def getMeWord(self, num):
		ones = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		tens = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']
		if num >= 1 and num <= 19:
			return ones[num]
		elif num >= 20 and num <= 99:
			mynumTen = int(num / 10)
			mynumOne = num % 10
			return tens[mynumTen] + ones[mynumOne]


class Solution:

	def convertToWords(self, n):
		unit = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		tenth = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']

		def numtoword(num, s=''):
			ans = ''
			if num > 19:
				ans += tenth[num // 10] + ' ' + unit[num % 10] + ' '
			else:
				ans += unit[num] + ' '
			if num:
				ans += s + ' '
			return ans
		a = ''
		a += numtoword(n // 10000000, 'crore')
		a += numtoword(n // 100000 % 100, 'lakh')
		a += numtoword(n // 1000 % 100, 'thousand')
		a += numtoword(n // 100 % 10, 'hundred')
		if n > 100 and n % 100:
			a += 'and '
		a += numtoword(n % 100, '')
		return ' '.join(a.split())


class Solution:

	def convertToWords(self, n):
		n = str(n)
		length = len(n)
		word = []
		words = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		subwords = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		num = 0
		for i in range(length):
			if length - 9 - i == 0:
				if n[i] == '1':
					word.append(subwords[10 + int(n[i + 1])])
				elif n[i] != '0':
					word.append(words[int(n[i])])
			elif length - 8 - i == 0:
				if length == length - i and n[i] != '0':
					word.append(subwords[int(n[i])])
				elif n[i] != '0' and n[i - 1] != '1':
					word.append(subwords[int(n[i])])
				if n[i] != '0' or n[i - 1] != '0':
					word.append('crore')
			elif length - 7 - i == 0:
				if n[i] == '1':
					word.append(subwords[10 + int(n[i + 1])])
				elif n[i] != '0':
					word.append(words[int(n[i])])
			elif length - 6 - i == 0:
				if length == length - i and n[i] != '0':
					word.append(subwords[int(n[i])])
				elif n[i] != '0' and n[i - 1] != '1':
					word.append(subwords[int(n[i])])
				if n[i] != '0' or n[i - 1] != '0':
					word.append('lakh')
			elif length - 5 - i == 0:
				if n[i] == '1':
					word.append(subwords[10 + int(n[i + 1])])
				elif n[i] != '0':
					word.append(words[int(n[i])])
			elif length - 4 - i == 0:
				if length == length - i and n[i] != '0':
					word.append(subwords[int(n[i])])
				elif n[i] != '0' and n[i - 1] != '1':
					word.append(subwords[int(n[i])])
				if n[i] != '0' or n[i - 1] != '0':
					word.append('thousand')
			elif length - 3 - i == 0:
				if n[i] != '0':
					word.append(subwords[int(n[i])] + ' hundred')
			elif length - 2 - i == 0:
				num = int(n[-2:])
				if num > 0:
					if num < 20:
						if length > 2:
							word.append('and' + ' ' + subwords[num])
						else:
							word.append(subwords[num])
						break
					elif n[-1] != '0':
						if length > 2:
							word.append('and ' + words[int(n[i])] + ' ' + subwords[int(n[i + 1])])
						else:
							word.append(words[int(n[i])] + ' ' + subwords[int(n[i + 1])])
						break
					else:
						if length > 2:
							word.append('and ' + words[int(n[i])])
						else:
							word.append(words[int(n[i])])
						break
			elif length == 1:
				word.append(subwords[int(n[i])])
		return ' '.join(word)


class Solution:

	def __init__(self):
		self.l = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ']
		self.l11 = ['ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		self.l1 = ['', 'one1 ', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']

	def ans(self, n):
		t = n % 10
		m = int(str(n)[0])
		if len(str(int(n))) == 1:
			m = 0
		if m == 1:
			return self.l11[t]
		return self.l1[int(m)] + self.l[int(t)]

	def convertToWords(self, n):
		s = ''
		s = self.ans(n % 100)
		n = int(n / 100)
		if n > 0:
			if n % 10 == 0:
				s = 'and ' + s
			elif s == '':
				s = 'hundred ' + s
			else:
				s = 'hundred and ' + s
		s = self.l[n % 10] + s
		n = int(n / 10)
		c = 0
		while n > 0:
			t = self.ans(n % 100)
			if t == '':
				pass
			elif c == 0:
				s = 'thousand ' + s
			elif c == 1:
				s = 'lakh ' + s
			elif c == 2:
				s = 'crore ' + s
			s = t + s
			n = int(n / 100)
			c += 1
		return s


class Solution:

	def two(self, ones, tens, dig):
		i = int(dig)
		if i > 10 and i < 20:
			if i <= 15:
				if i == 11:
					return 'eleven'
				if i == 12:
					return 'twelve'
				if i == 13:
					return 'thirteen'
				if i == 14:
					return 'fourteen'
				if i == 15:
					return 'fifteen'
			if i == 18:
				return 'eighteen'
			return ones[int(dig[1])] + 'teen'
		if len(dig) > 1:
			if i % 10 != 0:
				return tens[int(dig[0])] + ' ' + ones[int(dig[1])]
			else:
				return tens[int(dig[0])]
		elif len(dig) == 1:
			return ones[int(dig[0])]

	def convertToWords(self, n):
		s = str(n)
		p = ''
		ones = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
		tens = ['', 'ten', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		t = [i for i in [7, 5, 3, 2]]
		h = {}
		h[7] = 'crore'
		h[5] = 'lakh'
		h[3] = 'thousand'
		h[2] = 'hundred'
		for j in t:
			f = pow(10, j)
			if n // f != 0:
				k = n // f
				m = n % f
				p += self.two(ones, tens, str(k)) + ' ' + h[j] + ' '
				n = m
		if p != '' and n != 0:
			p += 'and '
		p += self.two(ones, tens, str(n))
		return p


class Solution:

	def num_to_string(self, number, postfix):
		ten = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		twenty = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']
		num_st = ''
		if number > 19:
			num_st += twenty[number // 10] + ten[number % 10]
		else:
			num_st += ten[number]
		if number:
			num_st += postfix
		return num_st

	def convertToWords(self, n):
		result = ''
		result += self.num_to_string(n // 10000000, 'crore ')
		result += self.num_to_string(n // 100000 % 100, 'lakh ')
		result += self.num_to_string(n // 1000 % 100, 'thousand ')
		result += self.num_to_string(n // 100 % 10, 'hundred ')
		if n > 100 and n % 100:
			result += 'and '
		result += self.num_to_string(n % 100, '')
		return result


class Solution:

	def util(self, n, st, ans):
		if n == 0:
			return ''
		one = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		ten = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']
		temp = ''
		if n > 19:
			temp += ten[n // 10] + one[n % 10]
		else:
			temp += one[n]
		return temp + st

	def convertToWords(self, n):
		ans = ''
		ans += self.util(n // 10000000, 'crore ', ans)
		ans += self.util(n // 100000 % 100, 'lakh ', ans)
		ans += self.util(n // 1000 % 100, 'thousand ', ans)
		ans += self.util(n // 100 % 10, 'hundred ', ans)
		if n // 100 and n % 100:
			ans += 'and '
		ans += self.util(n % 100, '', ans)
		return ans


class Solution:

	def convertToWords(self, n):
		l = len(str(n))
		ans = []
		lookUpNumber = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ', 'ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		lookUpTenth = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']
		power = ['crore', 'lakh', 'thousand', 'hundred', '']
		i = 0
		i2 = 100000000
		while i != 3:
			if n // i2 != 0:
				if n // i2 == 1:
					i2 = i2 // 10
					ans.append(lookUpNumber[n // i2] + power[i] + ' ')
				else:
					curr = lookUpTenth[n // i2]
					n = n % i2
					i2 = i2 // 10
					ans.append(curr + lookUpNumber[n // i2] + power[i] + ' ')
			else:
				i2 = i2 // 10
				if n // i2 != 0:
					ans.append(lookUpNumber[n // i2] + power[i] + ' ')
			n = n % i2
			i2 = i2 // 10
			i += 1
		if n // i2 != 0:
			ans.append(lookUpNumber[n // i2] + power[i] + ' ')
		n = n % i2
		i2 = i2 // 10
		i += 1
		if n // i2 != 0:
			if n // i2 == 1:
				i2 = i2 // 10
				ans.append(lookUpNumber[n // i2] + power[i] + ' ')
				if len(ans) > 1:
					ans.insert(-1, 'and ')
			else:
				curr = lookUpTenth[n // i2]
				n = n % i2
				i2 = i2 // 10
				ans.append(curr + lookUpNumber[n // i2] + power[i] + ' ')
				if len(ans) > 1:
					ans.insert(-1, 'and ')
		else:
			i2 = i2 // 10
			if n // i2 != 0:
				ans.append(lookUpNumber[n // i2] + power[i] + ' ')
				if len(ans) > 1:
					ans.insert(-1, 'and ')
		return ''.join(ans).strip()


class Solution:

	def convertToWords(self, n):
		number = []
		ans = []
		val = {9: 'crore', 8: 'crore', 7: 'lakh', 6: 'lakh', 5: 'thousand', 4: 'thousand', 3: 'hundred'}
		one_digit = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']
		two_digit = ['ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen']
		three_digit = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety']
		while n > 0:
			a = n % 10
			number.append(a)
			n //= 10
		while len(number) > 3:
			if len(number) % 2 != 0:
				length = 0
				if number[-1] == 1:
					ans.append(two_digit[number[-2]])
				else:
					ans.append(three_digit[number[-1]])
					ans.append(one_digit[number[-2]])
				length = len(number)
				number.pop()
				number.pop()
			else:
				ans.append(one_digit[number[-1]])
				length = len(number)
				number.pop()
			if ans[-1] != '' or (ans[-2] != '' and ans[-2] not in val.values()):
				ans.append(val[length])
		if len(number) == 3:
			if number[-1] != 0:
				ans.append(one_digit[number[-1]])
				ans.append(val[len(number)])
			number.pop()
		if len(number) == 2:
			if len(ans) != 0:
				ans.append('and')
			if number[-1] == 1:
				ans.append(two_digit[number[-2]])
			else:
				ans.append(three_digit[number[-1]])
				ans.append(one_digit[number[-2]])
			number.pop()
			number.pop()
		if len(number) == 1:
			ans.append(one_digit[number[0]])
		rt = ' '.join(ans)
		r = rt.split()
		if r[-1] == 'and':
			r.pop()
		return ' '.join(r)


l = ''
l1 = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']
l2 = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety', 'hundrade']

class Solution:

	def convertToWords(self, n):
		temp = n
		k = ''
		n = 0
		if temp // 10000000 != 0:
			k = findletter(temp // 10000000) + ' crore '
			temp = temp % 10000000
			n += 1
		if temp // 100000 != 0:
			k = k + findletter(temp // 100000) + ' lakh '
			temp = temp % 100000
			n += 1
		if temp // 1000 != 0:
			k = k + findletter(temp // 1000) + ' thousand '
			temp = temp % 1000
			n += 1
		if temp // 100 != 0:
			k = k + findletter(temp // 100) + ' hundred '
			temp = temp % 100
			n += 1
		if n > 0 and temp != 0:
			k = k + 'and ' + findletter(temp)
		else:
			k = k + findletter(temp)
		return k

def findletter(n):
	k = ''
	if n <= 20:
		return l1[n]
	elif n % 10 == 0:
		return k + l2[n // 10]
	else:
		k = l2[n // 10] + ' '
		k = k + l1[n % 10]
		return k


class Solution:

	def convertToWords(self, n):
		nums = ['', 'one ', 'two ', 'three ', 'four ', 'five ', 'six ', 'seven ', 'eight ', 'nine ']
		teens = ['ten ', 'eleven ', 'twelve ', 'thirteen ', 'fourteen ', 'fifteen ', 'sixteen ', 'seventeen ', 'eighteen ', 'nineteen ']
		tens = ['', '', 'twenty ', 'thirty ', 'forty ', 'fifty ', 'sixty ', 'seventy ', 'eighty ', 'ninety ']
		ans = ''
		num_str = str(n)

		def convert(afterlen, unit):
			nonlocal ans, num_str
			if len(num_str) <= afterlen:
				return
			if afterlen == 0:
				word = num_str
			else:
				word = num_str[:-afterlen]
				num_str = num_str[-afterlen:]
			if len(word) == 0 or int(word) == 0:
				return
			elif int(word) < 10:
				ans += nums[int(word)]
			elif word[0] == '1':
				ans += teens[int(word[1])]
			else:
				ans += tens[int(word[0])] + nums[int(word[1])]
			ans += unit
		convert(7, 'crore ')
		convert(5, 'lakh ')
		convert(3, 'thousand ')
		convert(2, 'hundred ')
		if len(ans) > 0 and num_str != '00':
			ans += 'and '
		convert(0, '')
		return ans