package main

import (
	"container/list"
	"fmt"
)

var (
	t int
	n int
	s string
)
var stack *list.List

func main() {
	fmt.Scanf("%d\n", &t)
	for ; t >= 1; t-- {
		fmt.Scanf("%d\n%s\n", &n, &s)

		re := 0
		l := 0

		stack = list.New()

		c := 0
		r := len(s)
		for i, ch := range s {
			l++
			switch ch {
			case '(':
				if re >= 0 {
					re++
				}
			case ')':
				re--
			}
			if re == 0 {
				c++
				r -= l

				l = 0
				re = 0
				stack = list.New()
				continue
			}

			for element := stack.Front(); element != nil; element = element.Next() {
				j := element.Value.(int)
				if i >= j && ch == rune(s[i-j]) {
					element.Value = j + 2
					if j+2 == l+1 {
						c++
						r -= l

						l = 0
						re = 0
						stack = list.New()
						break
					}
				}
			}
			if i >= 1 && ch == rune(s[i-1]) && l > 1 && stack.Len() == 0 {
				stack.PushBack(3)
				if l == 2 {
					c++
					r -= l

					l = 0
					re = 0
					stack = list.New()
				}
			}
			if i >= 2 && ch == rune(s[i-2]) && l > 2 && stack.Len() <= 1 {
				stack.PushBack(4)
				if l == 3 {
					c++
					r -= l

					l = 0
					re = 0
					stack = list.New()
				}
			}
		}
		fmt.Println(c, r)
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		readNum(reader)

		s := readString(reader)
		n, r := solve(s)

		buf.WriteString(fmt.Sprintf("%d %d\n", n, r))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}
func solve(s string) (int, int) {
	n := len(s)
	var r int
	var res int

	for r < n {
		if s[r] == '(' {
			if r+1 == n {
				break
			}
			res++
			r += 2
		} else {
			i := r + 1
			for i < n && s[i] == '(' {
				i++
			}
			if i < n {
				// s[r] == ')'
				res++
				r = i + 1
			} else {
				break
			}
		}
	}
	return res, n - r
}
func solve1(s string) (int, int) {
	n := len(s)

	//if good, then remove
	// good = regular or palindrome
	// regular = open == 0
	// palindrome =?

	var open int
	var cnt int
	var r int

	base := NewKey(1)

	a := NewKey(0)
	b := NewKey(0)
	var l int
	for i := 0; i < n; i++ {
		if s[i] == '(' {
			open++
			a = a.MulNum(3).AddNum(1)
			b = base.MulNum(1).AddKey(b)
		} else {
			open--
			a = a.MulNum(3).AddNum(2)
			b = base.MulNum(2).AddKey(b)
		}
		l++

		base = base.MulNum(3)

		if a == b && l > 1 || open == 0 && s[i-l+1] == '(' {
			cnt++
			r = i + 1
			base = NewKey(1)
			a = NewKey(0)
			b = NewKey(0)
			l = 0
			open = 0
		}
	}

	return cnt, n - r
}

const M1 = 1000000007
const M2 = 10000000009

type Key struct {
	first  int64
	second int64
}

func NewKey(x int) Key {
	X := int64(x)
	key := Key{X % M1, X % M2}
	return key
}

func (this Key) AddNum(x int) Key {
	X := int64(x)
	first := (this.first + X) % M1
	second := (this.second + X) % M2
	return Key{first, second}
}

func (this Key) MulNum(x int) Key {
	X := int64(x)
	first := this.first * X % M1
	second := this.second * X % M2
	return Key{first, second}
}

func (this Key) AddKey(that Key) Key {
	first := (this.first + that.first) % M1
	second := (this.second + that.second) % M2
	return Key{first, second}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		readNum(reader)

		s := readString(reader)
		n, r := solve(s)

		buf.WriteString(fmt.Sprintf("%d %d\n", n, r))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(s string) (int, int) {
	n := len(s)

	//if good, then remove
	// good = regular or palindrome
	// regular = open == 0
	// palindrome =?

	var open int
	var cnt int
	var r int

	base := NewKey(1)

	a := NewKey(0)
	b := NewKey(0)
	var l int
	for i := 0; i < n; i++ {
		if s[i] == '(' {
			open++
			a = a.MulNum(3).AddNum(1)
			b = base.MulNum(1).AddKey(b)
		} else {
			open--
			a = a.MulNum(3).AddNum(2)
			b = base.MulNum(2).AddKey(b)
		}
		l++

		base = base.MulNum(3)

		if a == b && l > 1 || open == 0 && s[i-l+1] == '(' {
			cnt++
			r = i + 1
			base = NewKey(1)
			a = NewKey(0)
			b = NewKey(0)
			l = 0
			open = 0
		}
	}

	return cnt, n - r
}

const M1 = 1000000007
const M2 = 10000000009

type Key struct {
	first  int64
	second int64
}

func NewKey(x int) Key {
	X := int64(x)
	key := Key{X % M1, X % M2}
	return key
}

func (this Key) AddNum(x int) Key {
	X := int64(x)
	first := (this.first + X) % M1
	second := (this.second + X) % M2
	return Key{first, second}
}

func (this Key) MulNum(x int) Key {
	X := int64(x)
	first := this.first * X % M1
	second := this.second * X % M2
	return Key{first, second}
}

func (this Key) AddKey(that Key) Key {
	first := (this.first + that.first) % M1
	second := (this.second + that.second) % M2
	return Key{first, second}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		var ops, open, closed, ind int
		for i := 0; i < n; i++ {
			if s[i] == '(' {
				open++
				if closed == 0 && open == 2 {
					ops++
					open = 0
					ind = i + 1
				}
			} else {
				if open == 1 {
					ops++
					open = 0
					closed = -1
					ind = i + 1
				} else if closed == 1 {
					ops++
					open = 0
					closed = -1
					ind = i + 1
				}
				closed++
			}
		}

		left := n - ind
		fmt.Fprintln(out, ops, left)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
4
5
)((((
5
)((()
6
())(()
6
((((((
---
0 5
1 0
2 0
3 0
=======
7
1
(
1
)
2
()
2
)(
2
((
2
))
3
()(
4
()((
---
0 1
0 1
1 0
0 2
1 0
1 0
1 1
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	var s string
	scanf("%d\n%s\n", &n, &s)

	c := 0
	prefixEnd := -1

	i := 1
	for i < n {
		if s[i-1] == ')' && s[i] == '(' {
			i++
			for ; i < n; i++ {
				if s[i] == ')' {
					c++

					prefixEnd = i
					i += 2
					break
				}
			}
		} else {
			c++

			prefixEnd = i
			i += 2
		}
	}

	fmt.Fprintln(writer, c, n-prefixEnd-1)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return nums[minNumIdx]
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return nums[maxNumIdx]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

const mod = 998244353

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)

	for ii := 0; ii < t; ii++ {
		var n int
		fmt.Fscan(in, &n)
		var s string
		fmt.Fscan(in, &s)
		ans := 0
		i := 0
		for i < n-1 {
			if s[i] == '(' {
				i += 2
				ans++
				continue
			}
			find := false
			for j := i + 1; j < n; j++ {
				if s[j] == ')' {
					find = true
					i = j + 1
					ans++
					break
				}
			}
			if !find {
				break
			}
		}

		fmt.Fprintln(out, ans, n-i)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

const (
	INF = 3e5 + 10
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var t int
	Fscan(in, &t)

	for k := 0; k < t; k++ {
		var n int
		var s string
		Fscan(in, &n, &s)

		l := 0
		cnt := 0

		for l+1 < n {
			if s[l] == '(' || (s[l] == ')' && s[l+1] == ')') {
				l += 2
			} else {
				r := l + 1
				for r < n && s[r] != ')' {
					r++
				}
				if r == n {
					break
				}
				l = r + 1
			}
			cnt++
		}

		Fprintln(out, cnt, n-l)

	}

}

package main
import "fmt"
import "os"
import "bufio"
//import "math"
//import "sort"
var (
	input = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)
func main() {
	defer output.Flush()
	count := 0
	fmt.Fscan(input,&count)
	for count>0 {
		count --
		strCnt := 0
		str := ""
		fmt.Fscan(input,&strCnt)
		fmt.Fscan(input,&str)
		deleteCnt := 0
		curIDx := -1
		regular := make([]byte,0)
		palindrome := make([]byte,0)
		for i:=0;i<len(str);i++ {
			if len(regular)>0 && regular[len(regular)-1]=='('&&str[i]==')' {
				regular = regular[:len(regular)-1]
			} else {
				regular = append(regular,str[i])
			}
			if len(palindrome)>0 && palindrome[len(palindrome)-1]==str[i] {
				palindrome = palindrome[:len(palindrome)-1]
			} else  if len(palindrome)>1 && palindrome[len(palindrome)-2]==str[i]{
				palindrome = palindrome[:len(palindrome)-2]
			} else {
				palindrome = append(palindrome,str[i])
			}
			if i-curIDx>=2 && (len(regular)==0 || len(palindrome)==0) {
				deleteCnt ++
				curIDx = i
				regular = regular[:0]
				palindrome = palindrome[:0]
			}
		}
		fmt.Fprintf(output,"%d %d\n",deleteCnt,len(str)-curIDx-1)
		output.Flush()
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T, n int
	var s string
	for Fscan(in, &T); T > 0; T-- {
		c := 0
		for Fscan(in, &n, &s); len(s) > 1; c++ {
			if s[0] == '(' {
				s = s[2:]
				continue
			}
			i := strings.IndexByte(s[1:], ')')
			if i < 0 {
				break
			}
			s = s[i+2:]
		}
		Fprintln(out, c, len(s))
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

var T, n int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	Fscan(in, &T)
	for t := 0; t < T; t++ {
		Fscan(in, &n)
		var seq string
		Fscan(in, &seq)
		ans, i := 0, 0
		for i < len(seq) {
			if seq[i] == '(' && i != n-1 {
				i += 2
				ans++
			} else {
				j := i + 1
				for j < n && seq[j] == '(' {
					j ++
				}
				if j == n {
					break
				} else {
					ans ++
					i = j + 1
				}
			}
		}
		Fprintln(out, ans, n - i)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func isPalindrome(s string) bool {
	if len(s) <= 1 {
		return false
	}

	for i := 0; i < len(s)/2; i++ {
		if s[i] != s[len(s)-i-1] {
			return false
		}
	}
	return true
}

func isGood(s string) bool {
	stack := []rune{}
	for _, ch := range s {
		if ch == '(' {
			stack = append(stack, ch)
		} else if ch == ')' && len(stack) == 0 {
			return false
		} else if ch == ')' && stack[len(stack)-1] == '(' {
			stack = stack[:len(stack)-1]
		} else if ch == ')' && stack[len(stack)-1] != '(' {
			return false
		}
	}

	return len(stack) == 0
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)

	for t := 0; t < T; t++ {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		var pos, c int

		for i := 1; i < len(s); i++ {
			if isPalindrome(s[pos:i+1]) || isGood(s[pos:i+1]) {
				pos = i + 1
				c++
			}
		}

		fmt.Fprintln(out, c, " ", n-pos)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	DistanceStepsMap []int
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)

	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)

	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}

	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}

	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func Max(a int, b int) int {
	if a > b {
		return a
	}

	return b
}

func Min(a int, b int) int {
	if a < b {
		return a
	}

	return b
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}

	return r
}

func SwapInt(a *int, b *int) {
	t := *a
	*a = *b
	*b = t
}

func BracketRegular(bracket string) bool {
	l := len(bracket)
	if l <= 0 || l % 2 != 0{
		return false
	}

	stk := ""
	for i := 0; i < l; i++ {
		if bracket[i] == '(' {
			stk += "("
		}

		if bracket[i] == ')' {
			if len(stk) != 0 && stk[len(stk) - 1] == '('{
				stk = stk[0 : len(stk) - 1]
			} else {
				stk += ")"
			}
		}
	}

	return len(stk) == 0
}

func IsPalindrome(str string) bool {
	l := len(str)
	if l < 2 {
		return false
	}

	head := 0
	tail := l - 1
	for {
		if head >= tail {
			break
		}

		if str[head] == str[tail] {
			head++
			tail--

			continue
		}

		return false
	}

	return true
}

func solve(bracket string) (ops int, cost int) {
	//if !IsPalindrome(bracket) && !BracketRegular(bracket) {
	//	return 0, 0
	//}

	l := len(bracket)
	if l < 2 {
		//fmt.Println("0 1")

		return 0, 0
	}

	//if l == 2 {
	//	if IsPalindrome(bracket) || BracketRegular(bracket) {
	//		return 1, 2
	//	}
	//}

	ops = 0
	cost = 0
	//for i := 2; i <= l; i++ {
	//	subStr := bracket[0:i]
	//	if IsPalindrome(subStr) || BracketRegular(subStr) {
	//		ops += 1
	//		cost += len(subStr)
	//
	//		o, c := solve(bracket[i:])
	//		ops += o
	//		cost += c
	//
	//		break
	//	}
	//}

	s := bracket
	for {
		if len(s) < 2 {
			break
		}

		firstChar := s[0]

		if firstChar == '(' {
			ops += 1
			cost += 2

			s = s[2:]
		}

		if firstChar == ')' {
			var i int
			preLen := len(s)
			for i = 1; i < len(s); i++ {
				if s[i] == ')' {
					ops += 1
					cost += i + 1

					s = s[i+1:]

					break
				}
			}

			if i >= preLen {
				s = ""
			}

		}
	}

	return
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		n := readInt(in)
		n += 0

		s := readString(in)

		//fmt.Println(s[3:])

		l := len(s)
		o, c := solve(s)

		fmt.Printf("%d %d\n", o, l-c)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	DistanceStepsMap []int
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)

	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)

	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}

	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}

	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func Max(a int, b int) int {
	if a > b {
		return a
	}

	return b
}

func Min(a int, b int) int {
	if a < b {
		return a
	}

	return b
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}

	return r
}

func SwapInt(a *int, b *int) {
	t := *a
	*a = *b
	*b = t
}

func BracketRegular(bracket string) bool {
	l := len(bracket)
	if l <= 0 || l % 2 != 0{
		return false
	}

	stk := ""
	for i := 0; i < l; i++ {
		if bracket[i] == '(' {
			stk += "("
		}

		if bracket[i] == ')' {
			if len(stk) != 0 && stk[len(stk) - 1] == '('{
				stk = stk[0 : len(stk) - 1]
			} else {
				stk += ")"
			}
		}
	}

	return len(stk) == 0
}

func IsPalindrome(str string) bool {
	l := len(str)
	if l < 2 {
		return false
	}

	head := 0
	tail := l - 1
	for {
		if head >= tail {
			break
		}

		if str[head] == str[tail] {
			head++
			tail--

			continue
		}

		return false
	}

	return true
}

func solve(bracket string) (ops int, cost int) {
	//if !IsPalindrome(bracket) && !BracketRegular(bracket) {
	//	return 0, 0
	//}

	l := len(bracket)
	if l < 2 {
		//fmt.Println("0 1")

		return 0, 0
	}

	//if l == 2 {
	//	if IsPalindrome(bracket) || BracketRegular(bracket) {
	//		return 1, 2
	//	}
	//}

	ops = 0
	cost = 0
	//for i := 2; i <= l; i++ {
	//	subStr := bracket[0:i]
	//	if IsPalindrome(subStr) || BracketRegular(subStr) {
	//		ops += 1
	//		cost += len(subStr)
	//
	//		o, c := solve(bracket[i:])
	//		ops += o
	//		cost += c
	//
	//		break
	//	}
	//}

	s := bracket
	for {
		if len(s) < 2 {
			break
		}

		firstChar := s[0]

		if firstChar == '(' {
			ops += 1
			cost += 2

			s = s[2:]
		}

		if firstChar == ')' {
			var i int
			for i = 1; i < len(s); i++ {
				if s[i] == ')' {
					ops += 1
					cost += i + 1

					s = s[i+1:]

					break
				}
			}

			if i >= len(s) {
				s = "" // empty s
			}
		}
	}

	return
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		n := readInt(in)
		n += 0

		s := readString(in)

		//fmt.Println(s[10:])

		l := len(s)
		o, c := solve(s)

		fmt.Printf("%d %d\n", o, l-c)
	}
}

/*
10000
1
(
1
)
2
((
2
)(
2
()
2
))
3
(((
3
)((
3
()(
3
))(
3
(()
3
)()
3
())
3
)))
4
((((
4
)(((
4
()((
4
))((
4
(()(
4
)()(
4
())(
4
)))(
4
((()
4
)(()
4
()()
4
))()
4
(())
4
)())
4
()))
4
))))
5
(((((
5
)((((
5
()(((
5
))(((
5
(()((
5
)()((
5
())((
5
)))((
5
((()(
5
)(()(
5
()()(
5
))()(
5
(())(
5
)())(
5
()))(
5
))))(
5
(((()
5
)((()
5
()(()
5
))(()
5
(()()
5
)()()
5
())()
5
)))()
5
((())
 */

/*
0 1
0 1
1 0
0 2
1 0
1 0
1 1
0 3
1 1
1 1
1 1
1 0
1 1
1 1
2 0
0 4
2 0
1 2
1 2
1 1
1 2
1 2
2 0
1 0
2 0
1 2
2 0
1 1
2 0
1 2
2 1
0 5
2 1
1 3
1 3
1 2
1 3
1 3
2 1
1 1
2 1
1 3
2 1
1 2
2 1
1 3
2 1
1 0
2 1
2 0
2 0
1 2
2 0
2 0
2 1
1 1
2 1
2 0
2 1
1 2
2 1
2 0
3 0
0 6
3 0
1 4
1 4
1 3
1 4
1 4
3 0
1 2
3 0
1 4
2 2
1 3
2 2
1 4
2 2
1 1
2 2
2 1
2 1
1 3
2 1
2 1
2 2
1 2
2 2
2 1
2 2
1 3
2 2
2 1
3 0
1 0
3 0
2 0
2 0
1 3
2 0
2 0
3 0
1 2
3 0
2 0
2 2
1 3
2 2
2 0
3 0
1 1
3 0
2 1
2 1
1 3
2 1
2 1
3 0
1 2
3 0
2 1
2 2
1 3
2 2
2 1
3 1
 */

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	DistanceStepsMap []int
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)

	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)

	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}

	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}

	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func Max(a int, b int) int {
	if a > b {
		return a
	}

	return b
}

func Min(a int, b int) int {
	if a < b {
		return a
	}

	return b
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}

	return r
}

func SwapInt(a *int, b *int) {
	t := *a
	*a = *b
	*b = t
}

func BracketRegular(bracket string) bool {
	l := len(bracket)
	if l <= 0 || l % 2 != 0{
		return false
	}

	stk := ""
	for i := 0; i < l; i++ {
		if bracket[i] == '(' {
			stk += "("
		}

		if bracket[i] == ')' {
			if len(stk) != 0 && stk[len(stk) - 1] == '('{
				stk = stk[0 : len(stk) - 1]
			} else {
				stk += ")"
			}
		}
	}

	return len(stk) == 0
}

func IsPalindrome(str string) bool {
	l := len(str)
	if l < 2 {
		return false
	}

	head := 0
	tail := l - 1
	for {
		if head >= tail {
			break
		}

		if str[head] == str[tail] {
			head++
			tail--

			continue
		}

		return false
	}

	return true
}

func solve(bracket string) (ops int, cost int) {
	//if !IsPalindrome(bracket) && !BracketRegular(bracket) {
	//	return 0, 0
	//}

	l := len(bracket)
	if l < 2 {
		//fmt.Println("0 1")

		return 0, 0
	}

	//if l == 2 {
	//	if IsPalindrome(bracket) || BracketRegular(bracket) {
	//		return 1, 2
	//	}
	//}

	ops = 0
	cost = 0
	//for i := 2; i <= l; i++ {
	//	subStr := bracket[0:i]
	//	if IsPalindrome(subStr) || BracketRegular(subStr) {
	//		ops += 1
	//		cost += len(subStr)
	//
	//		o, c := solve(bracket[i:])
	//		ops += o
	//		cost += c
	//
	//		break
	//	}
	//}

	s := bracket
	for {
		if len(s) < 2 {
			break
		}

		firstChar := s[0]

		if firstChar == '(' {
			ops += 1
			cost += 2

			s = s[2:]
		}

		if firstChar == ')' {
			for i := 1; i < len(s); i++ {
				if s[i] == ')' {
					ops += 1
					cost += i + 1

					s = s[i+1:]
				}
			}

			s = "" // empty s
		}
	}

	return
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		n := readInt(in)
		n += 0

		s := readString(in)

		//fmt.Println(s[10:])

		l := len(s)
		o, c := solve(s)

		fmt.Printf("%d %d\n", o, l-c)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var (
	DistanceStepsMap []int
)

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)

	return n
}

func readInt64(in *bufio.Reader) uint64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.ParseUint(nStr, 10, 64)

	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")

	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}

	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}

	return arr
}

func readString(in *bufio.Reader) string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")

	return line
}

func Max(a int, b int) int {
	if a > b {
		return a
	}

	return b
}

func Min(a int, b int) int {
	if a < b {
		return a
	}

	return b
}

func StringToRuneSlice(s string) []rune {
	var r []rune
	for _, runeValue := range s {
		r = append(r, runeValue)
	}

	return r
}

func SwapInt(a *int, b *int) {
	t := *a
	*a = *b
	*b = t
}

func BracketRegular(bracket string) bool {
	l := len(bracket)
	if l <= 0 || l % 2 != 0{
		return false
	}

	stk := ""
	for i := 0; i < l; i++ {
		if bracket[i] == '(' {
			stk += "("
		}

		if bracket[i] == ')' {
			if len(stk) != 0 && stk[len(stk) - 1] == '('{
				stk = stk[0 : len(stk) - 1]
			} else {
				stk += ")"
			}
		}
	}

	return len(stk) == 0
}

func IsPalindrome(str string) bool {
	l := len(str)
	if l < 2 {
		return false
	}

	head := 0
	tail := l - 1
	for {
		if head >= tail {
			break
		}

		if str[head] == str[tail] {
			head++
			tail--

			continue
		}

		return false
	}

	return true
}

func solve(bracket string) (ops int, cost int) {
	if !IsPalindrome(bracket) && !BracketRegular(bracket) {
		return 0, 0
	}

	l := len(bracket)
	if l < 2 {
		//fmt.Println("0 1")

		return 0, 0
	}

	//if l == 2 {
	//	if IsPalindrome(bracket) || BracketRegular(bracket) {
	//		return 1, 2
	//	}
	//}

	ops = 0
	cost = 0
	//for i := 2; i <= l; i++ {
	//	subStr := bracket[0:i]
	//	if IsPalindrome(subStr) || BracketRegular(subStr) {
	//		ops += 1
	//		cost += len(subStr)
	//
	//		o, c := solve(bracket[i:])
	//		ops += o
	//		cost += c
	//
	//		break
	//	}
	//}

	s := bracket
	i := 2
	for {
		if len(s) < i {
			break
		}

		subStr := s[0:i]
		if IsPalindrome(subStr) || BracketRegular(subStr) {
			ops += 1
			cost += len(subStr)

			s = s[i:]
			i = 2
			continue
		}

		i++
	}

	return
}

func main() {
	in := bufio.NewReader(os.Stdin)

	tc := readInt(in)

	for i := 0; i < tc; i++ {
		n := readInt(in)
		n += 0

		s := readString(in)

		l := len(s)
		o, c := solve(s)

		fmt.Printf("%d %d\n", o, l-c)
	}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		readNum(reader)

		s := readString(reader)
		n, r := solve(s)

		buf.WriteString(fmt.Sprintf("%d %d\n", n, r))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' || s[i] == '\r' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(s string) (int, int) {
	n := len(s)

	//if good, then remove
	// good = regular or palindrome
	// regular = open == 0
	// palindrome =?

	var open int
	var cnt int
	r := n

	base := NewKey(1)

	a := NewKey(0)
	b := NewKey(0)
	var l int
	for i := 0; i < n; i++ {
		if s[i] == '(' {
			open++
			a = a.MulNum(3).AddNum(1)
			b = base.MulNum(1).AddKey(b)
		} else {
			open--
			a = a.MulNum(3).AddNum(2)
			b = base.MulNum(2).AddKey(b)
		}
		l++

		base = base.MulNum(3)

		if a == b && l > 1 || open == 0 && s[i-l+1] == '(' {
			cnt++
			r = i + 1
			base = NewKey(1)
			a = NewKey(0)
			b = NewKey(0)
			l = 0
			open = 0
		}
	}

	return cnt, n - r
}

const M1 = 1000000007
const M2 = 10000000009

type Key struct {
	first  int64
	second int64
}

func NewKey(x int) Key {
	X := int64(x)
	key := Key{X % M1, X % M2}
	return key
}

func (this Key) AddNum(x int) Key {
	X := int64(x)
	first := (this.first + X) % M1
	second := (this.second + X) % M2
	return Key{first, second}
}

func (this Key) MulNum(x int) Key {
	X := int64(x)
	first := this.first * X % M1
	second := this.second * X % M2
	return Key{first, second}
}

func (this Key) AddKey(that Key) Key {
	first := (this.first + that.first) % M1
	second := (this.second + that.second) % M2
	return Key{first, second}
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)

	var buf bytes.Buffer

	tc := readNum(reader)

	for tc > 0 {
		tc--
		readNum(reader)

		s := readString(reader)
		n, r := solve(s)

		buf.WriteString(fmt.Sprintf("%d %d\n", n, r))
	}

	fmt.Print(buf.String())
}

func readString(reader *bufio.Reader) string {
	s, _ := reader.ReadString('\n')
	for i := 0; i < len(s); i++ {
		if s[i] == '\n' {
			return s[:i]
		}
	}
	return s
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'a' && s[i-1] <= 'z' {
			return s[:i]
		}
	}
	return ""
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(s string) (int, int) {
	n := len(s)

	//if good, then remove
	// good = regular or palindrome
	// regular = open == 0
	// palindrome =?

	var open int
	var cnt int
	r := n

	base := NewKey(1)

	a := NewKey(0)
	b := NewKey(0)
	var l int
	for i := 0; i < n; i++ {
		if s[i] == '(' {
			open++
			a = a.MulNum(3).AddNum(1)
			b = base.MulNum(1).AddKey(b)
		} else {
			open--
			a = a.MulNum(3).AddNum(2)
			b = base.MulNum(2).AddKey(b)
		}
		l++

		base = base.MulNum(3)

		if a == b && l > 1 || open == 0 && s[i-l+1] == '(' {
			cnt++
			r = i + 1
			base = NewKey(1)
			a = NewKey(0)
			b = NewKey(0)
			l = 0
			open = 0
		}
	}

	return cnt, n - r
}

const M1 = 1000000007
const M2 = 10000000009

type Key struct {
	first  int64
	second int64
}

func NewKey(x int) Key {
	X := int64(x)
	key := Key{X % M1, X % M2}
	return key
}

func (this Key) AddNum(x int) Key {
	X := int64(x)
	first := (this.first + X) % M1
	second := (this.second + X) % M2
	return Key{first, second}
}

func (this Key) MulNum(x int) Key {
	X := int64(x)
	first := this.first * X % M1
	second := this.second * X % M2
	return Key{first, second}
}

func (this Key) AddKey(that Key) Key {
	first := (this.first + that.first) % M1
	second := (this.second + that.second) % M2
	return Key{first, second}
}

package main

import (
	"fmt"
)

var (
	t int
	n int
	s string
)

func main() {
	fmt.Scanf("%d\n", &t)
	for ; t >= 1; t-- {
		fmt.Scanf("%d\n%s\n", &n, &s)
		var regular, palindrome, length int
		palindrome = 1
		palindrome2 := 2
		var c, r int
		r = n
		for i, ch := range s {
			length++
			switch ch {
			case '(':
				if regular >= 0 {
					regular++
				}
			case ')':
				regular--
			}
			if regular == 0 && length > 1 {
				c++
				r -= length

				length = 0
				palindrome = 1
				palindrome2 = 2
				regular = 0
			}

			// fmt.Println(i, string(ch), -palindrome2, length)
			if length > 1 {
				if rune(s[i-palindrome]) == ch {
					palindrome += 2
					if palindrome == length+1 {
						c++
						r -= length

						length = 0
						palindrome = 1
						palindrome2 = 2
						regular = 0
					}
				} else {
					palindrome = 1
					if rune(s[i-palindrome]) == ch {
						palindrome += 2
					} else {
						palindrome = 1
					}
				}
			}
			if length > 2 {
				if rune(s[i-palindrome2]) == ch {
					palindrome2 += 2
					if palindrome2 == length+1 {
						c++
						r -= length

						length = 0
						palindrome = 1
						palindrome2 = 2
						regular = 0
					}
				} else {
					palindrome2 = 2
					if rune(s[i-palindrome2]) == ch {
						palindrome2 += 2
					} else {
						palindrome2 = 2
					}
				}
			}
		}
		fmt.Println(c, r)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		var n int
		var s string
		fmt.Fscan(in, &n, &s)

		var ops, open, closed, ind int
		for i := 0; i < n; i++ {
			if s[i] == '(' {
				open++
				if closed == 0 && open == 2 {
					ops++
					open = 0
					ind = i
				}
			} else {
				if open == 1 {
					ops++
					open = 0
					closed = -1
					ind = i
				} else if closed == 1 {
					ops++
					open = 0
					closed = -1
					ind = i
				}
				closed++
			}
		}

		left := n - ind - 1
		fmt.Fprintln(out, ops, left)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
2
5
)((((
5
)((()
---
0 5
1 0
*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n int
	var s string
	scanf("%d\n%s\n", &n, &s)

	c := 0
	prefixEnd := 0

	i := 1
	for i < n {
		if s[i-1] == ')' && s[i] == '(' {
			i++
			for ; i < n; i++ {
				if s[i] == ')' {
					c++

					prefixEnd = i
					i += 2
					break
				}
			}
		} else {
			c++

			prefixEnd = i
			i += 2
		}
	}

	fmt.Fprintln(writer, c, n-prefixEnd-1)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return nums[minNumIdx]
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return nums[maxNumIdx]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

type ll = int64

func solve() {
	var n, s ll
	scan(&n, &s)
	a := make([]ll, n)
	for i := range a {
		scan(&a[i])
	}
	ll, rr := -1, -2
	l := 0
	for r := range a {
		s += a[r]
		for l <= r && s < 0 {
			s -= a[l]
			l++
		}
		if rr-ll+1 < r-l+1 {
			ll, rr = l, r
		}
	}
	if ll > -1 {
		printf("%v %v\n", ll+1, rr+1)
	} else {
		printf("-1\n")
	}
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	CF1611F(os.Stdin, os.Stdout)
}

func CF1611F(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n, s int64
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n, &s)
		arr := make([]int64, n+1)
		for i := int64(1); i <= n; i++ {
			fmt.Fscan(r, &arr[i])
			arr[i] = arr[i] + arr[i-1]
		}
		ll, rr := int64(-1), int64(-1)
		for left, right := int64(0), int64(0); right < n; left++ {
			for right < n && arr[right+1] - arr[left] >= -s {
				right++
			}
			if right - left > rr - ll {
				ll, rr = left, right
			}
		}

		if ll < 0 {
			fmt.Fprintln(w, -1)
		} else {
			fmt.Fprintln(w, ll+1, rr)
		}
	}

}

func max(a, b int64) int64 {
	if b > a {
		return b
	}
	return a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type Ans struct {
	v int
	l int
	r int
}

var in  = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()

	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++  {
		var n int
		var s int64
		fmt.Fscan(in, &n, &s)
		a := make([]int64, n)
		for	j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}

		ans := Ans {
			0,
			0,
			0,
		}
		r := 0
		var lsum, rsum int64
		for l := 0; l < n; l++ {
			if r < l {
				r = l
				rsum = lsum
			}
			for r < n && rsum - lsum + a[r] + s >= 0 {
				rsum += a[r]
				r++
			}
			v := r - l
			//println("v:", v, "l:", l, "r:", r, "lsum:", lsum, "rsum:", rsum)
			if v > ans.v {
				ans = Ans{v, l, r}
			}
			lsum += a[l]
		}

		if ans.v == 0 {
			fmt.Fprintln(out, "-1")
		} else {
			fmt.Fprintln(out, ans.l + 1, ans.r)
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1611F(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var s int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s)
		a := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			a[i] += a[i-1]
		}
		ll, rr := -1, -1
		for l, r := 0, 0; r < n; l++ {
			for r < n && a[r+1]-a[l] >= -s {
				r++
			}
			if r-l > rr-ll {
				ll, rr = l, r
			}
		}
		if ll < 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, ll+1, rr)
		}
	}
}

func main() { CF1611F(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	."fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1611F(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var s int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s)
		a := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			a[i] += a[i-1]
		}
		ll, rr := -1, -1
		for l, r := 0, 0; l < n; l++ {
			for r < n && a[r+1]-a[l] >= -s {
				r++
			}
			if r-l > rr-ll {
				ll, rr = l, r
			}
		}
		if ll < 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, ll+1, rr)
		}
	}
}

func main() { CF1611F(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1611F(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var s int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s)
		a := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			a[i] += a[i-1]
		}
		ll, rr := -1, -1
		for l, r := 0, 0; l < n; l++ {
			for r < n && a[r+1]-a[l] >= -s {
				r++
			}
			if r-l > rr-ll {
				ll, rr = l, r
			}
		}
		if ll < 0 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, ll+1, rr)
		}
	}
}

func main() { CF1611F(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1611F(read io.Reader, write io.Writer) {
	in := bufio.NewReader(read)
	out := bufio.NewWriter(write)
	defer out.Flush()

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n int
		var s int64
		fmt.Fscan(in, &n, &s)
		nums := make([]int, n)
		var sum int64
		left := 0
		l, r := -1, -2
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
			sum += int64(nums[i])
			for sum+s < 0 && left <= i {
				sum -= int64(nums[left])
				left++
			}
			if sum+s >= 0 && r-l < i-left {
				l, r = left+1, i+1
			}
		}
		if l == -1 {
			fmt.Fprintln(out, l)
		} else {
			fmt.Fprintln(out, l, r)
		}
	}
}

func main() {
	// in, _ := os.Open("input.txt")
	in := os.Stdin
	CF1611F(in, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

type Value struct {
	value int64
	index int
}

func solveCase() {
	var (
		ansStart int = 0
		ansEnd   int = -1
	)
	var n, i, lo, hi, mid int
	var amount int64
	fmt.Fscan(in, &n, &amount)
	var a = make([]int64, n+2)
	var stackTop int = n           // 3
	var stack = make([]Value, n+2) // (0,idx0) (-3,idx1) (-7,idx2)
	for i = 1; i <= n; i += 1 {
		fmt.Fscan(in, &a[i])
	}

	stack[stackTop] = Value{value: 0, index: n + 1}
	for i = n; i >= 1; i-- {
		a[i] += a[i+1]

		// find j such that:
		//   j > i
		//   (amount + a[i] - a[j]) < 0 <=> a[j] > a[i] + amount
		//   j is as small as possible
		// This means the range [i,j-1] is the first range that doesn't work,
		// so the range [i,j-2] is the longuest rangue starting at i that does work.
		lo = stackTop
		hi = n + 1
		for lo < hi {
			mid = (lo + hi) / 2
			if stack[mid].value <= a[i]+amount {
				lo = mid + 1
			} else {
				hi = mid
			}
		}

		var reach = 0
		if lo == n+1 {
			reach = n
		} else {
			reach = stack[lo].index - 2
		}
		if (a[i]-a[i+1])+amount >= 0 && reach-i > ansEnd-ansStart {
			ansEnd = reach
			ansStart = i
		}

		// add (a[i],i) to stack
		for stackTop <= n && stack[stackTop].value <= a[i] {
			stackTop++
		}
		stackTop--
		stack[stackTop] = Value{value: a[i], index: i}
	}

	if ansStart == 0 {
		fmt.Fprintln(out, "-1")
	} else {
		fmt.Fprintf(out, "%d %d\n", ansStart, ansEnd)
	}
}

func main() {
	var ntc, t int
	fmt.Fscan(in, &ntc)
	for t = 0; t < ntc; t += 1 {
		solveCase()
	}
	out.Flush()
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	CF1611F(os.Stdin, os.Stdout)
}

func CF1611F(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n, s int64
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n, &s)
		arr, pre := make([]int64, n), make([]int64, n+1)
		for i := range arr {
			fmt.Fscan(r, &arr[i])
			pre[i+1] = pre[i] + arr[i]
		}
		left, found := int64(1), false
		ansl, ansr := int64(0), int64(0)
		for left < n {
			base := pre[left-1]
			if pre[left]-base < -s {
				left++
				continue
			}
			right := left + 1
			for right <= n && pre[right]-base >= -s {
				right++
			}
			if right-left-1 >= ansr-ansl {
				ansr, ansl = right-1, left
			}
			found = true
			left++
		}
		if !found {
			fmt.Fprintln(w, -1)
		} else {
			fmt.Fprintln(w, ansl, ansr)
		}
	}

}

func max(a, b int64) int64 {
	if b > a {
		return b
	}
	return a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	CF1611F(os.Stdin, os.Stdout)
}

func CF1611F(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n, s int64
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n, &s)
		arr, pre := make([]int64, n), make([]int64, n+1)
		for i := range arr {
			fmt.Fscan(r, &arr[i])
			pre[i+1] = pre[i] + arr[i]
		}
		left, found := int64(1), false
		ansl, ansr := int64(0), int64(0)
		for left < n {
			base := pre[left-1]
			if pre[left]-base < -s {
				left++
				continue
			}
			right := left + 1
			for right <= n && pre[right]-base >= -s {
				right++
			}
			if right-left-1 > ansr-ansl {
				ansr, ansl = right-1, left
			}
			found = true
			left++
		}
		if !found {
			fmt.Fprintln(w, -1)
		} else {
			fmt.Fprintln(w, ansl, ansr)
		}
	}

}

func max(a, b int64) int64 {
	if b > a {
		return b
	}
	return a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	CF1611F(os.Stdin, os.Stdout)
}

func CF1611F(in io.Reader, out io.Writer) {
	r := bufio.NewReader(in)
	w := bufio.NewWriter(out)
	defer w.Flush()

	var T, n, s int64
	for fmt.Fscan(r, &T); T > 0; T-- {
		fmt.Fscan(r, &n, &s)
		arr, pre := make([]int64, n), make([]int64, n+1)
		for i := range arr {
			fmt.Fscan(r, &arr[i])
			pre[i+1] = pre[i] + arr[i]
		}
		left, found := int64(1), false
		for left < n {
			base := pre[left-1]
			if pre[left]-base < -s {
				left++
				continue
			}
			right := left + 1
			for right <= n && pre[right]-base >= -s {
				right++
			}
			found = true
			fmt.Fprintln(w, left, right-1)
			break
		}
		if !found {
			fmt.Fprintln(w, -1)
		}
	}

}

func max(a, b int64) int64 {
	if b > a {
		return b
	}
	return a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func gcd(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

type Ans struct {
	v int
	l int
	r int
}

var in  = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()

	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++  {
		var n int
		var s int64
		fmt.Fscan(in, &n, &s)
		a := make([]int64, n)
		for	j := 0; j < n; j++ {
			fmt.Fscan(in, &a[j])
		}

		ans := Ans {
			0,
			0,
			0,
		}
		r := 0
		var lsum, rsum int64
		prev := -int64(1e9 + 100)
		for l := 0; l < n; l++ {
			if r < l {
				r = l
				rsum = lsum
			}
			if lsum + a[l] > prev {
				for r < n && rsum - lsum + a[r] + s >= 0 {
					rsum += a[r]
					r++
				}
				prev = lsum + a[l]
			}
			v := r - l
			//println("v:", v, "l:", l, "r:", r, "lsum:", lsum, "rsum:", rsum)
			if v > ans.v {
				ans = Ans{v, l, r}
			}
			lsum += a[l]
		}

		if ans.v == 0 {
			fmt.Fprintln(out, "-1")
		} else {
			fmt.Fprintln(out, ans.l + 1, ans.r)
		}
	}
}

package main

import (
	"fmt"
)

type Ans struct {
	v int
	l int
	r int
}

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++  {
		var n, s int
		fmt.Scanln(&n, &s)
		a := make([]int, n)
		for	j := 0; j < n; j++ {
			fmt.Scan(&a[j])
		}

		ans := Ans {
			0,
			0,
			0,
		}
		r := 0
		lsum, rsum := 0, 0
		prev := -int(1e9 + 100)
		for l := 0; l < n; l++ {
			if r < l {
				r = l
				rsum = lsum
			}
			if lsum + a[l] > prev {
				for r < n && rsum - lsum + a[r] + s >= 0 {
					rsum += a[r]
					r++
				}
				prev = lsum + a[l]
			}
			v := r - l
			//println("v:", v, "l:", l, "r:", r, "lsum:", lsum, "rsum:", rsum)
			if v > ans.v {
				ans = Ans{v, l, r}
			}
			lsum += a[l]
		}

		if ans.v == 0 {
			println(-1)
		} else {
			println(ans.l + 1, ans.r)
		}
	}
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1611F(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var T, n int
	var s int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &s)
		a := make([]int64, n+1)
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			a[i] += a[i-1]
		}
		ll, rr := -1, -1
		for l, r := 0, 0; r < n; l++ {
			for r < n && a[r+1]-a[l] >= -s {
				r++
			}
			if l-r > rr-ll {
				ll, rr = l, r
			}
		}
		if ll == -1 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, ll+1, rr)
		}
	}
}

func main() { CF1611F(os.Stdin, os.Stdout) }

package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func CF1611F(read io.Reader, write io.Writer) {
	in := bufio.NewReader(read)
	out := bufio.NewWriter(write)
	defer out.Flush()

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var n int
		var s int64
		fmt.Fscan(in, &n, &s)
		nums := make([]int, n)
		var sum int64
		left := 0
		l, r := -1, -1
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &nums[i])
			sum += int64(nums[i])
			for sum+s < 0 && left <= i {
				sum -= int64(nums[left])
				left++
			}
			if sum+s >= 0 && r-l < i-left {
				l, r = left+1, i+1
			}
		}
		if l == -1 {
			fmt.Fprintln(out, l)
		} else {
			fmt.Fprintln(out, l, r)
		}
	}
}

func main() {
	// in, _ := os.Open("input.txt")
	in := os.Stdin
	CF1611F(in, os.Stdout)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solve()
	}
}

type ll = int64

func solve() {
	var n, s ll
	scan(&n, &s)
	a := make([]ll, n)
	for i := range a {
		scan(&a[i])
	}
	ll, rr := -1, -1
	l := 0
	for r := range a {
		s += a[r]
		for l <= r && s < 0 {
			s -= a[l]
			l++
		}
		if rr-ll+1 < r-l+1 {
			ll, rr = l, r
		}
	}
	if ll > -1 {
		printf("%v %v\n", ll+1, rr+1)
	} else {
		printf("-1\n")
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

type Value struct {
	value int64
	index int
}

func solveCase() {
	var (
		ansStart int = 0
		ansEnd   int = 0
	)
	var n, i, lo, hi, mid int
	var amount int64
	fmt.Fscan(in, &n, &amount)
	var a = make([]int64, n+2)
	var stackTop int = n           // 3
	var stack = make([]Value, n+2) // (0,idx0) (-3,idx1) (-7,idx2)
	for i = 1; i <= n; i += 1 {
		fmt.Fscan(in, &a[i])
	}

	stack[stackTop] = Value{value: 0, index: n + 1}
	for i = n; i >= 1; i-- {
		a[i] += a[i+1]

		// find j such that:
		//   (amount + a[i] - a[j]) < 0 <=> a[j] > a[i] + amount
		//   j is as small as possible, but j > i
		lo = stackTop
		hi = n + 1
		for lo < hi {
			mid = (lo + hi) / 2
			if stack[mid].value <= a[i]+amount {
				lo = mid + 1
			} else {
				hi = mid
			}
		}

		var reach = 0
		if lo == n+1 {
			reach = n
		} else {
			reach = stack[lo].index - 2
		}
		if (a[i]-a[i+1])+amount >= 0 && lo > 0 && reach-i > ansEnd-ansStart {
			ansEnd = reach
			ansStart = i
		}

		// add (a[i],i) to stack
		for stackTop <= n && stack[stackTop].value <= a[i] {
			stackTop++
		}
		stackTop--
		stack[stackTop] = Value{value: a[i], index: i}
	}

	if ansStart == 0 {
		fmt.Fprintln(out, "-1")
	} else {
		fmt.Fprintf(out, "%d %d\n", ansStart, ansEnd)
	}
}

func main() {
	var ntc, t int
	fmt.Fscan(in, &ntc)
	for t = 0; t < ntc; t += 1 {
		solveCase()
	}
	out.Flush()
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t int
	_, _ = fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, z, ans int
		_, _ = fmt.Fscan(r, &n, &z)
    for ; n > 0; n-- {
      var x int
      _, _ = fmt.Fscan(r, &x)
      ans = max(ans, x | z)
    }
    fmt.Fprintln(w, ans)
	}
}

func max(a, b int) int {
  if a > b {
    return a
  }
  return b
}

package main

import "fmt"

var (
	t, n, z int
	a       = make([]int, 2048)
)

func main() {
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		ret := 0
		fmt.Scanf("%d %d\n", &n, &z)
		// fmt.Printf("z = %d\n", z)
		for j := 0; j < n; j++ {
			fmt.Scanf("%d", &a[j+1])
			// fmt.Printf("a=%d, ", a[j+1])
			// fmt.Printf("z|a[j+1]=%d, ", z|a[j+1])
			if z|a[j+1] > ret {
				ret = z | a[j+1]
			}
		}
		fmt.Scanf("\n")
		fmt.Printf("%d\n", ret)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	in  = bufio.NewReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}

func solve() {
	var n, z int
	scan(&n, &z)
	max, x := 0, 0
	for i := 0; i < n; i++ {
		scan(&x)
		if max < x|z {
			max = x | z
		}
	}
	printf("%d\n", max)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type CF1696A struct {
	sc        *bufio.Reader
	split     []string
	index     int
	separator string
}

func (in *CF1696A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1696A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

func (in *CF1696A) NextInt() int {
	in.load()
	val, _ := strconv.Atoi(strings.TrimSpace(in.split[in.index]))
	in.index++
	return val
}

func (in *CF1696A) NextInt64() int64 {
	in.load()
	val, _ := strconv.ParseInt(strings.TrimSpace(in.split[in.index]), 10, 64)
	in.index++
	return val
}

func (in *CF1696A) NextString() string {
	in.load()
	val := strings.TrimSpace(in.split[in.index])
	in.index++
	return val
}

/**
Run solve the problem CF1696A
Date: 3/07/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1696/A
Problem: CF1696A
**/
func (in *CF1696A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, z := in.NextInt(), in.NextInt()

		ans := 0
		for i := 0; i < n; i++ {
			val := in.NextInt()
			if (z | val) > ans {
				ans = z | val
			}
		}

		fmt.Println(ans)
	}
}

func NewCF1696A(r *bufio.Reader) *CF1696A {
	return &CF1696A{
		sc:        r,
		split:     []string{},
		index:     0,
		separator: " ",
	}
}

func main() {
	NewCF1696A(bufio.NewReader(os.Stdin)).Run()
}

package main

import (
	"fmt"
	"io"
	"bufio"
	"os"
)

func Max(x int, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func Solve(testCaseIdx int, reader io.Reader) {
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var (
		n int
		z int
	)
	ans := 0
	fmt.Fscan(reader, &n, &z)
	for k := 0; k < n; k++ {
		var ak int
		fmt.Fscan(reader, &ak)
		ans = Max(ans, ak | z)
	}
	fmt.Fprintln(writer, ans)
}

func main() {
	var testCaseCount int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &testCaseCount)
	for t := 0; t < testCaseCount; t++ {
		Solve(t, reader)
	}
}

package main

import (
	"fmt"
)

func main() {
	var qq int
	fmt.Scan(&qq)

	for ii := 0; ii < qq; ii++ {
		var n, z int
		fmt.Scan(&n)
		fmt.Scan(&z)
		var ans int = 0
		for i := 0; i < n; i++ {
			var x int
			fmt.Scan(&x)
			var cur int = x | z
			if cur > ans {
				ans = cur
			}
		}

		fmt.Println(ans)
	}
}

package main

import (
	"bufio"
	. "fmt"
	"os"
)

func A4() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		var n, z int
		// n
		// x
		// k 有多少个土豆
		// =>x

		Fscan(in, &n, &z)
		var ans int
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			Fscan(in, &arr[i])
		}
		for i := 0; i < n; i++ {
			if arr[i]|z > ans {
				ans = arr[i] | z
			}
		}
		Fprintln(out, ans)
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() { A4() }

package main

import (
	"bufio"
	"fmt"
	"os"
)

func maxInt(a int, b int) int {
	if a >= b {
		return a
	}

	return b
}

func main() {
	//f, _ := os.Open("input.txt")
	var reader = bufio.NewReader(os.Stdin)
	//var reader = bufio.NewReader(f)
	var tests int
	fmt.Fscan(reader, &tests)
	for t := 0; t < tests; t++ {
		var n int
		fmt.Fscan(reader, &n)
		var z int
		fmt.Fscan(reader, &z)
		var max int
		for i := 0; i < n; i++ {
			var s int
			fmt.Fscan(reader, &s)
			var first = s
			var second = s | z
			max = maxInt(max, maxInt(first, second))
		}
		fmt.Println(max)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t int
	_, _ = fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, z, ans int
		_, _ = fmt.Fscan(r, &n, &z)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(r, &a[i])
		}
		for _, v := range a {
			if v|z > ans {
				ans = v | z
			}
		}
		fmt.Fprintln(w, ans)
	}
}

package main

import (
	"fmt"
	//"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	for k := 0; k < n; k++ {
		var n int64
		var z int64
		fmt.Scan(&n)
		fmt.Scan(&z)
		var max int64 = 0
		for i := 0; int64(i) < n; i++ {
			var number int64
			fmt.Scan(&number)
			if (number | z) > max {
				max = (number | z)
			}
		}
		fmt.Println(max)
		//fmt.Print("\n")
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 0, 64*1024*1024)
	scanner.Buffer(buf, 64*1024*1024)
	scanner.Scan()
	count, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < count; i++ {
		var n, z int
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d\n", &n, &z)
		scanner.Scan()
		max := -999999
		for _, strA := range strings.Split(scanner.Text(), " ") {
			a, _ := strconv.Atoi(strA)
			a = a | z
			z = a & z
			if a > max {
				max = a
			}
		}
		fmt.Println(max)
	}
}

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

/*
1
4 6
2 3 4 6
---

==========
1
5 5
0 2 4 6 8
---
13

*/

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var n, z int
	scanf("%d %d\n", &n, &z)

	a := make([]int, n)

	for i := range a {
		scanf("%d", &a[i])

		a[i] = a[i] | z
	}
	scanf("\n")

	ans := max(a...)

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func sum(nums ...int) (sum int) {
	for _, num := range nums {
		sum += num
	}
	return
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int64) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := int64(5); i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

//goland:noinspection GoUnusedFunction
func factorize(num int64) []int64 {
	factors := make([]int64, 0)

	for ftr := int64(2); ftr*ftr <= num; ftr++ {
		for num%ftr == 0 {
			num /= ftr
			factors = append(factors, ftr)
		}
	}

	if num > 1 {
		factors = append(factors, num)
	}

	return factors
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		var z int64
		fmt.Fscan(in, &n, &z)

		var ans int64
		for i := 0; i < n; i++ {
			var v int64
			fmt.Fscan(in, &v)
			ans = max(ans, v|z)
		}
		fmt.Fprintln(out, ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t int
	_, _ = fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, z, ans int
		_, _ = fmt.Fscan(r, &n, &z)
		for ; n > 0; n-- {
			var x int
			_, _ = fmt.Fscan(r, &x)
			ans = max(ans, x|z)
		}
		fmt.Fprintln(w, ans)
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var t int
	_, _ = fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		var n, z, ans int
		_, _ = fmt.Fscan(r, &n, &z)
		for ; n > 0; n-- {
			var x int
			_, _ = fmt.Fscan(r, &x)
			ans = max(ans, x|z)
		}
		fmt.Fprint(w, ans)
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var in = bufio.NewScanner(os.Stdin)

func readInt() int {
	if !in.Scan() {
		panic(in.Err())
	}
	res := 0
	for _, b := range in.Bytes() {
		res = res*10 + int(b-'0')
	}
	return res
}

func main() {
	in.Split(bufio.ScanWords)

	n := readInt()
	a := make([]int, 0, n-1)
	for i := 0; i < n; i++ {
		x := readInt()
		if x == 0 {
			continue
		}
		a = append(a, x)
	}
	b := make([]int, 0, n-1)
	for i := 0; i < n; i++ {
		x := readInt()
		if x == 0 {
			continue
		}
		b = append(b, x)
	}

	first := 0
	for b[first] != a[0] {
		first++
	}
	for i := range a {
		if a[i] != b[(first+i)%(n-1)] {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
)

func main() {
	defer out.Flush()
	n := in.NextInt()
	a := make([]int, 0, n-1)
	for i := 0; i < n; i++ {
		x := in.NextInt()
		if x != 0 {
			a = append(a, x)
		}
	}
	b := make([]int, 0, n-1)
	for i := 0; i < n; i++ {
		x := in.NextInt()
		if x != 0 {
			b = append(b, x)
		}
	}
	if equals(shift(a), shift(b)) {
		fmt.Fprintln(out, "YES")
	} else {
		fmt.Fprintln(out, "NO")
	}
}

func shift(a []int) []int {
	one := 0
	for i := range a {
		if a[i] == 1 {
			one = i
			break
		}
	}
	return append(a[one:], a[:one]...)
}

func equals(a, b []int) bool {
	if len(a) != len(b) {
		return false
	}
	for i := range a {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

var (
	in  = NewFastReader(os.Stdin)
	out = bufio.NewWriter(os.Stdout)
)

type FastReader struct {
	r   *bufio.Reader
	buf string
}

func NewFastReader(r io.Reader) *FastReader {
	return &FastReader{
		r: bufio.NewReader(r),
	}
}

func (r *FastReader) advance() {
	for len(r.buf) != 0 && r.buf[0] == ' ' {
		r.buf = r.buf[1:]
	}
	if len(r.buf) != 0 {
		return
	}
	var buf bytes.Buffer
	for {
		chunk, more, _ := r.r.ReadLine()
		buf.Write(chunk)
		if !more {
			break
		}
	}
	r.buf = buf.String()
}

func (r *FastReader) NextLine() string {
	r.advance()
	line := r.buf
	r.buf = ""
	return line
}

func (r *FastReader) NextWord() string {
	r.advance()
	var word string
	wordStart := 0
	for i := 0; i < len(r.buf); i++ {
		b := r.buf[i]
		if b == ' ' {
			if i != wordStart {
				word = r.buf[wordStart:i]
				r.buf = r.buf[i:]
				break
			}
			wordStart = i + 1
		}
	}
	if len(word) == 0 {
		word = r.buf
		r.buf = ""
	}
	return word
}

func (r *FastReader) NextInt() int {
	return parseInt(r.NextWord())
}

func parseInt(word string) int {
	result := 0
	for i := 0; i < len(word); i++ {
		if i == 0 && word[0] == '-' {
			continue
		}
		result = result*10 + int(word[i]) - '0'
	}
	if word[0] == '-' {
		result *= -1
	}
	return result
}