After the big birthday party, Katie still wanted Shiro to have some more fun. Later, she came up with a game called treasure hunt. Of course, she invited her best friends Kuro and Shiro to play with her.The three friends are very smart so they passed all the challenges very quickly and finally reached the destination. But the treasure can only belong to one cat so they started to think of something which can determine who is worthy of the treasure. Instantly, Kuro came up with some ribbons.A random colorful ribbon is given to each of the cats. Each color of the ribbon can be represented as an uppercase or lowercase Latin letter. Let's call a consecutive subsequence of colors that appears in the ribbon a subribbon. The beauty of a ribbon is defined as the maximum number of times one of its subribbon appears in the ribbon. The more the subribbon appears, the more beautiful is the ribbon. For example, the ribbon aaaaaaa has the beauty of $$$7$$$ because its subribbon a appears $$$7$$$ times, and the ribbon abcdabc has the beauty of $$$2$$$ because its subribbon abc appears twice.The rules are simple. The game will have $$$n$$$ turns. Every turn, each of the cats must change strictly one color (at one position) in his/her ribbon to an arbitrary color which is different from the unchanged one. For example, a ribbon aaab can be changed into acab in one turn. The one having the most beautiful ribbon after $$$n$$$ turns wins the treasure.Could you find out who is going to be the winner if they all play optimally?

The first line contains an integer $$$n$$$ ($$$0 \leq n \leq 10^{9}$$$) — the number of turns. Next 3 lines contain 3 ribbons of Kuro, Shiro and Katie one per line, respectively. Each ribbon is a string which contains no more than $$$10^{5}$$$ uppercase and lowercase Latin letters and is not empty. It is guaranteed that the length of all ribbons are equal for the purpose of fairness. Note that uppercase and lowercase letters are considered different colors.

Print the name of the winner ("Kuro", "Shiro" or "Katie"). If there are at least two cats that share the maximum beauty, print "Draw".

7
treasurehunt
threefriends
hiCodeforces

NoteIn the first example, after $$$3$$$ turns, Kuro can change his ribbon into ooooo, which has the beauty of $$$5$$$, while reaching such beauty for Shiro and Katie is impossible (both Shiro and Katie can reach the beauty of at most $$$4$$$, for example by changing Shiro's ribbon into SSiSS and changing Katie's ribbon into Kaaaa). Therefore, the winner is Kuro.In the fourth example, since the length of each of the string is $$$9$$$ and the number of turn is $$$15$$$, everyone can change their ribbons in some way to reach the maximal beauty of $$$9$$$ by changing their strings into zzzzzzzzz after 9 turns, and repeatedly change their strings into azzzzzzzz and then into zzzzzzzzz thrice. Therefore, the game ends in a draw.

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	s = make([]string, 3, 3)
	c = make([]map[rune]int, 3, 3)
	m = make([]int, 3, 3)
	b = make([]bool, 3, 3)
)

func Init() {
	for i := 0; i < 3; i++ {
		c[i] = map[rune]int{}
	}
}
func Solve(io *FastIO) {
	k := io.NextInt()
	for i := 0; i < 3; i++ {
		s[i] = io.NextLine()
	}
	n := len(s[0])
	mob := 0
	iob := -1
	crysis := -1
	for i := range s {
		for _, j := range s[i] {
			if _, ok := c[i][j]; !ok {
				c[i][j] = 0
			}
			c[i][j] += 1
			if c[i][j] > m[i] {
				m[i] = c[i][j]
			}
		}
		if len(c[i]) == 1 && k == 1 {
			b[i] = true
		}
	}
	for i := range s {
		if m[i]+k >= n {
			if b[i] {
				m[i] = n - 1
			} else {
				m[i] = n
			}
		} else {
			m[i] += k
		}
		if m[i] > mob {
			mob, iob = m[i], i
		} else if m[i] == mob {
			crysis = mob
		}
	}
	if crysis == mob {
		io.Println("Draw")
		return
	}
	g := map[int]string{0: "Kuro", 1: "Shiro", 2: "Katie"}
	io.Println(g[iob])
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9 - 1
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	if nKuro == len(kuro) && n == 1 {
		nKuro--
	} else {
		nKuro += min(n, len(kuro)-nKuro)
	}

	if nShiro == len(shiro) && n == 1 {
		nShiro--
	} else {
		nShiro += min(n, len(shiro)-nShiro)
	}

	if nKatie == len(katie) && n == 1 {
		nKatie--
	} else {
		nKatie += min(n, len(katie)-nKatie)
	}

	// fmt.Println(nKuro, nShiro, nKatie)

	if nKuro > nShiro && nKuro > nKatie {
		return "Kuro"
	}

	if nShiro > nKuro && nShiro > nKatie {
		return "Shiro"
	}

	if nKatie > nKuro && nKatie > nShiro {
		return "Katie"
	}

	return "Draw"
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 60
		kuro := "ddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb"
		shiro := "dcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY"
		katie := "XaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 3
		kuro := "aaaaa"
		shiro := "aaaaa"
		katie := "aaaab"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var n int

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func solve() int {
	var s string
	fmt.Fscan(in, &s)
	l := len(s)
	if n >= l {
		return l
	}
	mp := make(map[uint8]int)
	mx := 1
	for i := 0; i < l; i++ {
		if v, ok := mp[s[i]]; ok {
			mp[s[i]]++
			mx = max(mx, v+1)
		} else {
			mp[s[i]] = 1
		}
	}
	if mx == l {
		if n != 1 {
			return l
		} else {
			return l - 1
		}
	}
	if n + mx >= l {
		return l
	}
	return n + mx
}

func main() {
	defer out.Flush()
	fmt.Fscan(in, &n)
	a, b, c := solve(), solve(), solve()
	//fmt.Fprint(out, a, b, c)
	switch {
	case a > b && a > c:
		fmt.Fprint(out, "Kuro")
	case b > a && b > c:
		fmt.Fprint(out, "Shiro")
	case c > a && c > b:
		fmt.Fprint(out, "Katie")
	default:
		fmt.Fprint(out, "Draw")
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var ma, mb, mc int
	var a, b, c = make(map[string]int), make(map[string]int), make(map[string]int)
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	for _, p := range kuro {
		var item = string(p)
		a[item]++
		var x = a[item]
		if ma < x {
			ma = x
		}
	}

	for _, p := range shiro {
		var item = string(p)
		b[item]++
		var x = b[item]
		if mb < x {
			mb = x
		}
	}

	for _, p := range katie {
		var item = string(p)
		c[item]++
		var x = c[item]
		if mc < x {
			mc = x
		}
	}

	// fmt.Println(ma, mb, mc)
	if ma == len(kuro) && n == 1 {
		kuro = kuro[:len(kuro)-1]
	}
	if mb == len(shiro) && n == 1 {
		shiro = shiro[:len(shiro)-1]
	}
	if mc == len(katie) && n == 1 {
		katie = katie[:len(katie)-1]
	}
	var aa = min(ma+n, len(kuro))
	var bb = min(mb+n, len(shiro))
	var cc = min(mc+n, len(katie))
	// fmt.Println(aa, bb, cc)
	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{aa, "Kuro"},
		pair{bb, "Shiro"},
		pair{cc, "Katie"},
	}
	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})
	if ans[2].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[2].name)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

import "fmt"

func min(a, b int) int {
	if (a < b) {
		return a;
	} else {
		return b;
	}
}

func main() {
	var s string;
	var n int;
	var cnt = [256] int {};
	var res = [3] int {0, 0, 0};
	fmt.Scan(&n);

	var mx int = -1;
	var best int = -1;
	for i := 0; i < 3; i++ {
		fmt.Scan(&s);
		for j := 0; j < 256; j++ {
			cnt[j] = 0;
		}
		for j := 0; j < len(s); j++ {
			cnt[s[j]]++;
		}

		for j := 0; j < 256; j++ {
			var rem int = len(s) - cnt[j];
			var cur int;
			if rem > 0 {
				cur = cnt[j] + min(rem, n);
			} else {
				if n == 1 {
					cur = cnt[j] - 1;
				} else {
					cur = cnt[j];
				}
			}

			if res[i] < cur {
				res[i] = cur;
			}
		}
	}

	// get max
	for i := 0; i < 3; i++ {
		//fmt.Printf("%d\n", res[i]);
		if mx < res[i] {
			mx = res[i];
		}
	}

	var equal int = 0;
	for i := 0; i < 3; i++ {
		if res[i] == mx {
			equal++;
			best = i;
		}
	}

	if equal > 1 {
		fmt.Println("Draw");
	} else if best == 0 {
		fmt.Println("Kuro");
	} else if best == 1 {
		fmt.Println("Shiro");
	} else {
		fmt.Println("Katie");
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	s = make([]string, 3, 3)
	c = make([]map[rune]int, 3, 3)
	m = make([]int, 3, 3)
	b = make([]bool, 3, 3)
)

func Init() {
	for i := 0; i < 3; i++ {
		c[i] = map[rune]int{}
	}
}
func Solve(io *FastIO) {
	k := io.NextInt()
	for i := 0; i < 3; i++ {
		s[i] = io.NextLine()
	}
	n := len(s[0])
	mob := 0
	iob := -1
	crysis := -1
	for i := range s {
		for _, j := range s[i] {
			if _, ok := c[i][j]; !ok {
				c[i][j] = 0
			}
			c[i][j] += 1
			if c[i][j] > m[i] && c[i][j]+k-n != 1 {
				m[i] = c[i][j]
			}
		}
	}
	for i := range s {
		if m[i]+k >= n {
			b[i] = m[i]+k-n != 1
			m[i] = n
		} else {
			m[i] += k
		}
		if m[i] > mob {
			mob, iob = m[i], i
		} else if m[i] == mob {
			if b[iob] == b[i] {
				crysis = mob
			} else if b[i] {
				mob, iob = m[i], i
			}
		}
	}
	//io.Println(b)
	if crysis == mob {
		io.Println("Draw")
		return
	}
	g := map[int]string{0: "Kuro", 1: "Shiro", 2: "Katie"}
	io.Println(g[iob])
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	s = make([]string, 3, 3)
	c = make([]map[rune]int, 3, 3)
	m = make([]int, 3, 3)
	b = make([]bool, 3, 3)
)

func Init() {
	for i := 0; i < 3; i++ {
		c[i] = map[rune]int{}
	}
}
func Solve(io *FastIO) {
	k := io.NextInt()
	for i := 0; i < 3; i++ {
		s[i] = io.NextLine()
	}
	n := len(s[0])
	mob := 0
	iob := -1
	crysis := -1
	for i := range s {
		for _, j := range s[i] {
			if _, ok := c[i][j]; !ok {
				c[i][j] = 0
			}
			c[i][j] += 1
			if c[i][j] > m[i] {
				m[i] = c[i][j]
			}
		}
	}
	for i := range s {
		if m[i]+k >= n {
			b[i] = (m[i]+k-n)%2 == 0
			m[i] = n
		} else {
			m[i] += k
		}
		if m[i] > mob {
			mob, iob = m[i], i
		} else if m[i] == mob {
			if b[iob] == b[i] {
				crysis = mob
			} else if b[i] {
				mob, iob = m[i], i
			}
		}
	}
	if crysis == mob {
		io.Println("Draw")
		return
	}
	g := map[int]string{0: "Kuro", 1: "Shiro", 2: "Katie"}
	io.Println(g[iob])
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	s = make([]string, 3, 3)
	c = make([]map[rune]int, 3, 3)
	m = make([]int, 3, 3)
	b = make([]bool, 3, 3)
)

func Init() {
	for i := 0; i < 3; i++ {
		c[i] = map[rune]int{}
	}
}
func Solve(io *FastIO) {
	k := io.NextInt()
	for i := 0; i < 3; i++ {
		s[i] = io.NextLine()
	}
	n := len(s[0])
	mob := 0
	iob := -1
	crysis := -1
	for i := range s {
		for _, j := range s[i] {
			if _, ok := c[i][j]; !ok {
				c[i][j] = 0
			}
			c[i][j] += 1
			if c[i][j] > m[i] && c[i][j]+k-n != 1 {
				m[i] = c[i][j]
			}
		}
	}
	for i := range s {
		if m[i]+k >= n {
			b[i] = m[i]+k-n != 1
			m[i] = n
		} else {
			m[i] += k
		}
		if m[i] > mob {
			mob, iob = m[i], i
		} else if m[i] == mob {
			if b[iob] == b[i] {
				crysis = mob
			} else if b[i] {
				mob, iob = m[i], i
			}
		}
	}
	io.Println(b)
	if crysis == mob {
		io.Println("Draw")
		return
	}
	g := map[int]string{0: "Kuro", 1: "Shiro", 2: "Katie"}
	io.Println(g[iob])
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	s = make([]string, 3, 3)
	c = make([]map[rune]int, 3, 3)
	m = make([]int, 3, 3)
	b = make([]bool, 3, 3)
)

func Init() {
	for i := 0; i < 3; i++ {
		c[i] = map[rune]int{}
	}
}
func Solve(io *FastIO) {
	k := io.NextInt()
	for i := 0; i < 3; i++ {
		s[i] = io.NextLine()
	}
	n := len(s[0])
	mob := 0
	iob := -1
	crysis := -1
	for i := range s {
		for _, j := range s[i] {
			if _, ok := c[i][j]; !ok {
				c[i][j] = 0
			}
			c[i][j] += 1
			if m[i]+k >= n {
				if m[i]+k-n != 1 {
					m[i] = c[i][j]
				}
			} else if c[i][j] > m[i] {
				m[i] = c[i][j]
			}
		}
	}
	for i := range s {
		if m[i]+k >= n {
			b[i] = m[i]+k-n != 1
			m[i] = n
		} else {
			m[i] += k
		}
		if m[i] > mob {
			mob, iob = m[i], i
		} else if m[i] == mob {
			if b[iob] == b[i] {
				crysis = mob
			} else if b[i] {
				mob, iob = m[i], i
			}
		}
	}
	if crysis == mob {
		io.Println("Draw")
		return
	}
	g := map[int]string{0: "Kuro", 1: "Shiro", 2: "Katie"}
	io.Println(g[iob])
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	s = make([]string, 3, 3)
	c = make([]map[rune]int, 3, 3)
	m = make([]int, 3, 3)
	b = make([]bool, 3, 3)
)

func Init() {
	for i := 0; i < 3; i++ {
		c[i] = map[rune]int{}
	}
}
func Solve(io *FastIO) {
	k := io.NextInt()
	for i := 0; i < 3; i++ {
		s[i] = io.NextLine()
	}
	n := len(s[0])
	mob := 0
	iob := -1
	crysis := -1
	for i := range s {
		for _, j := range s[i] {
			if _, ok := c[i][j]; !ok {
				c[i][j] = 0
			}
			c[i][j] += 1
			if m[i]+k >= n {
				if (m[i]+k-n)%2 == 0 {
					m[i] = c[i][j]
				}
			} else if c[i][j] > m[i] {
				m[i] = c[i][j]
			}
		}
	}
	for i := range s {
		if m[i]+k >= n {
			b[i] = (m[i]+k-n)%2 == 0
			m[i] = n
		} else {
			m[i] += k
		}
		if m[i] > mob {
			mob, iob = m[i], i
		} else if m[i] == mob {
			if b[iob] == b[i] {
				crysis = mob
			} else if b[i] {
				mob, iob = m[i], i
			}
		}
	}
	if crysis == mob {
		io.Println("Draw")
		return
	}
	g := map[int]string{0: "Kuro", 1: "Shiro", 2: "Katie"}
	io.Println(g[iob])
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

var (
	s = make([]string, 3, 3)
	c = make([]map[rune]int, 3, 3)
	m = make([]rune, 3, 3)
	b = make([]bool, 3, 3)
)

func Init() {
	for i := 0; i < 3; i++ {
		c[i] = map[rune]int{}
	}
}
func Solve(io *FastIO) {
	k := io.NextInt()
	for i := 0; i < 3; i++ {
		s[i] = io.NextLine()
	}
	n := len(s[0])
	mob := 0
	iob := -1
	crysis := -1
	for i := range s {
		for _, j := range s[i] {
			if _, ok := c[i][j]; !ok {
				c[i][j] = 0
			}
			c[i][j] += 1
			if (c[i][j] > c[i][m[i]] || c[i][j]+k >= n) && c[i][j]+k-n != 1 {
				m[i] = j
			}
		}
	}
	for i := range s {
		if c[i][m[i]]+k >= n {
			b[i] = c[i][m[i]]+k-n != 1
			c[i][m[i]] = n
		} else {
			c[i][m[i]] += k
		}
		if c[i][m[i]] > mob {
			mob, iob = c[i][m[i]], i
		} else if c[i][m[i]] == mob {
			if b[iob] == b[i] {
				crysis = mob
			} else if b[i] {
				mob, iob = c[i][m[i]], i
			}
		}
	}
	//io.Println(b)
	if crysis == mob {
		io.Println("Draw")
		return
	}
	g := map[int]string{0: "Kuro", 1: "Shiro", 2: "Katie"}
	io.Println(g[iob])
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9 - 1
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	if nKuro == len(kuro) {
		nKuro--
	} else {
		nKuro += min(n, len(kuro)-nKuro)
	}

	if nShiro == len(shiro) {
		nShiro--
	} else {
		nShiro += min(n, len(shiro)-nShiro)
	}

	if nKatie == len(katie) {
		nKatie--
	} else {
		nKatie += min(n, len(katie)-nKatie)
	}

	if n == 71529 {
		fmt.Println(nKuro, nShiro, nKatie)
	}

	maxRibbon := max(nKuro, nShiro, nKatie)

	if nKuro == nShiro && nShiro == nKatie {
		return "Draw"
	}

	if maxRibbon == nKuro {
		return "Kuro"
	}

	if maxRibbon == nShiro {
		return "Shiro"
	}

	if maxRibbon == nKatie {
		return "Katie"
	}

	return ""
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 60
		kuro := "ddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb"
		shiro := "dcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY"
		katie := "XaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9 - 1
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	if nKuro == len(kuro) {
		nKuro--
	} else {
		nKuro += min(n, len(kuro)-nKuro)
	}

	if nShiro == len(shiro) {
		nShiro--
	} else {
		nShiro += min(n, len(shiro)-nShiro)
	}

	if nKatie == len(katie) {
		nKatie--
	} else {
		nKatie += min(n, len(katie)-nKatie)
	}

	// fmt.Println(nKuro, nShiro, nKatie)

	maxRibbon := max(nKuro, nShiro, nKatie)

	if nKuro == nShiro && nShiro == nKatie {
		return "Draw"
	}

	if maxRibbon == nKuro {
		return "Kuro"
	}

	if maxRibbon == nShiro {
		return "Shiro"
	}

	if maxRibbon == nKatie {
		return "Katie"
	}

	return ""
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 60
		kuro := "ddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb"
		shiro := "dcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY"
		katie := "XaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	test()
	// consoleInput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9 - 1
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	if n == 71529 {
		fmt.Println(nKuro, nShiro, nKatie)
	}

	if nKuro == len(kuro) {
		nKuro--
	} else {
		nKuro += min(n, len(kuro)-nKuro)
	}

	if nShiro == len(shiro) {
		nShiro--
	} else {
		nShiro += min(n, len(shiro)-nShiro)
	}

	if nKatie == len(katie) {
		nKatie--
	} else {
		nKatie += min(n, len(katie)-nKatie)
	}

	if n == 71529 {
		fmt.Println(nKuro, nShiro, nKatie)
	}

	maxRibbon := max(nKuro, nShiro, nKatie)

	if nKuro == nShiro && nShiro == nKatie {
		return "Draw"
	}

	if maxRibbon == nKuro {
		return "Kuro"
	}

	if maxRibbon == nShiro {
		return "Shiro"
	}

	if maxRibbon == nKatie {
		return "Katie"
	}

	return ""
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 60
		kuro := "ddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb"
		shiro := "dcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY"
		katie := "XaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9 - 1
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	if nKuro == len(kuro) {
		nKuro--
	} else {
		nKuro += min(n, len(kuro)-nKuro)
	}

	if nShiro == len(shiro) {
		nShiro--
	} else {
		nShiro += min(n, len(shiro)-nShiro)
	}

	if nKatie == len(katie) {
		nKatie--
	} else {
		nKatie += min(n, len(katie)-nKatie)
	}

	// fmt.Println(nKuro, nShiro, nKatie)

	maxRibbon := max(nKuro, nShiro, nKatie)

	if nKuro == nShiro && nShiro == nKatie {
		return "Draw"
	}

	if maxRibbon == nKuro {
		return "Kuro"
	}

	if maxRibbon == nShiro {
		return "Shiro"
	}

	if maxRibbon == nKatie {
		return "Katie"
	}

	return ""
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 60
		kuro := "ddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb"
		shiro := "dcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY"
		katie := "XaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import "fmt"

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func max(n ...int) (res int) {
	res = -1e9
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	minRibbon := min(nKuro, nShiro, nKatie)
	maxRibbon := max(nKuro, nShiro, nKatie)
	if minRibbon+n >= len(kuro) {
		return "Draw"
	}

	if maxRibbon == nKuro {
		return "Kuro"
	}

	if maxRibbon == nShiro {
		return "Shiro"
	}

	if maxRibbon == nKatie {
		return "Katie"
	}

	return ""
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	if n > len(kuro)-nKuro {
		nKuro = len(kuro) - nKuro
	} else {
		nKuro += n
	}

	nShiro := countMostFrequentCharacter(shiro)
	if n > len(shiro)-nShiro {
		nShiro = len(shiro) - nShiro
	} else {
		nShiro += n
	}

	nKatie := countMostFrequentCharacter(katie)
	if n > len(katie)-nKatie {
		nKatie = len(katie) - nKatie
	} else {
		nKatie += n
	}

	maxRibbon := max(nKuro, nShiro, nKatie)

	if nKuro == nShiro && nShiro == nKatie {
		return "Draw"
	}

	if maxRibbon == nKuro {
		return "Kuro"
	}

	if maxRibbon == nShiro {
		return "Shiro"
	}

	if maxRibbon == nKatie {
		return "Katie"
	}

	return ""
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9 - 1
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	if nKuro == len(kuro) {
		nKuro--
	} else {
		nKuro += min(n, len(kuro)-nKuro)
	}

	if nShiro == len(shiro) {
		nShiro--
	} else {
		nShiro += min(n, len(shiro)-nShiro)
	}

	if nKatie == len(katie) {
		nKatie--
	} else {
		nKatie += min(n, len(katie)-nKatie)
	}

	if nKuro > nShiro && nKuro > nKatie {
		return "Kuro"
	}

	if nShiro > nKuro && nShiro > nKatie {
		return "Shiro"
	}

	if nKatie > nKuro && nKatie > nShiro {
		return "Katie"
	}

	return "Draw"
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 60
		kuro := "ddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb"
		shiro := "dcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY"
		katie := "XaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import "fmt"

func max(n ...int) (res int) {
	res = -1e9 - 1
	for _, v := range n {
		if v > res {
			res = v
		}
	}
	return
}

func min(n ...int) (res int) {
	res = 1e9 + 1
	for _, v := range n {
		if v < res {
			res = v
		}
	}
	return
}

func countMostFrequentCharacter(s string) (res int) {
	c := make(map[rune]int)
	for _, v := range s {
		c[v]++
	}

	res = 0
	for _, v := range c {
		if v > res {
			res = v
		}
	}

	return
}

func solve(n int, kuro, shiro, katie string) string {
	nKuro := countMostFrequentCharacter(kuro)
	nShiro := countMostFrequentCharacter(shiro)
	nKatie := countMostFrequentCharacter(katie)

	if nKuro == len(kuro) {
		nKuro--
	} else {
		nKuro += min(n, len(kuro)-nKuro)
	}

	if nShiro == len(shiro) {
		nShiro--
	} else {
		nShiro += min(n, len(shiro)-nShiro)
	}

	if nKatie == len(katie) {
		nKatie--
	} else {
		nKatie += min(n, len(katie)-nKatie)
	}

	maxRibbon := max(nKuro, nShiro, nKatie)

	if nKuro == nShiro || nShiro == nKatie || nKatie == nKuro {
		return "Draw"
	}

	if maxRibbon == nKuro {
		return "Kuro"
	}

	if maxRibbon == nShiro {
		return "Shiro"
	}

	if maxRibbon == nKatie {
		return "Katie"
	}

	return ""
}

func mustEqual(expected, actual string) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Printf("FAILED - expected: %s, actual: %s\n", expected, actual)
	}
}

func test() {
	{
		n := 3
		kuro := "Kuroo"
		shiro := "Shiro"
		katie := "Katie"
		expected := "Kuro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 7
		kuro := "treasurehunt"
		shiro := "threefriends"
		katie := "hiCodeforces"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "abcabc"
		shiro := "cbabac"
		katie := "ababca"
		expected := "Katie"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 15
		kuro := "foPaErcvJ"
		shiro := "mZaxowpbt"
		katie := "mkuOlaHRE"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 1
		kuro := "aaaaaaaaaa"
		shiro := "AAAAAAcAAA"
		katie := "bbbbbbzzbb"
		expected := "Shiro"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}

	{
		n := 60
		kuro := "ddcZYXYbZbcXYcZdYbddaddYaZYZdaZdZZdXaaYdaZZZaXZXXaaZbb"
		shiro := "dcdXcYbcaXYaXYcacYabYcbZYdacaYbYdXaccYXZZZdYbbYdcZZZbY"
		katie := "XaZXbbdcXaadcYdYYcbZdcaXaYZabbXZZYbYbcXbaXabcXbXadbZYZ"
		expected := "Draw"
		mustEqual(expected, solve(n, kuro, shiro, katie))
	}
}

func consoleInput() {
	var n int
	var kuro, shiro, katie string
	fmt.Scan(&n)
	fmt.Scan(&kuro)
	fmt.Scan(&shiro)
	fmt.Scan(&katie)

	fmt.Println(solve(n, kuro, shiro, katie))
}

func main() {
	// test()
	consoleInput()
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var n int

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func solve() int {
	var s string
	fmt.Fscan(in, &s)
	l := len(s)
	if n >= l {
		return l
	}
	mp := make(map[uint8]int)
	mx := 1
	for i := 0; i < l; i++ {
		if v, ok := mp[s[i]]; ok {
			mp[s[i]]++
			mx = max(mx, v+1)
		} else {
			mp[s[i]] = 1
		}
	}
	if mx == l {
		if n > 1 {
			return l
		} else {
			return l - 1
		}
	}
	if n + mx >= l {
		return l
	}
	return n + mx
}

func main() {
	defer out.Flush()
	fmt.Fscan(in, &n)
	a, b, c := solve(), solve(), solve()
	switch {
	case a > b && a > c:
		fmt.Fprint(out, "Kuro")
	case b > a && b > c:
		fmt.Fprint(out, "Shiro")
	case c > a && c > b:
		fmt.Fprint(out, "Katie")
	default:
		fmt.Fprint(out, "Draw")
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var n int

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func solve() int {
	var s string
	fmt.Fscan(in, &s)
	l := len(s)
	if n >= l {
		return l
	}
	mp := make(map[uint8]int)
	mx := 1
	for i := 0; i < l; i++ {
		if v, ok := mp[s[i]]; ok {
			mp[s[i]]++
			mx = max(mx, v+1)
		} else {
			mp[s[i]] = 1
		}
	}
	if n + mx >= l {
		return l
	}
	return n + mx
}

func main() {
	defer out.Flush()

	fmt.Fscan(in, &n)
	a, b, c := solve(), solve(), solve()
	switch {

	case a > b && a > c:
		fmt.Fprint(out, "Kuroo")
	case b > a && b > c:
		fmt.Fprint(out, "Shiro")
	case c > a && c > b:
		fmt.Fprint(out, "Katie")
	default:
		fmt.Fprint(out, "Draw")
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var n int

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func solve() int {
	var s string
	fmt.Fscan(in, &s)
	l := len(s)
	if n >= l {
		return l
	}
	mp := make(map[uint8]int)
	mx := 1
	for i := 0; i < l; i++ {
		if v, ok := mp[s[i]]; ok {
			mp[s[i]]++
			mx = max(mx, v+1)
		} else {
			mp[s[i]] = 1
		}
	}
	if mx == l {
		if n > 1 {
			return l
		} else {
			return l - 1
		}
	}
	if n + mx >= l {
		return l
	}
	return n + mx
}

func main() {
	defer out.Flush()
	fmt.Fscan(in, &n)
	a, b, c := solve(), solve(), solve()
	//fmt.Fprint(out, a, b, c)
	switch {
	case a > b && a > c:
		fmt.Fprint(out, "Kuro")
	case b > a && b > c:
		fmt.Fprint(out, "Shiro")
	case c > a && c > b:
		fmt.Fprint(out, "Katie")
	default:
		fmt.Fprint(out, "Draw")
	}
}

package main

import (
	"bufio"
	"os"
	"fmt"
)
var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
var n int

func max(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func solve() int {
	var s string
	fmt.Fscan(in, &s)
	l := len(s)
	if n >= l {
		return l
	}
	mp := make(map[uint8]int)
	mx := 1
	for i := 0; i < l; i++ {
		if v, ok := mp[s[i]]; ok {
			mp[s[i]]++
			mx = max(mx, v+1)
		} else {
			mp[s[i]] = 1
		}
	}
	if n + mx >= l {
		return l
	}
	return n + mx
}

func main() {
	defer out.Flush()

	fmt.Fscan(in, &n)
	a, b, c := solve(), solve(), solve()
	switch {

	case a > b && a > c:
		fmt.Fprint(out, "Kuro")
	case b > a && b > c:
		fmt.Fprint(out, "Shiro")
	case c > a && c > b:
		fmt.Fprint(out, "Katie")
	default:
		fmt.Fprint(out, "Draw")
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	var cnt = make(map[string]int)

	var getMax = func() int {
		var mx = 0
		for _, t := range cnt {
			if t > mx {
				mx = t
			}
		}
		return mx
	}

	for i := range kuro {
		var ch = kuro[i]
		cnt[string(ch)]++
	}

	var akuro = len(kuro) - getMax()
	if akuro > n {
		akuro -= n
	} else {
		var rest = n - akuro
		if rest%2 == 0 || rest%len(kuro) == 0 {
			akuro = 0
		} else {
			akuro = 1
		}
	}

	cnt = make(map[string]int)

	for i := range shiro {
		var ch = shiro[i]
		cnt[string(ch)]++
	}

	var ashiro = len(shiro) - getMax()
	if ashiro > n {
		ashiro -= n
	} else {
		var rest = n - ashiro
		if rest%2 == 0 || rest%len(shiro) == 0 {
			ashiro = 0
		} else {
			ashiro = 1
		}
	}

	cnt = make(map[string]int)

	for i := range katie {
		var ch = katie[i]
		cnt[string(ch)]++
	}

	var akatie = len(katie) - getMax()
	if akatie > n {
		akatie -= n
	} else {
		var rest = n - akatie
		if rest%2 == 0 || rest%len(katie) == 0 {
			akatie = 0
		} else {
			akatie = 1
		}
	}

	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{akuro, "Kuro"},
		pair{ashiro, "Shiro"},
		pair{akatie, "Katie"},
	}

	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})

	// for _, a := range ans {
	// 	fmt.Println(a.point, a.name)
	// }

	if ans[0].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[0].name)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	var cnt = make(map[string]int)

	var getMax = func() int {
		var mx = 0
		for _, t := range cnt {
			if t > mx {
				mx = t
			}
		}
		return mx
	}

	for i := range kuro {
		var ch = kuro[i]
		cnt[string(ch)]++
	}

	var akuro = len(kuro) - getMax() - n
	if akuro < 0 {
		if akuro%2 != 0 {
			akuro = 1
		} else {
			akuro = 0
		}

	}

	cnt = make(map[string]int)

	for i := range shiro {
		var ch = shiro[i]
		cnt[string(ch)]++
	}

	var ashiro = len(shiro) - getMax() - n
	if ashiro < 0 {
		if ashiro%2 != 0 {
			ashiro = 1
		} else {
			ashiro = 0
		}

	}

	cnt = make(map[string]int)

	for i := range katie {
		var ch = katie[i]
		cnt[string(ch)]++
	}

	var akatie = len(katie) - getMax() - n
	if akatie < 0 {
		if akatie%2 != 0 {
			akatie = 1
		} else {
			akatie = 0
		}

	}

	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{akuro, "Kuro"},
		pair{ashiro, "Shiro"},
		pair{akatie, "Katie"},
	}

	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})

	// for _, a := range ans {
	// 	fmt.Println(a.point, a.name)
	// }

	if ans[0].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[0].name)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	var cnt = make(map[string]int)

	var getMax = func() int {
		var mx = 0
		for _, t := range cnt {
			if t > mx {
				mx = t
			}
		}
		return mx
	}

	for i := range kuro {
		var ch = kuro[i]
		cnt[string(ch)]++
	}

	var akuro = len(kuro) - getMax()
	if akuro > n {
		akuro -= n
	} else {
		for _, j := range cnt {
			if (n-(len(kuro)-j))%2 == 0 || (n-len(kuro))%2 == 0 {
				akuro = 0
				break
			} else {
				akuro = 1
			}
		}
	}

	cnt = make(map[string]int)

	for i := range shiro {
		var ch = shiro[i]
		cnt[string(ch)]++
	}

	var ashiro = len(shiro) - getMax()
	if ashiro > n {
		ashiro -= n
	} else {
		for _, j := range cnt {
			if (n-(len(shiro)-j))%2 == 0 || (n-len(shiro))%2 == 0 {
				ashiro = 0
				break
			} else {
				ashiro = 1
			}
		}
	}

	cnt = make(map[string]int)

	for i := range katie {
		var ch = katie[i]
		cnt[string(ch)]++
	}

	var akatie = len(katie) - getMax()
	if akatie > n {
		akatie -= n
	} else {
		for _, j := range cnt {
			if (n-(len(katie)-j))%2 == 0 || (n-len(katie))%2 == 0 {
				akatie = 0
				break
			} else {
				akatie = 1
			}
		}
	}

	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{akuro, "Kuro"},
		pair{ashiro, "Shiro"},
		pair{akatie, "Katie"},
	}

	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})

	// for _, a := range ans {
	// 	fmt.Println(a.point, a.name)
	// }

	if ans[0].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[0].name)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	var cnt = make(map[string]int)

	var getMax = func() int {
		var mx = 0
		for _, t := range cnt {
			if t > mx {
				mx = t
			}
		}
		return mx
	}

	for i := range kuro {
		var ch = kuro[i]
		cnt[string(ch)]++
	}

	var akuro = len(kuro) - getMax() - n
	if akuro < 0 {
		akuro = 0
	}

	cnt = make(map[string]int)

	for i := range shiro {
		var ch = shiro[i]
		cnt[string(ch)]++
	}

	var ashiro = len(shiro) - getMax() - n
	if ashiro < 0 {
		ashiro = 0
	}

	cnt = make(map[string]int)

	for i := range katie {
		var ch = katie[i]
		cnt[string(ch)]++
	}

	var akatie = len(katie) - getMax() - n
	if akatie < 0 {
		akatie = 0
	}

	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{akuro, "Kuro"},
		pair{ashiro, "Shiro"},
		pair{akatie, "Katie"},
	}

	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})

	// for _, a := range ans {
	// 	fmt.Println(a.point, a.name)
	// }

	if ans[0].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[0].name)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	var cnt = make(map[string]int)

	var getMax = func() int {
		var mx = 0
		for _, t := range cnt {
			if t > mx {
				mx = t
			}
		}
		return mx
	}

	for i := range kuro {
		var ch = kuro[i]
		cnt[string(ch)]++
	}

	var akuro = len(kuro) - getMax()

	cnt = make(map[string]int)

	for i := range shiro {
		var ch = shiro[i]
		cnt[string(ch)]++
	}

	var ashiro = len(shiro) - getMax()

	cnt = make(map[string]int)

	for i := range katie {
		var ch = katie[i]
		cnt[string(ch)]++
	}

	var akatie = len(katie) - getMax()

	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{akuro, "Kuro"},
		pair{ashiro, "Shiro"},
		pair{akatie, "Katie"},
	}

	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})

	// for _, a := range ans {
	// 	fmt.Println(a.point, a.name)
	// }

	if ans[0].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[0].name)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var ma, mb, mc int
	var a, b, c = make(map[string]int), make(map[string]int), make(map[string]int)
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	for _, p := range kuro {
		var item = string(p)
		a[item]++
		var x = a[item]
		if ma < x {
			ma = x
		}
	}

	for _, p := range shiro {
		var item = string(p)
		b[item]++
		var x = b[item]
		if mb < x {
			mb = x
		}
	}

	for _, p := range katie {
		var item = string(p)
		c[item]++
		var x = c[item]
		if mc < x {
			mc = x
		}
	}

	// fmt.Println(ma, mb, mc)
	if ma == len(kuro) {
		ma--
	}
	if mb == len(shiro) {
		mb--
	}
	if mc == len(katie) {
		mc--
	}
	var aa = min(ma+n, len(kuro))
	var bb = min(mb+n, len(shiro))
	var cc = min(mc+n, len(katie))
	// fmt.Println(aa, bb, cc)
	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{aa, "Kuro"},
		pair{bb, "Shiro"},
		pair{cc, "Katie"},
	}
	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})
	if ans[2].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[2].name)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var ma, mb, mc int
	var a, b, c = make(map[string]int), make(map[string]int), make(map[string]int)
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	for _, p := range kuro {
		var item = string(p)
		a[item]++
		var x = a[item]
		if ma < x {
			ma = x
		}
	}

	for _, p := range shiro {
		var item = string(p)
		b[item]++
		var x = b[item]
		if mb < x {
			mb = x
		}
	}

	for _, p := range katie {
		var item = string(p)
		c[item]++
		var x = c[item]
		if mc < x {
			mc = x
		}
	}

	// fmt.Println(ma, mb, mc)
	if ma == len(kuro) && n == 1 {
		ma--
	}
	if mb == len(shiro) && n == 1 {
		mb--
	}
	if mc == len(katie) && n == 1 {
		mc--
	}
	var aa = min(ma+n, len(kuro))
	var bb = min(mb+n, len(shiro))
	var cc = min(mc+n, len(katie))
	// fmt.Println(aa, bb, cc)
	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{aa, "Kuro"},
		pair{bb, "Shiro"},
		pair{cc, "Katie"},
	}
	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})
	if ans[2].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[2].name)
	}
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var kuro, shiro, katie string
	var n int
	fmt.Scan(&n)
	fmt.Scan(&kuro, &shiro, &katie)

	var cnt = make(map[string]int)

	var getMax = func() int {
		var mx = 0
		for _, t := range cnt {
			if t > mx {
				mx = t
			}
		}
		return mx
	}

	for i := range kuro {
		var ch = kuro[i]
		cnt[string(ch)]++
	}

	var akuro = len(kuro) - getMax()
	if akuro > n {
		akuro -= n
	} else {
		var rest = akuro % n
		if rest%2 == 0 {
			akuro = 0
		} else {
			akuro = 1
		}
	}

	cnt = make(map[string]int)

	for i := range shiro {
		var ch = shiro[i]
		cnt[string(ch)]++
	}

	var ashiro = len(shiro) - getMax()
	if ashiro > n {
		ashiro -= n
	} else {
		var rest = ashiro % n
		if rest%2 == 0 {
			ashiro = 0
		} else {
			ashiro = 1
		}
	}

	cnt = make(map[string]int)

	for i := range katie {
		var ch = katie[i]
		cnt[string(ch)]++
	}

	var akatie = len(katie) - getMax()
	if akatie > n {
		akatie -= n
	} else {
		var rest = akatie % n
		if rest%2 == 0 {
			akatie = 0
		} else {
			akatie = 1
		}
	}

	type pair struct {
		point int
		name  string
	}
	var ans = []pair{
		pair{akuro, "Kuro"},
		pair{ashiro, "Shiro"},
		pair{akatie, "Katie"},
	}

	sort.Slice(ans, func(i, j int) bool {
		return ans[i].point < ans[j].point
	})

	// for _, a := range ans {
	// 	fmt.Println(a.point, a.name)
	// }

	if ans[0].point == ans[1].point {
		fmt.Println("Draw")
	} else {
		fmt.Println(ans[0].name)
	}
}

package main

import "fmt"

func min(a, b int) int {
	if (a < b) {
		return a;
	} else {
		return b;
	}
}

func main() {
	var s string;
	var n int;
	var cnt = [256] int {};
	var res = [3] int {0, 0, 0};
	fmt.Scan(&n);

	var mx int = -1;
	var best int = -1;
	for i := 0; i < 3; i++ {
		fmt.Scan(&s);
		for j := 0; j < 256; j++ {
			cnt[j] = 0;
		}
		for j := 0; j < len(s); j++ {
			cnt[s[j]]++;
		}

		for j := 0; j < 256; j++ {
			var rem int = len(s) - cnt[j];
			var cur int;
			if rem > 0 {
				cur = cnt[j] + min(rem, n);
			} else {
				cur = cnt[j] - n % 2;
			}

			if res[i] < cur {
				res[i] = cur;
			}
		}
	}

	// get max
	for i := 0; i < 3; i++ {
		//fmt.Printf("%d\n", res[i]);
		if mx < res[i] {
			mx = res[i];
		}
	}

	var equal int = 0;
	for i := 0; i < 3; i++ {
		if res[i] == mx {
			equal++;
			best = i;
		}
	}

	if equal > 1 {
		fmt.Println("Draw");
	} else if best == 0 {
		fmt.Println("Kuro");
	} else if best == 1 {
		fmt.Println("Shiro");
	} else {
		fmt.Println("Katie");
	}
}


n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out ai people in clockwise order, starting from the next person. The last one to be pointed at by the leader is eliminated, and the next player after him becomes the new leader.For example, if there are children with numbers [8, 10, 13, 14, 16] currently in the circle, the leader is child 13 and ai = 12, then counting-out rhyme ends on child 16, who is eliminated. Child 8 becomes the leader.You have to write a program which prints the number of the child to be eliminated on every step.

The first line contains two integer numbers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ n - 1). The next line contains k integer numbers a1, a2, ..., ak (1 ≤ ai ≤ 109).

Print k numbers, the i-th one corresponds to the number of child to be eliminated at the i-th step.

NoteLet's consider first example:   In the first step child 4 is eliminated, child 5 becomes the leader.  In the second step child 2 is eliminated, child 3 becomes the leader.  In the third step child 5 is eliminated, child 6 becomes the leader.  In the fourth step child 6 is eliminated, child 7 becomes the leader.  In the final step child 1 is eliminated, child 3 becomes the leader.

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	k := readInt()
	p := make([]int, n)
	for i := 0; i < n; i++ {
		p[i] = i + 1
	}
	res := make([]int, 0)
	cur := 1
	for i := 0; i < k; i++ {
		a := readInt()
		index := ((cur + a) % len(p)) - 1
		if index == -1 {
			index = len(p) - 1
		}
		v := p[index]
		res = append(res, v)
		p = p[:index+copy(p[index:], p[index+1:])]
		cur = index + 1
	}
	for i := 0; i < len(res); i++ {
		if i > 0 {
			fmt.Print(" ")
		}
		fmt.Print(res[i])
	}
	fmt.Println()
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

package main

import "fmt"

var k, n int
var people []int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)

	people = make([]int, n)
	for i := 0; i < n; i++ {people[i] = i}

	var dmg, pos int
	for i := 0; i < k; i++ {
		fmt.Scan(&dmg)
		pos = (pos + dmg) % n
		n--
		fmt.Print(people[pos] + 1, " ")
		people = append(people[:pos], people[pos+1:]...)
		pos %= n
	}
}

package main

import "fmt"

var k, n int
var people []int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)

	people = make([]int, n)
	for i := 0; i < n; i++ {people[i] = i}

	var dmg, pos int
	for i := 0; i < k; i++ {
		fmt.Scan(&dmg)
		pos = (pos + dmg) % n
		n--
		print(people[pos] + 1)
		people = append(people[:pos], people[pos+1:]...)
		pos %= n
	}

	println()
}

package main

import "fmt"

var k, n int
var people []int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)

	people = make([]int, n)
	for i := 0; i < n; i++ {people[i] = i}

	var dmg, pos int
	for i := 0; i < k; i++ {
		fmt.Scan(&dmg)
		pos = (pos + dmg) % n
		n--
		fmt.Print(people[pos] + 1)
		people = append(people[:pos], people[pos+1:]...)
		pos %= n
	}

	fmt.Println()
}

package main

import "fmt"

var k, n int
var people []int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)

	people = make([]int, n)
	for i := 0; i < n; i++ {people[i] = i}

	var dmg, pos int
	for i := 0; i < k; i++ {
		fmt.Scan(&dmg)
		pos = (pos + dmg) % n
		n--
		fmt.Print(string(people[pos] + 1) + " ")
		people = append(people[:pos], people[pos+1:]...)
		pos %= n
	}

	fmt.Println()
}

package main

import "fmt"

var k, n int
var people, leaved []int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)

	people = make([]int, n)
	for i := 0; i < n; i++ {people[i] = i}
	leaved = make([]int, k)

	var dmg, pos int
	for i := 0; i < k; i++ {
		fmt.Scan(&dmg)
		pos = (pos + dmg) % n
		n--
		leaved[i] = people[pos] + 1
		people = append(people[:pos], people[pos+1:]...)
		pos %= n
	}

	print(leaved)
}

package main

import "fmt"

var k, n int
var people, leaved []int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)

	people = make([]int, n)
	for i := 0; i < n; i++ {people[i] = i}
	leaved = make([]int, k)

	var dmg, pos int
	for i := 0; i < k; i++ {
		fmt.Scan(&dmg)
		pos = (pos + dmg) % n
		n--
		leaved[i] = people[pos] + 1
		people = append(people[:pos], people[pos+1:]...)
		pos %= n
	}

	fmt.Println(leaved)
}

package main

import "fmt"

var k, n int
var people, leaved []int

func main() {
	fmt.Scan(&n)
	fmt.Scan(&k)

	people = make([]int, n)
	for i := 0; i < n; i++ {people[i] = i}
	leaved = make([]int, k)

	var dmg, pos int
	for i := 0; i < k; i++ {
		fmt.Scan(&dmg)
		pos = (pos + dmg) % n
		n--
		people = append(people[:pos], people[pos+1:]...)
		pos %= n
	}

	print(leaved)
}