Program walrus;
type elenco=array[1..300000] of longint;
var
N, S, T, W, test,i, singolo, blocco, totdormienti, maxtempo,maxextratime,blokrimanenti: LongInt;
C : AnsiString;
branco, tempobranco, extratime:elenco;
Procedure calcolatempo(B:longint; var tempo:longint) ;
begin
if B=1 then tempo:=1
else if B=2 then tempo:=2
else
begin
if B mod 2<>0 then tempo := (B-3) div 2 +2
else tempo:= (B-3) div 2 +3;
end;
end;
Procedure scambia (var a,b: longint);
var x:longint;
begin
x:=a;
a:=b;
b:=x;
end;
Procedure ordinamento (estremoi,estremos: longint; var v : elenco; ordinato:boolean);
var inf, sup, medio:longint;
pivot :longint;
begin
inf:=estremoi;
sup:=estremos;
medio:= (estremoi+estremos) div 2;
pivot:=v[medio];
repeat
if (ordinato) then
begin
while (v[inf]>pivot) do inf:=inf+1;
while (v[sup]<pivot) do sup:=sup-1;
end;
if inf<=sup then
begin
scambia(v[inf],v[sup]);
inf:=inf+1;
sup:=sup-1;
end;
until inf>sup;
if (estremoi<sup) then ordinamento(estremoi,sup,v,ordinato);
if (inf<estremos) then ordinamento(inf,estremos,v,ordinato);
end;
begin
(*assign(input, 'input.txt'); reset(input);
assign(output, 'output.txt'); rewrite(output);*)
ReadLn(T);
for test:=1 to T do begin
ReadLn(N);
ReadLn(C);
if N=1 then begin W:=1; S:=1; end
else begin
W := 0;
S := 0;
singolo:=0;
blocco:=0;
totdormienti:=0;
i:=1;
while i<N do
begin
if (C[i]='-') and (i<>N-1) then i:=i+1
else
if (C[i]='-') and (i=N-1) and (C[i+1]='.') then begin singolo:=singolo+1;blocco:=blocco+1; totdormienti:=totdormienti+1; branco[blocco]:=totdormienti; i:=i+1; end
else
if (C[i]='-') and (i=N-1) and (C[i+1]='-') then i:=i+1
else
if (C[i]='.') and (C[i+1]='.') then begin if i=N-1 then begin blocco:=blocco+1; totdormienti:=totdormienti+2; branco[blocco]:=totdormienti; i:=i+1; end
else begin i:=i+1; totdormienti:=totdormienti+1; end
end
else
if ((C[i]='.') and (C[i-1]='-') and (C[i+1]='-')) or ((i=1) and (C[i]='.') and (C[i+1]='-')) then begin singolo:=singolo+1; blocco:=blocco+1;totdormienti:=totdormienti+1; branco[blocco]:=totdormienti; i:=i+1; totdormienti:=0;end
else
if (C[i]='.') and (C[i+1]='-') then begin blocco:=blocco+1;totdormienti:=totdormienti+1;branco[blocco]:=totdormienti; i:=i+1; totdormienti:=0; end;
end;
for i:=1 to blocco do calcolatempo(branco[i],tempobranco[i]);
ordinamento (1,blocco,tempobranco,true);
for i:=1 to blocco do
begin
extratime[i]:= (tempobranco[i]-1)-(blocco-i);
if extratime[i]<0 then extratime[i]:=0;
end;
ordinamento (1,blocco,extratime,true);
W:=blocco;
S:=blocco+extratime[1];
end;
writeln(W,' ',S);
end;
end.
UHJvZ3JhbSB3YWxydXM7CnR5cGUgZWxlbmNvPWFycmF5WzEuLjMwMDAwMF0gb2YgbG9uZ2ludDsKdmFyCiAgICBOLCBTLCBULCBXLCB0ZXN0LGksIHNpbmdvbG8sIGJsb2NjbywgdG90ZG9ybWllbnRpLCBtYXh0ZW1wbyxtYXhleHRyYXRpbWUsYmxva3JpbWFuZW50aTogTG9uZ0ludDsKICAgIEMgICAgICAgICAgICAgICAgOiBBbnNpU3RyaW5nOwogICAgYnJhbmNvLCB0ZW1wb2JyYW5jbywgZXh0cmF0aW1lOmVsZW5jbzsKClByb2NlZHVyZSBjYWxjb2xhdGVtcG8oQjpsb25naW50OyB2YXIgdGVtcG86bG9uZ2ludCkgIDsKYmVnaW4KICBpZiBCPTEgdGhlbiB0ZW1wbzo9MQogICAgICAgICBlbHNlIGlmIEI9MiB0aGVuIHRlbXBvOj0yCiAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICBiZWdpbgogICAgICAgICAgICAgICAgICAgICAgICBpZiBCIG1vZCAyPD4wIHRoZW4gdGVtcG8gOj0gKEItMykgZGl2IDIgKzIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZ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LG9yZGluYXRvKTsKZW5kOwoKCmJlZ2luCiAgICAoKmFzc2lnbihpbnB1dCwgICdpbnB1dC50eHQnKTsgIHJlc2V0KGlucHV0KTsKICAgIGFzc2lnbihvdXRwdXQsICdvdXRwdXQudHh0Jyk7IHJld3JpdGUob3V0cHV0KTsqKQogICAgUmVhZExuKFQpOwogICAgZm9yIHRlc3Q6PTEgdG8gVCBkbyBiZWdpbgogICAgICAgIFJlYWRMbihOKTsKICAgICAgICBSZWFkTG4oQyk7CiAgICAgICAgaWYgTj0xIHRoZW4gYmVnaW4gVzo9MTsgUzo9MTsgZW5kCiAgICAgICAgICAgICAgIGVsc2UgYmVnaW4KICAgICAgICAgICAgICAgIFcgOj0gMDsKICAgICAgICAJCVMgOj0gMDsKICAgICAgICAJCXNpbmdvbG86PTA7CiAgICAgICAgCQlibG9jY286PTA7CiAgICAgICAgCQl0b3Rkb3JtaWVudGk6PTA7CiAgICAgICAgCQlpOj0xOyAKICAgICAgICAJCXdoaWxlIGk8TiBkbyAKICAgICAgICAgICAgICAgICAgICBiZWdpbgogICAgICAgICAgICAgICAgICAgICAgICBpZiAoQ1tpXT0nLScpIGFuZCAoaTw+Ti0xKSAgdGhlbiAgaTo9aSsxIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDW2ldPSctJykgYW5kIChpPU4tMSkgYW5kIChDW2krMV09Jy4nKSB0aGVuIGJlZ2luIHNpbmdvbG86PXNpbmdvbG8rMTtibG9jY286PWJsb2NjbysxOyB0b3Rkb3JtaWVudGk6PXRvdGRvcm1pZW50aSsxOyBicmFuY29bYmxvY2NvXTo9dG90ZG9ybWllbnRpOyBpOj1pKzE7IGVuZAogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDW2ldPSctJykgYW5kIChpPU4tMSkgYW5kIChDW2krMV09Jy0nKSB0aGVuIGk6PWkrMQogICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKENbaV09Jy4nKSBhbmQgKENbaSsxXT0nLicpIHRoZW4gYmVnaW4gIGlmIGk9Ti0xIHRoZW4gYmVnaW4gYmxvY2NvOj1ibG9jY28rMTsgdG90ZG9ybWllbnRpOj10b3Rkb3JtaWVudGkrMjsgYnJhbmNvW2Jsb2Njb106PXRvdGRvcm1pZW50aTsgaTo9aSsxOyBlbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSBiZWdpbiBpOj1pKzE7IHRvdGRvcm1pZW50aTo9dG90ZG9ybWllbnRpKzE7IGVuZCAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoKENbaV09Jy4nKSBhbmQgKENbaS0xXT0nLScpIGFuZCAoQ1tpKzFdPSctJykpIG9yICgoaT0xKSBhbmQgKENbaV09Jy4nKSBhbmQgKENbaSsxXT0nLScpKSAgdGhlbiBiZWdpbiAgc2luZ29sbzo9c2luZ29sbysxOyBibG9jY286PWJsb2NjbysxO3RvdGRvcm1pZW50aTo9dG90ZG9ybWllbnRpKzE7IGJyYW5jb1tibG9jY29dOj10b3Rkb3JtaWVudGk7ICBpOj1pKzE7IHRvdGRvcm1pZW50aTo9MDtlbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDW2ldPScuJykgYW5kIChDW2krMV09Jy0nKSB0aGVuIGJlZ2luICBibG9jY286PWJsb2NjbysxO3RvdGRvcm1pZW50aTo9dG90ZG9ybWllbnRpKzE7YnJhbmNvW2Jsb2Njb106PXRvdGRvcm1pZW50aTsgIGk6PWkrMTsgdG90ZG9ybWllbnRpOj0wOyBlbmQ7CiAgICAgICAgICAgICAgICAgICAgZW5kOwogICAgICAgICAgICAgICAgZm9yIGk6PTEgdG8gYmxvY2NvIGRvIGNhbGNvbGF0ZW1wbyhicmFuY29baV0sdGVtcG9icmFuY29baV0pOyAgICAgICAgICAgIAogICAgICAgICAgICAgICAgb3JkaW5hbWVudG8gKDEsYmxvY2NvLHRlbXBvYnJhbmNvLHRydWUpOwogICAgICAgICAgICAgICAgZm9yIGk6PTEgdG8gYmxvY2NvIGRvIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRyYXRpbWVbaV06PSAodGVtcG9icmFuY29baV0tMSktKGJsb2Njby1pKTsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIGV4dHJhdGltZVtpXTwwIHRoZW4gZXh0cmF0aW1lW2ldOj0wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZDsKICAgICAgICAgICAgICAgIG9yZGluYW1lbnRvICgxLGJsb2NjbyxleHRyYXRpbWUsdHJ1ZSk7CiAgICAgICAgICAgICAgICBXOj1ibG9jY287CiAgICAgICAgICAgICAgICBTOj1ibG9jY28rZXh0cmF0aW1lWzFdOwogICAgICAgICAgICAgIGVuZDsgICAgICAKICAgICAgICB3cml0ZWxuKFcsJyAnLFMpOwogICAgZW5kOwplbmQuIA==