Given an integer n, your task is to complete the function convertToRoman which prints the corresponding roman number of n. Various symbols and their values are given below
Note:- There are a few exceptions for some numbers like 4 in roman is IV,9 in roman is IX, similarly, 40 is XL while 90 is XC. Similarly, 400 is CD while 900 is CM
I 1
V 5
X 10
L 50
C 100
D 500
M 1000
 
Example 1:
Input:
n = 5
Output: V
 
Example 2:
Input:
n = 3
Output: III
 
Your Task:
Complete the function convertToRoman() which takes an integer N as input parameter and returns the equivalent roman. 
 
Expected Time Complexity: O(log_{10}N)
Expected Auxiliary Space: O(log_{10}N * 10)
 
Constraints:
1<=n<=3999

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(log_{10}N)
Expected Auxiliary Space: O(log_{10}N * 10)

Starter code:
#User function template for Python 3



class Solution:

    def convertRoman(self, n):

        #Code here

Solutions:
class Solution:

	def convertRoman(self, n):
		num = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
		sym = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M']
		i = 12
		roman = ''
		while n:
			div = n // num[i]
			n %= num[i]
			while div:
				roman += sym[i]
				div -= 1
			i -= 1
		return roman


class Solution:

	def convertRoman(self, n):
		symbols = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		res = ''
		for i in range(len(symbols)):
			q = n // values[i]
			if q > 0:
				res += symbols[i] * q
				n -= q * values[i]
		return res


class Solution:

	def convertRoman(self, n):
		num = (1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1)
		rom = ('M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I')
		result = ''
		for i in range(len(num)):
			count = int(n / num[i])
			result += str(rom[i] * count)
			n -= num[i] * count
		return result


class Solution:

	def convertRoman(self, num):
		roman = [['I', 1], ['IV', 4], ['V', 5], ['IX', 9], ['X', 10], ['XL', 40], ['L', 50], ['XC', 90], ['C', 100], ['CD', 400], ['D', 500], ['CM', 900], ['M', 1000]]
		res = ''
		for (sym, val) in reversed(roman):
			if num // val:
				count = num // val
				res += sym * count
				num = num % val
		return res


class Solution:

	def convertRoman(self, n):
		units = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
		tens = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC']
		hundrerds = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM']
		thousands = ['', 'M', 'MM', 'MMM']
		return thousands[n // 1000] + hundrerds[n % 1000 // 100] + tens[n % 100 // 10] + units[n % 10]


class Solution:

	def convertRoman(self, n):
		values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		romans = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		roman_letter = ''
		for i in range(len(values)):
			while n >= values[i]:
				roman_letter += romans[i]
				n -= values[i]
		return roman_letter


class Solution:

	def convertRoman(self, n):
		roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		number = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		result = ''
		i = 0
		while n > 0:
			if n >= number[i]:
				n -= number[i]
				result += roman[i]
			else:
				i += 1
		return result


class Solution:

	def convertRoman(self, n):
		numbers = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
		roman = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M']
		r = 12
		roman_type = ''
		while n != 0:
			if n >= numbers[r]:
				roman_type += roman[r]
				n = n - numbers[r]
			else:
				r -= 1
		return roman_type


class Solution:

	def convertRoman(self, n):
		roman = {1: 'I', 5: 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M', 4: 'IV', 9: 'IX', 40: 'XL', 90: 'XC', 400: 'CD', 900: 'CM'}
		ans = ''
		while n:
			for num in sorted(roman.keys(), reverse=True):
				if n >= num:
					ans += roman[num] * (n // num)
					n = n % num
		return ans


class Solution:

	def convertRoman(self, n):
		roman = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M']
		integers = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
		res = ''
		idx = -1
		while n:
			if integers[idx] > n:
				idx -= 1
				continue
			q = n // integers[idx]
			res += roman[idx] * q
			n = n % integers[idx]
		return res


class Solution:

	def convertRoman(self, n):
		a = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
		b = ['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M']
		i = 12
		res = ''
		while n:
			quo = n // a[i]
			n = n % a[i]
			while quo:
				res = res + b[i]
				quo = quo - 1
			i -= 1
		return res


import math

class Solution:

	def convertRoman(self, n):
		romansDict = {1: 'I', 5: 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M', 5000: 'G', 10000: 'H'}
		div = 1
		while n >= div:
			div *= 10
		div //= 10
		res = ''
		while n:
			lastNum = n // div
			if lastNum <= 3:
				res += romansDict[div] * lastNum
			elif lastNum == 4:
				res += romansDict[div] + romansDict[div * 5]
			elif 5 <= lastNum <= 8:
				res += romansDict[div * 5] + romansDict[div] * (lastNum - 5)
			elif lastNum == 9:
				res += romansDict[div] + romansDict[div * 10]
			n = math.floor(n % div)
			div //= 10
		return res


class Solution:

	def convertRoman(self, num):
		Roman = ''
		storeIntRoman = [[1000, 'M'], [900, 'CM'], [500, 'D'], [400, 'CD'], [100, 'C'], [90, 'XC'], [50, 'L'], [40, 'XL'], [10, 'X'], [9, 'IX'], [5, 'V'], [4, 'IV'], [1, 'I']]
		for i in range(len(storeIntRoman)):
			while num >= storeIntRoman[i][0]:
				Roman += storeIntRoman[i][1]
				num -= storeIntRoman[i][0]
		return Roman


class Solution:

	def convertRoman(self, n):
		ROMANS = (('M', 1000), ('CM', 900), ('D', 500), ('CD', 400), ('C', 100), ('XC', 90), ('L', 50), ('XL', 40), ('X', 10), ('IX', 9), ('V', 5), ('IV', 4), ('I', 1))
		result = ''
		for (roman, value) in ROMANS:
			while n >= value:
				result += roman
				n -= value
		return result


class Solution:

	def convertRoman(self, n):
		weights = [['I', 1], ['IV', 4], ['V', 5], ['IX', 9], ['X', 10], ['XL', 40], ['L', 50], ['XC', 90], ['C', 100], ['CD', 400], ['D', 500], ['CM', 900], ['M', 1000]]
		res = ''
		for (sym, weight) in weights[::-1]:
			if n >= weight:
				val = n // weight
				res = res + val * sym
				n = n % weight
		return res


class Solution:

	def convertRoman(self, n):
		romans = [['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX'], ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC'], ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM'], ['', 'M', 'MM', 'MMM', '', '', '', '', '', '']]
		str = ''
		i = 0
		while n != 0:
			str = romans[i][n % 10] + str
			n = n // 10
			i += 1
		return str


class Solution:

	def convertRoman(self, num):
		num_map = {1: 'I', 5: 'V', 4: 'IV', 10: 'X', 9: 'IX', 50: 'L', 40: 'XL', 100: 'C', 90: 'XC', 500: 'D', 400: 'CD', 1000: 'M', 900: 'CM'}
		r = ''
		for n in [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]:
			while n <= num:
				r += num_map[n]
				num -= n
		return r


class Solution:

	def convertRoman(self, n):
		baselist = [1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]
		baselist.reverse()
		dic = {1: 'I', 5: 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M', 4: 'IV', 9: 'IX', 40: 'XL', 90: 'XC', 400: 'CD', 900: 'CM'}
		roman = ''
		for i in range(len(baselist)):
			if n >= baselist[i]:
				q = n // baselist[i]
				r = n % baselist[i]
				roman += dic[baselist[i]] * q
				n = r
		return roman


class Solution:

	def convertRoman(self, n):
		lis = []
		roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		num = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		ans = ''
		k = n
		i = 0
		while i < len(num):
			l = k // num[i]
			while l > 0:
				ans += roman[i]
				l -= 1
			k = k % num[i]
			i += 1
		ans = ''.join(ans)
		return ans


class Solution:

	def convertRoman(self, n):
		str = ''
		m = ['', 'M', 'MM', 'MMM']
		c = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM']
		x = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC']
		i = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
		thousands = m[n // 1000]
		hundreds = c[n % 1000 // 100]
		tens = x[n % 100 // 10]
		ones = i[n % 10]
		str = str + thousands + hundreds + tens + ones
		return str


class Solution:

	def convertRoman(self, n):
		x = n
		z = ''
		while x > 0:
			k = 0
			s = ''
			if 1 <= x:
				k = 1
				s = 'I'
			if 4 <= x:
				k = 4
				s = 'IV'
			if 5 <= x:
				k = 5
				s = 'V'
			if 9 <= x:
				k = 9
				s = 'IX'
			if 10 <= x:
				k = 10
				s = 'X'
			if 40 <= x:
				k = 40
				s = 'XL'
			if 50 <= x:
				k = 50
				s = 'L'
			if 90 <= x:
				k = 90
				s = 'XC'
			if 100 <= x:
				k = 100
				s = 'C'
			if 400 <= x:
				k = 400
				s = 'CD'
			if 500 <= x:
				k = 500
				s = 'D'
			if 900 <= x:
				k = 900
				s = 'CM'
			if 1000 <= x:
				k = 1000
				s = 'M'
			x = x - k
			z = z + s
		return z


class Solution:

	def convertRoman(self, n):
		list_of_character = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		list_of_value = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		count = 0
		str = ''
		while n > 0:
			if n >= list_of_value[count]:
				n -= list_of_value[count]
				str += list_of_character[count]
			else:
				count += 1
		return str


class Solution:

	def convertRoman(self, n):
		roman = ''
		values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		notations = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		for (i, v) in enumerate(values):
			roman += n // v * notations[i]
			n %= v
		return roman


class Solution:

	def convertRoman(self, n):
		n = int(n)
		z = ''
		x = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		y = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		for i in range(13):
			while n >= x[i]:
				n = n - x[i]
				z += y[i]
		return z


class Solution:

	def convertRoman(self, n):
		num = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		roman = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		ans = ''
		for i in range(13):
			while n >= num[i]:
				n = n - num[i]
				ans = ans + roman[i]
		return ans


class Solution:

	def convertRoman(self, n):
		val = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		syb = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		roman_num = ''
		i = 0
		while n > 0:
			for _ in range(n // val[i]):
				roman_num += syb[i]
				n -= val[i]
			i += 1
		return roman_num


class Solution:

	def convertRoman(self, n):
		ls = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		dict = {1: 'I', 4: 'IV', 5: 'V', 9: 'IX', 10: 'X', 40: 'XL', 50: 'L', 90: 'XC', 100: 'C', 400: 'CD', 500: 'D', 900: 'CM', 1000: 'M'}
		ans = []

		def fun(n, res):
			for i in ls:
				if i == n:
					res = dict[i]
					rem = 0
					break
				if i < n:
					rem = n % i
					quo = n // i
					res += dict[i] * quo
					break
			ans.append(res)
			if rem == 0:
				pass
			else:
				fun(rem, '')
		fun(n, '')
		return ''.join(ans)


class Solution:

	def convertRoman(self, n):
		one = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
		ten = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC']
		hnd = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM']
		ths = ['', 'M', 'MM', 'MMM']
		return ths[n // 1000] + hnd[n % 1000 // 100] + ten[n % 100 // 10] + one[n % 10]


class Solution:

	def convertRoman(self, n):
		s = ''
		a = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		b = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		for j in b:
			if n != 0:
				v = n // j
				n = n % j
				s = s + v * a[b.index(j)]
		return s


class Solution:

	def convertRoman(self, n):
		symbols = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		values = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		roman_numerals = ''
		i = 0
		while n > 0:
			while n >= values[i]:
				roman_numerals += symbols[i]
				n = n - values[i]
			i += 1
		return roman_numerals


class Solution:

	def convertRoman(self, num):
		m = ['', 'M', 'MM', 'MMM']
		c = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM ']
		x = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC']
		i = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
		thousands = m[num // 1000]
		hundreds = c[num % 1000 // 100]
		tens = x[num % 100 // 10]
		ones = i[num % 10]
		ans = thousands + hundreds + tens + ones
		s = ''
		for i in range(len(ans)):
			if ans[i] == ' ':
				continue
			else:
				s += ans[i]
		return s


class Solution:

	def convertRoman(self, n):
		romanval = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
		romannum = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I']
		i = 0
		s1 = ''
		while n > 0:
			while n // romanval[i] == 0:
				i += 1
			div = n // romanval[i]
			s1 = s1 + romannum[i] * div
			n = n % romanval[i]
		return s1


class Solution:

	def convertRoman(self, n):
		d = {1: 'I', 5: 'V', 10: 'X', 50: 'L', 100: 'C', 500: 'D', 1000: 'M', 4: 'IV', 9: 'IX', 40: 'XL', 90: 'XC', 400: 'CD', 900: 'CM'}
		output = ''
		dt = sorted(d, reverse=True)
		i = 0
		while n > 0:
			div = n // dt[i]
			n = n % dt[i]
			while div:
				output += d[dt[i]]
				div -= 1
			i += 1
		return output


class Solution:

	def convertRoman(self, n):
		ans = ''
		while n > 0:
			if n >= 1000:
				ans += 'M'
				n -= 1000
			elif n >= 900 and n < 1000:
				ans += 'CM'
				n -= 900
			elif n >= 500 and n < 900:
				ans += 'D'
				n -= 500
			elif n >= 400 and n < 500:
				ans += 'CD'
				n -= 400
			elif n >= 100 and n < 400:
				ans += 'C'
				n -= 100
			elif n >= 90 and n < 100:
				ans += 'XC'
				n -= 90
			elif n >= 50 and n < 90:
				ans += 'L'
				n -= 50
			elif n >= 40 and n < 50:
				ans += 'XL'
				n -= 40
			elif n >= 10 and n < 40:
				ans += 'X'
				n -= 10
			elif n == 9:
				ans += 'IX'
				n -= 9
			elif n >= 5 and n < 9:
				ans += 'V'
				n -= 5
			elif n == 4:
				ans += 'IV'
				n -= 4
			elif n < 4:
				ans += 'I'
				n = n - 1
		return ans


class Solution:

	def convertRoman(self, num):
		way = {1: 'I', 4: 'IV', 5: 'V', 9: 'IX', 10: 'X', 40: 'XL', 50: 'L', 90: 'XC', 100: 'C', 400: 'CD', 500: 'D', 900: 'CM', 1000: 'M'}
		ans = ''
		for x in sorted(way.keys())[::-1]:
			if x <= num:
				ans += way[x] * (num // x)
				num %= x
		return ans


class Solution:

	def convertRoman(self, n):
		roman = ''
		th = n // 1000
		h = n // 100 - n // 1000 * 10
		t = n // 10 - n // 100 * 10
		s = n - n // 10 * 10
		if th:
			roman += 'M' * th
		if h:
			if h == 9:
				roman += 'CM'
			elif 6 <= h <= 8:
				roman += 'D' + 'C' * (h - 5)
			elif h == 5:
				roman += 'D'
			elif h == 4:
				roman += 'CD'
			elif 1 <= h <= 3:
				roman += 'C' * h
		if t > 0:
			if t == 9:
				roman += 'XC'
			elif 6 <= t <= 8:
				roman += 'L' + 'X' * (t - 5)
			elif t == 5:
				roman += 'L'
			elif t == 4:
				roman += 'XL'
			elif 1 <= t <= 3:
				roman += 'X' * t
		if s > 0:
			if s == 9:
				roman += 'IX'
			elif 6 <= s <= 8:
				roman += 'V' + 'I' * (s - 5)
			elif s == 5:
				roman += 'V'
			elif s == 4:
				roman += 'IV'
			elif 1 <= s <= 3:
				roman += 'I' * s
		return roman


class Solution:

	def convertRoman(self, n):
		str1 = ''
		x = n // 1000
		if x != 0:
			str1 += 'M' * x
		n = n % 1000
		x = n // 100
		if x == 9:
			str1 += 'CM'
		elif x == 5:
			str1 += 'D'
		elif x == 4:
			str1 += 'CD'
		elif x > 5 and x < 9:
			y = x - 5
			str1 += 'D' + 'C' * y
		elif x < 4 and x > 0:
			str1 += 'C' * x
		n = n % 100
		x = n // 10
		if x == 9:
			str1 += 'XC'
		elif x == 5:
			str1 += 'L'
		elif x == 4:
			str1 += 'XL'
		elif x > 0 and x < 4:
			str1 += 'X' * x
		elif x > 5 and x < 9:
			y = x - 5
			str1 += 'L' + 'X' * y
		n = n % 10
		x = n
		if x == 9:
			str1 += 'IX'
		elif x == 5:
			str1 += 'V'
		elif x == 4:
			str1 += 'IV'
		elif x > 0 and x < 4:
			str1 += 'I' * x
		elif x > 5 and x < 9:
			y = x - 5
			str1 += 'V' + 'I' * y
		return str1


MAP = dict(I=1, IV=4, V=5, IX=9, X=10, XL=40, L=50, XC=90, C=100, CD=400, D=500, CM=900, M=1000)
IDX = sorted([(value, key) for (key, value) in MAP.items()], key=lambda a: a[0], reverse=True)

class Solution:

	def convertRoman(self, n):
		r = ''
		for (val, key) in IDX:
			if n < val:
				continue
			r = r + key * (n // val)
			n = n % val
		return r


class Solution:

	def convertRoman(self, n):
		li = [[1000, 'M'], [900, 'CM'], [500, 'D'], [400, 'CD'], [100, 'C'], [90, 'XC'], [50, 'L'], [40, 'XL'], [10, 'X'], [9, 'IX'], [5, 'V'], [4, 'IV'], [1, 'I']]
		ans = ''
		while n > 0:
			for i in li:
				if n >= i[0]:
					n = n - i[0]
					ans = ans + i[1]
					break
		return ans


class Solution:

	def convertRoman(self, n):
		roman_hash = {1: 'I', 4: 'IV', 5: 'V', 9: 'IX', 10: 'X', 40: 'XL', 50: 'L', 90: 'XC', 100: 'C', 400: 'CD', 500: 'D', 900: 'CM', 1000: 'M'}
		roman_values = [i for i in roman_hash.keys()]
		roman_values.sort(reverse=True)
		res = ''
		for item in roman_values:
			if n in roman_hash:
				res = res + roman_hash[n]
				return res
			k = n // item
			while k > 0:
				res = res + roman_hash[item]
				k -= 1
			n = n % item
		return res


class Solution:

	def convertRoman(self, n):
		ones = ['', 'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX']
		tens = ['', 'X', 'XX', 'XXX', 'XL', 'L', 'LX', 'LXX', 'LXXX', 'XC']
		hundreds = ['', 'C', 'CC', 'CCC', 'CD', 'D', 'DC', 'DCC', 'DCCC', 'CM']
		thousands = ['', 'M', 'MM', 'MMM']
		t = thousands[n // 1000]
		h = hundreds[n % 1000 // 100]
		tt = tens[n % 100 // 10]
		o = ones[n % 10]
		ans = [t + h + tt + o]
		return ''.join(ans)


class Solution:
	yu = ['I', 'V', 'X', 'L', 'C', 'D', 'M']
	valo = [1, 5, 10, 50, 100, 500, 1000]
	op = ''
	u = 0

	def convertRoman(self, n):
		jki = int(str(n)[self.u]) * 10 ** (len(str(n)) - 1 - self.u)
		if jki >= 1 and jki <= 9:
			if jki < 5:
				if jki == 4:
					self.op += 'IV'
				else:
					for knb in range(0, jki):
						self.op += 'I'
			elif jki == 5:
				self.op += 'V'
			elif jki == 9:
				self.op += 'IX'
			else:
				self.op += 'V'
				jki = jki - 5
				for hbv in range(0, jki):
					self.op += 'I'
		elif jki >= 10 and jki <= 40:
			if jki == 10:
				self.op += 'X'
			elif jki > 10 and jki < 40:
				jki = jki // 10
				for tte in range(0, jki):
					self.op += 'X'
			else:
				self.op += 'XL'
		elif jki == 50:
			self.op += 'L'
		elif jki > 50 and jki < 90:
			self.op += 'L'
			jki = jki - 50
			jki = jki // 10
			for mmi in range(0, jki):
				self.op += 'X'
		elif jki == 90:
			self.op += 'XC'
		elif jki == 100:
			self.op += 'C'
		elif jki > 100 and jki < 400:
			jki = jki // 100
			for mnb in range(0, jki):
				self.op += 'C'
		elif jki == 400:
			self.op += 'CD'
		elif jki == 500:
			self.op += 'D'
		elif jki > 500 and jki < 900:
			self.op += 'D'
			jki = jki - 500
			jki = jki // 100
			for tte in range(0, jki):
				self.op += 'C'
		elif jki == 900:
			self.op += 'CM'
		elif jki == 1000:
			self.op += 'M'
		elif jki > 1000:
			jki = jki // 1000
			for ttewq in range(0, jki):
				self.op += 'M'
		if self.u == len(str(n)) - 1:
			return self.op
		else:
			self.u += 1
			return self.convertRoman(n)