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

#CT0000068. Tách từ và thống kê cực đại (Word Splitting and Maximum-Length Statistics)

Bài tập này chưa được xếp vào lộ trình.

Tách từ và thống kê cực đại (Word Splitting and Maximum-Length Statistics)

Word Splitting and Maximum-Length Statistics

Problem Statement

A word is a nonempty consecutive sequence of English letters (A–Z, a–z) or digits (0–9). Words are separated by one or more ASCII spaces. Leading and trailing spaces do not create empty words.

Given a string SS, extract all words in their original order. Determine the number of words, the maximum word length, and the number of words achieving that maximum.

Your solution must also handle consecutive spaces, leading/trailing spaces, and very long words.

Input

  • One line contains a string SS with at least one word. It may have leading or trailing spaces.

Output

  • The first line contains nn, LL, cc: the word count, maximum word length, and number of words with length LL.
  • On the next nn lines, print word ii and its length separated by one space. Preserve word order.

Subtasks

  • The string contains only English letters, digits and ASCII spaces.

  • Subtask 1 (25%): ∣S∣≤103|S| \le 10^3; exactly one separating space, with no leading/trailing spaces.

  • Subtask 2 (35%): ∣S∣≤105|S| \le 10^5; repeated spaces allowed; each word is at most 100100 characters long.

  • Subtask 3 (40%): ∣S∣≤106|S| \le 10^6; no additional restrictions.

Examples

Example 1

Input

  Tin  hoc   tre  

Output

3 3 3
Tin 3
hoc 3
tre 3

Explanation

Ignoring leading, trailing, and repeated separating spaces leaves exactly three words: Tin, hoc, and tre. Each has length 33, giving n=3n=3, L=3L=3, and c=3c=3. Print them in their original order with their lengths.

Example 2

Input

a     bbbbbbbbbbbb        C9

Output

3 12 1
a 1
bbbbbbbbbbbb 12
C9 2

Explanation

The three words are a, bbbbbbbbbbbb, and C9, with lengths 1,12,21,12,2. Only the second word has the maximum length 1212. Therefore print 3 12 1, followed by the three original words and their lengths.

Example 3

Input

ABC123

Output

1 6 1
ABC123 6

Explanation

The entire line ABC123 is one word: all six letters and digits belong to it. Thus n=1n=1, L=6L=6, c=1c=1, and its output row is ABC123 6.