This page is still under construction.

Parts of this page are still being built. What you see may change.

Hangul Syllables

Time limit1sMemory limit256 MB

Summary
Given N between 1 and 11172, print the N-th Hangul syllable in initial, medial, then final order.
Level

Easy1 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Every Hangul syllable is made of an initial consonant, a medial vowel, and a final consonant. The three parts are written together as one character.

There are 19 initial consonants: ㄱ, ㄲ, ㄴ, ㄷ, ㄸ, ㄹ, ㅁ, ㅂ, ㅃ, ㅅ, ㅆ, ㅇ, ㅈ, ㅉ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ. There are 21 medial vowels: ㅏ, ㅐ, ㅑ, ㅒ, ㅓ, ㅔ, ㅕ, ㅖ, ㅗ, ㅘ, ㅙ, ㅚ, ㅛ, ㅜ, ㅝ, ㅞ, ㅟ, ㅠ, ㅡ, ㅢ, ㅣ. There are 28 final consonants, where the first one is the empty final: none, ㄱ, ㄲ, ㄳ, ㄴ, ㄵ, ㄶ, ㄷ, ㄹ, ㄺ, ㄻ, ㄼ, ㄽ, ㄾ, ㄿ, ㅀ, ㅁ, ㅂ, ㅄ, ㅅ, ㅆ, ㅇ, ㅈ, ㅊ, ㅋ, ㅌ, ㅍ, ㅎ.

The syllables are numbered so that the initial consonant changes slowest and the final consonant changes fastest. Pick the initial consonant in the order listed above, pick the medial vowel in the order listed above within one initial consonant, and pick the final consonant in the order listed above among syllables that share an initial consonant and a medial vowel.

The first syllable joins initial ㄱ, medial ㅏ, and no final, which gives "가". The second joins initial ㄱ, medial ㅏ, and final ㄱ, which gives "각". The last joins initial ㅎ, medial ㅣ, and final ㅎ, which gives "힣".

The number of syllables built this way is 19×21×28=1117219 \times 21 \times 28 = 11172.

Given NN, write a program that finds the NN-th syllable.

Input

The first line contains NN. (1≤N≤111721 \le N \le 11172)

Output

Print the NN-th syllable on the first line. Use UTF-8 for the output encoding.

Examples4

  1. Example 1

    Input
    1
    
    Expected output
    가
    
  2. Example 2

    Input
    11172
    
    Expected output
    힣
    
  3. Example 3

    Input
    4146
    
    Expected output
    백
    
  4. Example 4

    Input
    7425
    
    Expected output
    준