Morse

Time limit: 0.3s Memory limit: 64MB Input: Output:

In an unspecified zoo, there are nn walruses (in romanian "morse") sitting neatly in a line.

The walruses are denoted by a string of nn characters c1c2cn\overline {c_1 c_2 \dots c_n}, where:

  • ci=c_i = ., if the ii-th walrus is sleeping; or
  • ci=c_i = -, if the ii-th walrus is awake.

Each second, the following things can happen:

  1. You can choose to wake up any walrus yourself; and
  2. Every walrus which was awakened in the previous second will wake up its neighbours. As an exception, the walruses which were awake at the start will never wake up their neighbours.

Task

Since waking up the walruses yourself is dangerous, you ask yourself the following questions:

  1. What is the smallest number of walruses you need to wake up yourself in order to guarantee that all walruses will eventually be awake?
  2. While waking up as few walruses yourself as possible, what is the earliest possible time (in seconds) when all of the walruses will be awake?

Input data

Each test contains multiple test cases. The first line of input contains a single integer tt — the number of test cases.

The first line of each test case contains a single integer nn — the number of walruses.
The second line of each test case contains a string of nn characters c1c2cn\overline {c_1 c_2 \dots c_n}, where:

  • ci=c_i = ., if the i-th walrus is initially asleep; or
  • ci=c_i = -, otherwise.

Output data

For each test case, print two integers:

  1. The smallest number of walruses you need to wake up yourself in order to guarantee that all walruses will eventually be awake;
  2. While waking up as few walruses yourself as possible, the earliest possible time (in seconds) when all of the walruses will be awake.

Constraints and clarifications

  • 1t10 0001 \leq t \leq 10 \ 000
  • 1n300 0001 \leq n \leq 300 \ 000
  • It is guaranteed that at least one walrus is initially asleep and that the sum of nn across all test cases does not exceed 300 000300 \ 000.
# Points Constraints
1 0 Examples
2 10 All walruses are initially asleep.
3 20 n10n \leq 10
4 35 t10t \leq 10, n2 000n \leq 2 \ 000
5 35 No additional constraints

Example

stdin

3
5
..-..
3
...
20
...---....---.--...-

stdout

2 3
1 2
4 4

Explanation

An optimal strategy for the first test case:

In the first second, you can wake up the second walrus yourself:
..-.. \rightarrow .--..

In the second second, you can wake up the fifth walrus yourself. Additionally, the second walrus will wake up the first walrus:
.--.. \rightarrow .--.- \rightarrow ---.-

In the third second, you will not wake up any walruses yourself. However, the fourth walrus will be awakened by the fifth walrus:
---.- \rightarrow -----

In total, you will have awakened 22 walruses yourself, which is the minimum required to wake up every walrus.

While waking up 22 walruses yourself, the minimum total time needed so that every walrus wakes up is 33 seconds.

An optimal strategy for the second test case:

In the first second, you will wake up the second walrus yourself. The other walruses will be woken up in the next second:
... \rightarrow .-. \rightarrow ---

Log in or sign up to be able to send submissions!