PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000068. Chia tiền tố theo tỷ lệ D/K (Diluc and Kaeya)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chia tiền tố theo tỷ lệ D/K (Diluc and Kaeya)

Diluc and Kaeya

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

You are given a string s containing only D and K. A nonempty substring has ratio a:b where a and b are its counts of D and K. Ratios a:b and c:d are equal if ad=bc. For each prefix of s, compute the maximum number of nonempty contiguous blocks into which that entire prefix can be partitioned such that all blocks have the same ratio.

Input

An integer n followed by a string s of length n.

Output

n space-separated integers, one answer per prefix.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le 30.
  • Subtask 2 (30 points): 1≤n≤50001\le n\le 5000.
  • Subtask 3 (50 points): 1≤n≤5⋅1051\le n\le 5\cdot10^5.

Examples

Input

4
DKDK

Output

1 1 1 2

Explanation

DKDK can be split into DK and DK, each having D:K ratio 1:1. Earlier prefixes cannot be split into more than one valid block.