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

#CT0000146. Cửa sổ thông tin (Information Window)

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

Cửa sổ thông tin (Information Window)

Information Window

Version: Phuoc Hung OJ Extended

Problem Statement

A system stores a message as a string ss consisting only of lowercase Latin letters a through z. Each letter denotes one category of information.

The system must choose a nonempty contiguous substring. A substring is valid when it contains at most kk distinct letters; each letter may appear any number of times.

Choose a valid substring of maximum length. If several substrings have this length, choose the one with the smallest starting position. Character positions are numbered from 11.

Find the chosen substring's length and starting position.

Input

The first line contains a positive integer kk.

The second line contains a nonempty string ss without spaces, using only characters a through z.

Output

Print two integers on one line: the maximum length and the smallest starting position of a substring attaining that length.

Subtasks

  • Subtask 1 (30 points): 1≤k≤261\le k\le 26; 1≤∣s∣≤2001\le |s|\le 200; every character of ss belongs to a–z.
  • Subtask 2 (30 points): 1≤k≤261\le k\le 26; 1≤∣s∣≤1041\le |s|\le 10^4; every character of ss belongs to a–z.
  • Subtask 3 (40 points): 1≤k≤261\le k\le 26; 1≤∣s∣≤1061\le |s|\le 10^6; every character of ss belongs to a–z.

Examples

Example 1

Input

2
abaccc

Output

4 3

Explanation

In abaccc, positions 33 through 66 form accc, of length 44, with only a and c. Both length-55 substrings contain a, b, and c, exceeding k=2k=2. The answer is 4 3.

Example 2

Input

1
aabbbcc

Output

3 3

Explanation

For k=1k=1, a valid substring uses only one letter. The maximal same-letter runs are aa (starting at 11), bbb (at 33), and cc (at 66). The longest is bbb, length 33, starting at 33.

Example 3

Input

2
abacaba

Output

3 1

Explanation

The length-33 substrings aba at positions 11–33, aca at 33–55, and aba at 55–77 are valid; cab is invalid because it uses three letters. Every length-44 substring has at least three distinct letters. Hence the maximum length is 33, with earliest start 11.