← Home
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)

	p10 := make([]uint64, n+1)
	p10[0] = 1
	for i := 1; i <= n; i++ {
		p10[i] = p10[i-1] * 10
	}

	dp := make([]uint64, n+1)
	choice := make([][]byte, 2*n)
	for i := range choice {
		choice[i] = make([]byte, n+1)
	}

	for p := 2*n - 1; p >= 0; p-- {
		nextDp := make([]uint64, n+1)
		digit := uint64(s[p] - '0')

		minC1 := p - n
		if minC1 < 0 {
			minC1 = 0
		}
		maxC1 := p
		if maxC1 > n {
			maxC1 = n
		}

		for c1 := minC1; c1 <= maxC1; c1++ {
			c2 := p - c1
			var scoreH, scoreM uint64
			validH := c1 < n
			validM := c2 < n

			if validH {
				scoreH = digit*p10[n-1-c1] + dp[c1+1]
			}
			if validM {
				scoreM = digit*p10[n-1-c2] + dp[c1]
			}

			if validH && validM {
				if scoreH >= scoreM {
					nextDp[c1] = scoreH
					choice[p][c1] = 'H'
				} else {
					nextDp[c1] = scoreM
					choice[p][c1] = 'M'
				}
			} else if validH {
				nextDp[c1] = scoreH
				choice[p][c1] = 'H'
			} else if validM {
				nextDp[c1] = scoreM
				choice[p][c1] = 'M'
			}
		}
		dp = nextDp
	}

	c1 := 0
	ans := make([]byte, 2*n)
	for p := 0; p < 2*n; p++ {
		ans[p] = choice[p][c1]
		if ans[p] == 'H' {
			c1++
		}
	}

	fmt.Println(string(ans))
}