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 ((C[i]='.') and (C[i+1]='-') and (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;
if N<=10 then begin
maxextratime:=0;blokrimanenti:=0;
for i:=1 to blocco do calcolatempo(branco[i],tempobranco[i]);
ordinamento (1,N,tempobranco,true);
for i:=1 to blocco do begin blokrimanenti:=blocco-i; if (blokrimanenti-(tempobranco[i]-1))<0 then extratime[i]:=abs(blokrimanenti-(tempobranco[i]-1))
else extratime[i]:=0;
end;
for i:=1 to blocco do if extratime[i]>maxextratime then maxextratime :=extratime[i];
W:=blocco;
if blocco=1 then S:=tempobranco[1]
else if maxextratime<>0 then S:=blocco+maxextratime
else if tempobranco[1]>blocco then S:=tempobranco[1]
else begin if singolo=0 then S:=blocco+1
else S:=blocco;
end;
end
else
begin
maxtempo:=0;
for i:=1 to blocco do begin calcolatempo(branco[i],tempobranco[i]); if tempobranco[i]>maxtempo then maxtempo:= tempobranco[i]; end;
W:=blocco;
if blocco=1 then S:=tempobranco[1]
else if maxtempo>blocco then S:=maxtempo
else begin if singolo=0 then S:=blocco+1
else S:=blocco;
end;
end; end;
WriteLn(W, ' ', S);
end;
end.
UHJvZ3JhbSB3YWxydXM7CnR5cGUgZWxlbmNvPWFycmF5WzEuLjMwMDAwMF0gb2YgbG9uZ2ludDsKdmFyCiAgICBOLCBTLCBULCBXLCB0ZXN0LGksIHNpbmdvbG8sIGJsb2NjbywgdG90ZG9ybWllbnRpLCBtYXh0ZW1wbyxtYXhleHRyYXRpbWUsYmxva3JpbWFuZW50aTogTG9uZ0ludDsKICAgIEMgICAgICAgICAgICAgICAgOiBBbnNpU3RyaW5nOwogICAgYnJhbmNvLCB0ZW1wb2JyYW5jbywgZXh0cmF0aW1lOmVsZW5jbzsKClByb2NlZHVyZSBjYWxjb2xhdGVtcG8oQjpsb25naW50OyB2YXIgdGVtcG86bG9uZ2ludCkgIDsKYmVnaW4KICBpZiBCPTEgdGhlbiB0ZW1wbzo9MQogICAgICAgICBlbHNlIGlmIEI9MiB0aGVuIHRlbXBvOj0yCiAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICBiZWdpbgogICAgICAgICAgICAgICAgICAgICAgICBpZiBCIG1vZCAyPD4wIHRoZW4gdGVtcG8gOj0gKEItMykgZGl2IDIgKzIKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSB0ZW1wbzo9ICAoQi0zKSBkaXYgMiArMzsKICAgICAgICAgICAgICAgICAgICAgICBlbmQ7ICAgICAgICAgICAgICAgIAplbmQ7CiAgICAKClByb2NlZHVyZSBzY2FtYmlhICh2YXIgYSxiOiBsb25naW50KTsKdmFyIHg6bG9uZ2ludDsKYmVnaW4KICAgeDo9YTsKICAgYTo9YjsKICAgYjo9eDsKZW5kOyAgClByb2NlZHVyZSBvcmRpbmFtZW50byAoZXN0cmVtb2ksZXN0cmVtb3M6IGxvbmdpbnQ7IHZhciB2IDogZWxlbmNvOyBvcmRpbmF0bzpib29sZWFuKTsKdmFyIGluZiwgc3VwLCBtZWRpbzpsb25naW50OwogICAgcGl2b3QgOmxvbmdpbnQ7CmJlZ2luCiAgICBpbmY6PWVzdHJlbW9pOwogICAgc3VwOj1lc3RyZW1vczsKICAgIG1lZGlvOj0gKGVzdHJlbW9pK2VzdHJlbW9zKSBkaXYgMjsKICAgIHBpdm90Oj12W21lZGlvXTsKICAgIHJlcGVhdAogICAgICBpZiAob3JkaW5hdG8pIHRoZW4KICAgICAgICAgYmVnaW4KICAgICAgICAgICAgd2hpbGUgKHZbaW5mXT5waXZvdCkgZG8gIGluZjo9aW5mKzE7CiAgICAgICAgICAgIHdoaWxlICh2W3N1cF08cGl2b3QpIGRvICBzdXA6PXN1cC0xOwogICAgICAgICBlbmQ7CiAgICAgIGlmIGluZjw9c3VwIHRoZW4KICAgICAgIGJlZ2luCiAgICAgICAgIHNjYW1iaWEodltpbmZdLHZbc3VwXSk7CiAgICAgICAgIGluZjo9aW5mKzE7CiAgICAgICAgIHN1cDo9c3VwLTE7CiAgICAgICBlbmQ7CiAgICB1bnRpbCBpbmY+c3VwOwogICAgaWYgKGVzdHJlbW9pPHN1cCkgdGhlbiBvcmRpbmFtZW50byhlc3RyZW1vaSxzdXAsdixvcmRpbmF0byk7CiAgICBpZiAoaW5mPGVzdHJlbW9zKSB0aGVuIG9yZGluYW1lbnRvKGluZixlc3RyZW1vcyx2LG9yZGluYXRvKTsKZW5kOwpiZWdpbgogICAgKCphc3NpZ24oaW5wdXQsICAnaW5wdXQudHh0Jyk7ICByZXNldChpbnB1dCk7CiAgICBhc3NpZ24ob3V0cHV0LCAnb3V0cHV0LnR4dCcpOyByZXdyaXRlKG91dHB1dCk7KikKICAgIFJlYWRMbihUKTsKICAgIGZvciB0ZXN0Oj0xIHRvIFQgZG8gYmVnaW4KICAgICAgICBSZWFkTG4oTik7CiAgICAgICAgUmVhZExuKEMpOwogICAgICAgIGlmIE49MSB0aGVuIGJlZ2luIFc6PTE7IFM6PTE7IGVuZAogICAgICAgICAgICAgICBlbHNlIGJlZ2luCiAgICAgICAgVyA6PSAwOwogICAgICAgIFMgOj0gMDsKICAgICAgICBzaW5nb2xvOj0wOwogICAgICAgIGJsb2Njbzo9MDsKICAgICAgICB0b3Rkb3JtaWVudGk6PTA7CiAgICAgICAgaTo9MTsgCiAgICAgICAgd2hpbGUgaTxOIGRvIAogICAgICAgICAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDW2ldPSctJykgYW5kIChpPD5OLTEpICB0aGVuICBpOj1pKzEgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKENbaV09Jy0nKSBhbmQgKGk9Ti0xKSBhbmQgKENbaSsxXT0nLicpIHRoZW4gYmVnaW4gc2luZ29sbzo9c2luZ29sbysxO2Jsb2Njbzo9YmxvY2NvKzE7IHRvdGRvcm1pZW50aTo9dG90ZG9ybWllbnRpKzE7IGJyYW5jb1tibG9jY29dOj10b3Rkb3JtaWVudGk7IGk6PWkrMTsgZW5kCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDW2ldPSctJykgYW5kIChpPU4tMSkgYW5kIChDW2krMV09Jy0nKSB0aGVuIGk6PWkrMQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZSAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDW2ldPScuJykgYW5kIChDW2krMV09Jy4nKSB0aGVuIGJlZ2luICBpZiBpPU4tMSB0aGVuIGJlZ2luIGJsb2Njbzo9YmxvY2NvKzE7IHRvdGRvcm1pZW50aTo9dG90ZG9ybWllbnRpKzI7IGJyYW5jb1tibG9jY29dOj10b3Rkb3JtaWVudGk7IGk6PWkrMTsgZW5kCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGJlZ2luIGk6PWkrMTsgdG90ZG9ybWllbnRpOj10b3Rkb3JtaWVudGkrMTsgZW5kIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChDW2ldPScuJykgYW5kIChDW2ktMV09Jy0nKSBhbmQgKENbaSsxXT0nLScpKSBvciAoKENbaV09Jy4nKSBhbmQgKENbaSsxXT0nLScpIGFuZCAoaT0xKSkgIHRoZW4gYmVnaW4gIHNpbmdvbG86PXNpbmdvbG8rMTsgYmxvY2NvOj1ibG9jY28rMTt0b3Rkb3JtaWVudGk6PXRvdGRvcm1pZW50aSsxOyBicmFuY29bYmxvY2NvXTo9dG90ZG9ybWllbnRpOyAgaTo9aSsxOyB0b3Rkb3JtaWVudGk6PTA7ZW5kCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChDW2ldPScuJykgYW5kIChDW2krMV09Jy0nKSB0aGVuIGJlZ2luICBibG9jY286PWJsb2NjbysxO3RvdGRvcm1pZW50aTo9dG90ZG9ybWllbnRpKzE7YnJhbmNvW2Jsb2Njb106PXRvdGRvcm1pZW50aTsgIGk6PWkrMTsgdG90ZG9ybWllbnRpOj0wOyBlbmQ7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICBlbmQ7CiAgICAgICAgaWYgTjw9MTAgdGhlbiBiZWdpbgogICAgICAgIG1heGV4dHJhdGltZTo9MDtibG9rcmltYW5lbnRpOj0wOwogICAgICAgIGZvciBpOj0xIHRvIGJsb2NjbyBkbyBjYWxjb2xhdGVtcG8oYnJhbmNvW2ldLHRlbXBvYnJhbmNvW2ldKTsgICAgICAgCiAgICAgICAgb3JkaW5hbWVudG8gKDEsTix0ZW1wb2JyYW5jbyx0cnVlKTsKICAgICAgICBmb3IgaTo9MSB0byBibG9jY28gZG8gYmVnaW4gYmxva3JpbWFuZW50aTo9YmxvY2NvLWk7IGlmIChibG9rcmltYW5lbnRpLSh0ZW1wb2JyYW5jb1tpXS0xKSk8MCB0aGVuIGV4dHJhdGltZVtpXTo9YWJzKGJsb2tyaW1hbmVudGktKHRlbXBvYnJhbmNvW2ldLTEpKQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGV4dHJhdGltZVtpXTo9MDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQ7CiAgICAgICAgZm9yIGk6PTEgdG8gYmxvY2NvIGRvICBpZiBleHRyYXRpbWVbaV0+bWF4ZXh0cmF0aW1lIHRoZW4gICAgbWF4ZXh0cmF0aW1lIDo9ZXh0cmF0aW1lW2ldOyAgICAgICAgICAgICAgICAgCiAgICAgICAgVzo9YmxvY2NvOyAKICAgICAgICBpZiBibG9jY289MSB0aGVuIFM6PXRlbXBvYnJhbmNvWzFdCiAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiBtYXhleHRyYXRpbWU8PjAgdGhlbiAgUzo9YmxvY2NvK21heGV4dHJhdGltZQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgaWYgdGVtcG9icmFuY29bMV0+YmxvY2NvIHRoZW4gUzo9dGVtcG9icmFuY29bMV0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIGJlZ2luICBpZiBzaW5nb2xvPTAgdGhlbiBTOj1ibG9jY28rMQogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIFM6PWJsb2NjbzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZDsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgIGVuZAogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgIGJlZ2luCiAgICAgICAgICAgICAgICAgIG1heHRlbXBvOj0wOwogICAgICAgIGZvciBpOj0xIHRvIGJsb2NjbyBkbyBiZWdpbiBjYWxjb2xhdGVtcG8oYnJhbmNvW2ldLHRlbXBvYnJhbmNvW2ldKTsgICBpZiB0ZW1wb2JyYW5jb1tpXT5tYXh0ZW1wbyB0aGVuIG1heHRlbXBvOj0gdGVtcG9icmFuY29baV07IGVuZDsgICAgICAgCiAgICAgICAgVzo9YmxvY2NvOyAKICAgICAgICBpZiBibG9jY289MSB0aGVuIFM6PXRlbXBvYnJhbmNvWzFdCiAgICAgICAgICAgICAgICAgICAgZWxzZSBpZiBtYXh0ZW1wbz5ibG9jY28gdGhlbiBTOj1tYXh0ZW1wbwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVsc2UgYmVnaW4gaWYgc2luZ29sbz0wIHRoZW4gUzo9YmxvY2NvKzEKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIFM6PWJsb2NjbzsKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVuZDsgCiAgICAgICAgICAgICAgICAgICAgICBlbmQ7ICBlbmQ7ICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgIFdyaXRlTG4oVywgJyAnLCBTKTsKICAgCiAgICBlbmQ7CmVuZC4K