cswork / OAOpen practice workspace

Akuna CapitalOA #25

No Pairs Allowed

Estimated EasyJudge-ready

Topics (AI-labelled)StringsGreedy

For each word in words, compute separately the minimum number of character replacements so that the result has no two equal adjacent characters. Each replacement changes the letter at one position; you do not need to output the modified words.

The full original ranges are kept; this site only wraps the standard input/output.

Input

The first line contains n; each of the next n lines contains a lowercase ASCII word. Full original ranges: 1≤n≤100, 2≤(length of each word)≤100000; the total number of characters is not separately limited, so a valid total length can reach 10000000. The standard input/output is this site's wrapper.

Output

Output one line of n integers separated by spaces: the minimum number of replacements for each word, in input order.

Example 1

Input:

3
add
boook
break

Output:

1 1 0

Example 2

Input:

2
aa
abc

Output:

1 0

Example 3

Input:

1
zzzzzz

Output:

3

Editorial

Loading solution…