<pre lang="Java">import java.util.*;
public class demo {
public static void main(String args[] ) throws Exception {
Scanner sc = new Scanner(System.in);
int input1 = sc.nextInt();
String result = "";
if(input1==1){
int n = sc.nextInt();
result = result + solution.lakh(n) + solution.thousand(n) + solution.hundred(n);
}
if(input1==2){
int n = sc.nextInt();
result = result + solution.million(n) + solution.thousand2(n) + solution.hundred(n);
}
System.out.println(result);
sc.close();
}
}
class solution{
public static String hundred(int n){
HashMap<Integer, String> words = new HashMap<>();
words.put(0, "");
words.put(1, "ONE");
words.put(2, "TWO");
words.put(3, "THREE");
words.put(4, "FOUR");
words.put(5, "FIVE");
words.put(6, "SIX");
words.put(7, "SEVEN");
words.put(8, "EIGHT");
words.put(9, "NINE");
words.put(10, "TEN");
words.put(11, "ELEVEN");
words.put(12, "TWELVE");
words.put(13, "THIRTEEN");
words.put(14, "FOURTEEN");
words.put(15, "FIFTEEN");
words.put(16, "SIXTEEN");
words.put(17, "SEVENTEEN");
words.put(18, "EIGHTEEN");
words.put(19, "NINETEEN");
words.put(20, "TWENTY");
words.put(30, "THIRTY");
words.put(40, "FORTY");
words.put(50, "FIFTY");
words.put(60, "SIXTY");
words.put(70, "SEVENTY");
words.put(80, "EIGHTY");
words.put(90, "NINETY");
n = n%1000;
String result="";
if(n==0){
result="";
}
else{
if(n/100!=0){
result = result + words.get(n/100) + " HUNDRED ";
if(n%100<20){
result = result + words.get(n%100) + " ";
}
else{
result = result + words.get(((n%100)/10)*10) + " " + words.get(((n%100)%10)) + " ";
}
}
else {
if(n/10!=0){
if(n%10==0){
result = result + words.get((n/10)*10) + " ";
}
else{
if(n<20){
result = result + words.get(n) + " ";
}
else{
result = result + words.get((n/10)*10) + " " + words.get(n%10) + " ";
}
}
}
else{
result = words.get(n) + " ";
}
}
}
return result;
}
public static String thousand(int n){
HashMap<Integer, String> words = new HashMap<>();
words.put(0, "");
words.put(1, "ONE");
words.put(2, "TWO");
words.put(3, "THREE");
words.put(4, "FOUR");
words.put(5, "FIVE");
words.put(6, "SIX");
words.put(7, "SEVEN");
words.put(8, "EIGHT");
words.put(9, "NINE");
words.put(10, "TEN");
words.put(11, "ELEVEN");
words.put(12, "TWELVE");
words.put(13, "THIRTEEN");
words.put(14, "FOURTEEN");
words.put(15, "FIFTEEN");
words.put(16, "SIXTEEN");
words.put(17, "SEVENTEEN");
words.put(18, "EIGHTEEN");
words.put(19, "NINETEEN");
words.put(20, "TWENTY");
words.put(30, "THIRTY");
words.put(40, "FORTY");
words.put(50, "FIFTY");
words.put(60, "SIXTY");
words.put(70, "SEVENTY");
words.put(80, "EIGHTY");
words.put(90, "NINETY");
n = (n/1000)%100;
String result = "";
if(n==0){
result = "";
}
else{
if(n%10==0){
result = result + words.get(n) + " THOUSAND ";
}
else{
if(n<20){
result = result + words.get(n) + " THOUSAND ";
}
else{
result = result + words.get((n/10)*10) + " " + words.get(n%10) + " THOUSAND ";
}
}
}
return result;
}
public static String lakh(int n){
HashMap<Integer, String> words = new HashMap<>();
words.put(0, "");
words.put(1, "ONE");
words.put(2, "TWO");
words.put(3, "THREE");
words.put(4, "FOUR");
words.put(5, "FIVE");
words.put(6, "SIX");
words.put(7, "SEVEN");
words.put(8, "EIGHT");
words.put(9, "NINE");
words.put(10, "TEN");
words.put(11, "ELEVEN");
words.put(12, "TWELVE");
words.put(13, "THIRTEEN");
words.put(14, "FOURTEEN");
words.put(15, "FIFTEEN");
words.put(16, "SIXTEEN");
words.put(17, "SEVENTEEN");
words.put(18, "EIGHTEEN");
words.put(19, "NINETEEN");
words.put(20, "TWENTY");
words.put(30, "THIRTY");
words.put(40, "FORTY");
words.put(50, "FIFTY");
words.put(60, "SIXTY");
words.put(70, "SEVENTY");
words.put(80, "EIGHTY");
words.put(90, "NINETY");
n = n/100000;
String result = "";
if(n==0){
result = "";
}
else{
if(n/10==0){
result = result + words.get(n) + " LAKH ";
}
else{
if(n<20){
result = result + words.get(n) + " LAKH ";
}
else{
result = result + words.get((n/10)*10) + " " + words.get(n%10) + " LAKH ";
}
}
}
return result;
}
public static String thousand2(int n){
n = (n/1000)%1000;
String result = "";
if(n==0){
result = "";
}
else{
result = result + solution.hundred(n) + "THOUSAND ";
}
return result;
}
public static String million(int n){
n = n/1000000;
String result = "";
if(n==0){
result = "";
}
else{
result = result + solution.hundred(n) + "MILLION ";
}
return result;
}
}