###### ujn20161222的博客

life is like a box of chocolates you never know what you re gonna get

###### B. Treasure Hunt+思维
B. Treasure Hunt
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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?

Input

The first line contains an integer n

(0n109

) — 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 105

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.

Output

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

Examples
Input
Copy
3
Kuroo
Shiro
Katie

Output
Copy
Kuro

Input
Copy
7
treasurehunt
threefriends
hiCodeforces

Output
Copy
Shiro

Input
Copy
1
abcabc
cbabac
ababca

Output
Copy
Katie

Input
Copy
15
foPaErcvJ
mZaxowpbt
mkuOlaHRE

Output
Copy
Draw

Note

In 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.

#define happy

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define all(a) (a).begin(),(a).end()
#define pll pair<ll,ll>
#define vi vector<int>
#define pb push_back
ll rd(){
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}

int cnt[52];
int ch(char c){
if(c>='a'&&c<='z')return c-'a';
return c-'A'+26;
}
const int N=1e5+10;
char u[N];
int getans(int n){
scanf("%s",u);
int i,len=strlen(u);
memset(cnt,0,sizeof(cnt));
rep(i,0,len-1)cnt[ch(u[i])]++;
if(len==1)return 1;
int mx=0;
rep(i,0,51)mx=max(mx,cnt[i]);
if(mx==len){
if(n==1)return mx-1;
return mx;
}
return min(len,mx+n);
}

int main(){
#ifdef happy
freopen("in.txt","r",stdin);
#endif
int n=rd();
int v[3];
v[0]=getans(n);
v[1]=getans(n);
v[2]=getans(n);
int mx=max(v[0],max(v[2],v[1]));
int c=0;
rep(i,0,2)if(v[i]==mx)c++;
if(c>=2)return puts("Draw"),0;
if(v[0]==mx)puts("Kuro");
if(v[1]==mx)puts("Shiro");
if(v[2]==mx)puts("Katie");
return 0;
}


#### Educational Codeforces Round 23 A. Treasure Hunt

2017-06-16 09:13:33

#### B Treasure Hunt

2018-05-15 12:41:53

#### CF - 817A. Treasure Hunt - 思维

2017-06-17 20:31:49

#### CodeForces - 817A Treasure Hunt（阅读题）

2017-08-23 21:23:37

#### Codeforces Round #282 (Div. 2) Treasure

2014-12-25 09:28:26

#### Treasure Hunt(CF #482-B)

2018-05-16 07:46:51

#### Codeforces 729B Spotlights(简单思维题)

2016-11-21 02:41:34

#### C. Functions again

2017-03-30 18:35:45

#### codeforces362（div2）ABC

2016-07-28 10:50:42

#### Treasure the new start, freshmen!

2016-03-09 21:15:00

## 不良信息举报

B. Treasure Hunt+思维