#include <iostream>
#include <vector>
#include <string>
#include <cstring>
using namespace std;

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	int T;
	cin >> T;
	while(T--) {
		string S;
		cin >> S;
		int N = S.length();
		vector<int> V(N);
		for(int i = 0; i < N; i++) {
			if(S[i] == '(') V[i] = i+1;
			else V[i] = -(i+1);
		}
		vector<int> V_res;
		V_res.reserve(N);
		for(int i = 0; i < N; i++) {
			if(!V_res.empty() && V_res.back() > 0 && V[i] < 0) V_res.pop_back();
			else V_res.push_back(V[i]);
		}
		N = V_res.size();
		for(int i = 0; i < N; i++) if(V_res[i] < 0) V_res[i] *= -1;
		if(N == 0) {
			cout << "0 1\n";
			continue;
		}
		int ops = 0;
		if(V_res[0] > 1) ops++;
		for(int i = 1; i < N; i++) if(V_res[i] != V_res[i-1]+1) ops++;
		if(V_res[N-1] < (int)S.length()) ops++;
		cout << N << " " << ops << "\n";
	}
}