package main

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

func main() {
	// var s string
	// fmt.Scanln(&s)
	// fmt.Println(s)
	in := bufio.NewReader(os.Stdin)
	s, _ := in.ReadString('\n')
	s = strings.TrimSpace(s)

	m := make(map[string]bool)
	for _, tok := range strings.Split(s[1:len(s)-1], ", ") {
		m[tok] = true
	}
	delete(m, "")
	// fmt.Println(m)
	fmt.Println(len(m))
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	line := readLine(reader)
	out := strings.Split(line[1:len(line)-1], ", ")
	set := make(map[string]bool)
	for _, c := range out {
		if c != "" {
			set[c] = true
		}
	}
	fmt.Println(len(set))
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

package main

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

func main() {
	s, _ := bufio.NewReader(os.Stdin).ReadString('}')
	ls := strings.Split(strings.Replace(s[1:len(s)-1], " ", "", -1), ",")
	m := make(map[string]bool)
	for _, l := range ls {
		if l != "" {
			m[l] = true
		}
	}
	fmt.Print(len(m))
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	str := scanner.Text()

	if str == "{}" {
		fmt.Println(0)
		return
	}

	res := strings.Split(str, ", ")
	res[0] = string([]byte{byte(res[0][1])})
	res[len(res)-1] = string([]byte{byte(res[len(res)-1][0])})
	unq := map[string]int{}

	for _, x := range res {
		unq[x] = 0
	}

	fmt.Println(len(unq))
}

package main

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

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt() uint64 {
    scanner.Scan()
    ans, _ := strconv.ParseUint(scanner.Text(), 10, 64)
    return ans
}

func PrintInt(value uint64) {
    writer.WriteString(strconv.FormatUint(value, 10))
    writer.WriteByte('\n')
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanLines)

    scanner.Scan()

    var line string = strings.Trim(scanner.Text(), "{}")
    var letters []string = strings.Split(line, ", ")
    var s map[string]bool = make(map[string]bool, 40)
    for _, val := range letters {
        s[val] = true
    }
    if len(line) > 0 {
        fmt.Println(len(s))
    } else {
        fmt.Println(0)
    }
}

package main

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

func main() {
  letter := make(map[byte]bool)
  bio := bufio.NewReader(os.Stdin)
  for line, hasMoreInLine, err := bio.ReadLine(); err == nil; {
    for _, char := range line {
      if 'a' <= char && char <= 'z' {
        letter[char] = true
      }
    }
    if !hasMoreInLine {
      break
    }
  }
  fmt.Println(len(letter))
}

package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	_ = stdin.Scan()
	inputLine := stdin.Text()

	alphabetFlags := make([]bool, 26)
	uniqueCount := 0

	for i := 0; i < len(inputLine); i++ {
		c := inputLine[i]

		switch c {
		case '{':
		case '}':
		case ',':
		case ' ':
			break
		default:
			if alphabetFlags[c - 'a'] == false {
				uniqueCount++
			}
			alphabetFlags[c - 'a'] = true
		}
	}

	fmt.Println(uniqueCount)
}

package main

import s "strings"
import "fmt"

func main() {
	var x, a, b, c, chr string

    for {
		n, err := fmt.Scanf("%s", &x)
        if n == 0 || err != nil { break }

		a = s.ReplaceAll(x, ",", "")
		b = s.ReplaceAll(a, "{", "")
		c = s.ReplaceAll(b, "}", "")
		chr += c
	}
	var str [26]int
	count := 0

	for i := 0; i < len(chr); i++ {
		str[chr[i]-'a']++
	}

	for i := 0; i < len(str); i++ {
		if str[i] > 0 {
			count++
		}
	}
	fmt.Println(count)

}

package main

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

func main() {
	sc := NewScanner(os.Stdin)
	s, _ := sc.NextLine()
	res := 0
	for i := 'a'; i <= 'z'; i++ {
		if strings.ContainsRune(s, i) {
			res++
		}
	}
	fmt.Println(res)
}

////////////////////////////////////////////////////////////////
//
//  gojus: retrieved from https://github.com/tnoda/gojus
//

// NewScanner returns a new Scanner to read from r.
func NewScanner(rdr io.Reader) *Scanner {
	sc := Scanner{bufio.NewScanner(rdr), 10}
	return &sc
}

// Errors returned by Scanner
var (
	ErrNoSuchElement = errors.New("gojus.Scanner: input is exhausted.")
)

// Scanner provides a similar interface to the java.util.Scaner's one.
type Scanner struct {
	*bufio.Scanner
	radix int
}

// Next scans and returns the next token of the input.
func (sc *Scanner) Next() (string, error) {
	sc.Split(bufio.ScanWords)
	if !sc.Scan() {
		return "", ErrNoSuchElement
	}
	return sc.Text(), nil
}

// UseRadix sets the scanner's default radix to the specified one.
func (sc *Scanner) UseRadix(radix int) *Scanner {
	sc.radix = radix
	return sc
}

func (sc *Scanner) nextLong() (int64, error) {
	t, e := sc.Next()
	if e != nil {
		return 0, e
	}
	return strconv.ParseInt(t, sc.radix, 64)
}

// NextLong scans and returns the next token of the input as an int64.
func (sc *Scanner) NextLong() (int64, error) {
	return sc.nextLong()
}

// NextDouble scans and returns the next token of the input as a float64
func (sc *Scanner) NextDouble() (float64, error) {
	t, e := sc.Next()
	if e != nil {
		return 0, e
	}
	return strconv.ParseFloat(t, 64)
}

// NextLine advances this scanner past the current line and returns
// the input that was skipped.
func (sc *Scanner) NextLine() (string, error) {
	sc.Split(bufio.ScanLines)
	if !sc.Scan() {
		return "", ErrNoSuchElement
	}
	return sc.Text(), nil
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

func main() {
	inputBytes, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	input := string(inputBytes)
	input = strings.NewReplacer("{", "", "}", "", "\n", "").Replace(input)
	input = strings.TrimSpace(input)

	var seen = map[string]struct{}{}
	var ok bool

	for _, symb := range strings.Split(input, ", ") {
		if _, ok = seen[symb]; ok || symb == "" {
			continue
		}
		seen[symb] = struct{}{}
	}

	fmt.Println(len(seen))
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var s string

func main() {
	sb, _, _ := reader.ReadLine()
	s = string(sb)
	if s == "{}" {
		fmt.Println(0)
		return
	}
	s = s[1 : len(s)-1]
	list := strings.Split(s, ", ")
	m := make(map[string]int)
	for i := 0; i < len(list); i++ {
		m[list[i]] = 1
	}
	fmt.Println(len(m))
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	xm := make(map[string]string)
	var s string

	s, _ = in.ReadString('\n')
	t := strings.ReplaceAll(s, ",", "")
	t = strings.ReplaceAll(t, "{", "")
	t = strings.ReplaceAll(t, "}", "")

	words := strings.Fields(t)
	if len(words) == 0{
		fmt.Println(0)
	}else{
		for i := 0; i < len(words); i++{
			xm[words[i]] = words[i];
		}
		fmt.Println(len(xm))
	}
}

package main

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

func main() {

	var S string

	scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan() // use `for scanner.Scan()` to keep reading

	S = scanner.Text()

	m := make(map[string]int)
	arr := string([]rune(S))
	for i:=0 ; i<len(arr) ;i++{
		if arr[i] == 123 || arr[i] == 125 || arr[i] == 32 || arr[i] == 44 {
			continue
		}else{
			m[string(arr[i])] += 1
		}
	}
	fmt.Println(len(m))
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    line, _ := reader.ReadString('\n')

    chars := make([]int, 26, 26)
    for i := 0; i < len(line); i++ {
        if line[i] >= 'a' && line[i] <= 'z' {
            chars[line[i] - 'a'] += 1
        }
    }

    result := 0
    for i := 0; i < 26; i++ {
        if chars[i] != 0 {
            result += 1
        }
    }

    fmt.Println(result)
}

//  URL: http://codeforces.com/problemset/problem/443/A
//  ~ Basic Implementation Problem

package main

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

func solve(s string) int {
	distinctCount := 0
	letterMap := make(map[rune]int)
	for _, elem := range s {
		if 'a' <= elem && elem <= 'z' && letterMap[elem] == 0 {
			letterMap[elem] += 1
			distinctCount += 1
		}
	}
	return distinctCount
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	s, _ := reader.ReadString('\n')
	fmt.Fprintf(writer, "%d\n", solve(s))
}

package main

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

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

func scanf(f string, a... interface{}) {
	fmt.Fscanf(reader, f, a...)
}

func printff(f string, a... interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func main() {

	in := bufio.NewReader(os.Stdin)
	S, _ := in.ReadString('\n')

	re, _ := regexp.Compile("[^a-zA-Z]")
	values := strings.Split(re.ReplaceAllString(S, ""), "")

	m := map[string]int{}
	for _, v := range values {
		if _, ok := m[v]; !ok {
			m[v] = 1
		}
	}

	fmt.Println(len(m))

}

package main

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

func main() {
	var myChar, firstString string
	var lastChar, currentChar byte
	var result int
	charArr := make([]int, 26)
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &firstString)
	currentChar = firstString[1]
	if currentChar != '}' {
		result++
		charArr[currentChar-97]++
	}
	lastChar = firstString[len(firstString)-1]
	for lastChar != '}' {
		fmt.Fscan(reader, &myChar)
		lastChar = myChar[len(myChar)-1]
		currentChar = myChar[0]
		if charArr[currentChar-97] == 0 {
			result++
			charArr[currentChar-97]++
		}

	}
	fmt.Println(result)
}

package main

import "fmt"
import "bufio"
import "os"

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	if scanner.Scan() {
		line := scanner.Text()
		m := make(map[rune]bool)
		for _, c := range line {
			if c >= 'a' && c <= 'z' {
				m[c] = true
			}
		}
		fmt.Println(len(m))
	}
}

package main

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

func main() {
	var s1, s2 string
	var flag bool
	var summ int
	reader := bufio.NewReader(os.Stdin)
	s1, _ = reader.ReadString('\n')
	for i := range s1 {
		flag = false
		if s1[i] >= 'a' && s1[i] <= 'z' {
			for j := range s2 {
				if s1[i] == s2[j] {
					flag = true
					break
				}
			}
			if !flag {
				s2 = s2 + string(s1[i])
				summ++
			}
		}
	}
	fmt.Println(summ)
}

package main

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

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func main() {
	var str string
	m := make(map[string]string, 0)
	reader := bufio.NewReader(os.Stdin)
	str, _ = reader.ReadString('\n')
	reg, _ := regexp.Compile("[^a-z,]")
	match := reg.ReplaceAllString(str,"")
	charLength := strings.Split(strings.TrimSpace(match), ",")
	for _, c := range charLength {
		if len(c) > 0 {
			m[c] = c
		}
	}
	printf("%d ", len(m))
}

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

func scanf(format string, x ...interface{}) {
	if _, err := fmt.Fscanf(os.Stdin, format, x...); err != nil {
		panic(err)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	data, _, _ := reader.ReadLine()
	str := string(data)
	if str == "{}" {
		fmt.Println(0)
	} else {
		str = strings.Replace(str, " ", "", -1)
		str = strings.Replace(str, "{", "", -1)
		str = strings.Replace(str, "}", "", -1)
		slice := strings.Split(str, ",")

		temp := make([]string, 0)

		for _, s := range slice {
			flag := false
			for _, t := range temp {
				if s == t {
					flag = true
					break
				}
			}
			if flag == false {
				temp = append(temp, s)
			}
		}
		fmt.Println(len(temp))
	}
}

package main

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

// https://codeforces.com/problemset/problem/443/A
// A. Anton and Letters
// time limit per test
// 2 seconds
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line.

// Unfortunately, from time to time Anton would forget writing some letter and write it again. He asks you to count the total number of distinct letters in his set.
// Input

// The first and the single line contains the set of letters. The length of the line doesn't exceed 1000. It is guaranteed that the line starts from an opening curved bracket and ends with a closing curved bracket. Between them, small English letters are listed, separated by a comma. Each comma is followed by a space.
// Output

// Print a single number — the number of distinct letters in Anton's set.

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	_ = scanner.Scan()
	line := scanner.Text()

	line = line[1 : len(line)-1]

	if len(line) == 0 {
		fmt.Print(0)
		return
	}

	letters := strings.Split(line, ", ")

	set := make(map[string]struct{}, len(letters))
	for _, letter := range letters {
		set[letter] = struct{}{}
	}

	fmt.Print(len(set))
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
)

// https://codeforces.com/problemset/problem/443/A
// комментарии к решению
// Требуется подсчитать кол-во неуникальных латинских букв,,
// поэтому уместно воспользоваться множествами set (map[T]struct{} в go)
func taskSolution(in []byte) int {
	type s struct{}
	exists := s{}
	chars := map[byte]s{}

	for _, c := range in {
		if c >= 'a' && c <= 'z' {
			chars[c] = exists
		}
	}

	return len(chars)
}

func main() {
	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(inRaw))
}

package main

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

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

	str, err := buf.ReadString('\n')
	if err != nil {
		panic(err)
	}
	// if str == "{}\n" || str == "()\n" {
	// 	fmt.Println("0")
	// 	return
	// }
	newStr := str[strings.Index(str, "{")+1 : strings.Index(str, "}")]
	if newStr == "" {
		fmt.Println("0")
		return
	}
	// fmt.Printf("NEWSTR: %v, len %v\n", newStr, len(newStr))
	res := make(map[string]int)
	chars := strings.Split(newStr, ", ")
	if len(chars) == 1 {
		fmt.Printf("%v\n", 1)
		return
	}
	for _, char := range chars {
		res[char]++
	}
	fmt.Printf("%v\n", len(res))
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	buffer, _ := reader.ReadBytes('}')
	set := make(map[byte]struct{})
	for i := 1; i < len(buffer)-1; i += 3 {
		set[buffer[i]] = struct{}{}
	}
	fmt.Println(len(set))
}

package main

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

func main() {
	var s string
	in := bufio.NewReader(os.Stdin)
	s, _ = in.ReadString('\n')
	//fmt.Fscanln(in, &s)
	//fmt.Println(s)
	ss := s[1:strings.Index(s, "}")]
	if len(ss) == 0 {
		fmt.Println(0)
	} else {
		split := strings.Split(ss, ",")
		distince := make(map[string]bool, 0)
		for _, v := range split {
			distince[strings.TrimSpace(v)] = true
		}
		ans := 0
		for _, _ = range distince {
			ans++
		}
		fmt.Println(ans)
	}
}

package main
import (
	"strings"
	"fmt"
	"bufio"
	"os"
)

func main() {
	var(
		data string
		set = make(map[string]int)
	)
	reader := bufio.NewReader(os.Stdin)
	bytes, _, _ := reader.ReadLine()
	data = string(bytes)
	data = strings.Replace(data, "{", "", 1)
	data = strings.Replace(data, "}", "", 1)
	for _, letter := range strings.Split(data, ", "){
		if "" != letter {
			_, ok := set[letter]
			if !ok {
				set[letter] = 1
			}
		}
	}

	fmt.Println(len(set))
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

//Wrong
func main() {
	defer writer.Flush()
	// scanner.Split(bufio.ScanWords)

	line := next()

	line = line[1:len(line) - 1]

	if len(line) == 0 {
		println(0)
		return
	}

	// chars := strings.Split(line, ", ")
	count := 0
	line = strings.Replace(line, ", ", "", -1)

	ch := make([]bool, 26)

	for i := range line {
		ch[line[i] - 'a'] = true
	}

	for i := range ch {
		if ch[i] {
			count++
		}
	}

	println(count)
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return n
}

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

func printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	set := scanner.Text()
	values := set[1 : len(set)-1]
	arrStr := strings.Split(values, ", ")

	if len(set) == 2 {
		fmt.Println(0)
		return
	}

	var length, i int64 = int64(len(arrStr)), 0
	temp := make(map[string]int64)
	for i = 0; i < length; i++ {
		_, ok := temp[arrStr[i]]

		if !ok {
			temp[arrStr[i]] = 1
		}
	}

	fmt.Println(len(temp))

}

package main

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

func main(){
    var (
        st string
        sc = bufio.NewScanner(os.Stdin)
        m =make(map[string]int)
        res = 0
        arr = []string{}
    )
    sc.Scan()
    st = sc.Text()
    st = st[1:len(st)-1]
    if st!=""{
        arr = strings.Split(st,",")
    }
    for i:=0;i<len(arr);i++{
        if len(arr[i])>1{
            arr[i]=arr[i][1:]
        }
        if _,ok:=m[arr[i]];ok==false{
            res++
            m[arr[i]]=1
        }
    }
    fmt.Println(res)
}

package main
import (
	"fmt"
	"unicode/utf8"
	"bufio"
	"os"
)
func main() {
	nn:=0
	var s string
	var u int
	input := bufio.NewScanner(os.Stdin)
	input.Scan()
	s = input.Text()
	len:= utf8.RuneCountInString(s)
	v :=make([]int,1005)
	fmt.Println()
	for i:=0;i<len;i++{
		if  (s[i]>='A' && s[i]<='Z') || (s[i]>='a' && s[i]<='z'){
			u =int(s[i]-'A')
			if v[u]==0 {
				nn++
			}
			v[u]=1
		}
	}
	fmt.Println(nn)
}

package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    str, _, _ := in.ReadLine()
    mp := map[byte]int{}
    for _, i := range str {
        if i >= 'a' && i <= 'z' {
            mp[i-byte('a')]++
        }
    }
    fmt.Println(len(mp))
}

package main

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

func main() {
	var text string
	var pattern *regexp.Regexp
	var index [][]int
	var alphabet [26]int
	var count int
	var scanner *bufio.Scanner

	pattern = regexp.MustCompile(`\w`)

	scanner = bufio.NewScanner(os.Stdin)
	scanner.Scan()
	text = scanner.Text()
	// fmt.Println(text)
	index = pattern.FindAllStringSubmatchIndex(text, -1)
	for _, second := range index {
		if alphabet[text[second[0]]-97] != 1 {
			count++
			alphabet[text[second[0]]-97] = 1
		}
	}

	fmt.Println(count)
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    var f [26]bool
    ans := 0
    for _, v := range scanner.Text() {
        if (v >= 'a') && (v <= 'z') {
            a := int(v-'a')
            if !f[a] { f[a] = true; ans++ }
        }
    }
    fmt.Println(ans)
}

package main

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

func main() {
	var input string
	// fmt.Scan(&input)
	in := bufio.NewReader(os.Stdin)
	input, _ = in.ReadString('\n')
	var results int
	if len(input) < 3 {
		fmt.Println(results)
		return
	}
	// input = input[1 : len(input)-2]
	records := make(map[rune]bool)
	for _, i := range input {
		if i < 97 || i > 122 {
			continue
		}
		records[i] = true
	}
	// fmt.Println(records)
	fmt.Println(len(records))
}

package main

import (
	"bufio"
	"os"

	"strings"
	"fmt"
)

func getString() string {
	sc := bufio.NewScanner(os.Stdin)
	for sc.Scan() {
		str := sc.Text()
		return str[1:len(str)-1]
	}
	return sc.Text()
}

func unique(str string) int {
	intSlice := []byte(str)
	keys := make(map[byte]bool)
	list := []byte{}
	for _, entry := range intSlice {
		if _, value := keys[entry]; !value {
			keys[entry] = true
			list = append(list, entry)
		}
	}
	return len(list)
}

func main() {
	str := getString()
	str = strings.Replace(str, ",", "", -1)
	str = strings.Replace(str, " ", "", -1)
	fmt.Println(unique(str))
}

package main

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

func main() {
	var s string
	in := bufio.NewReader(os.Stdin)
	s, _ = in.ReadString('\n')
	//fmt.Fscanln(in, &s)
	//fmt.Println(s)
	ss := s[1 : len(s)-1]
	if len(ss) == 0 {
		fmt.Println(0)
	} else {
		split := strings.Split(ss, ",")
		distince := make(map[string]bool, 0)
		for _, v := range split {

			distince[v] = true
		}
		ans := 0
		for _, _ = range distince {
			ans++
		}
		fmt.Println(ans)
	}
}

package main
import (
	"strings"
	"fmt"
	"bufio"
	"os"
)

func main() {
	var(
		data string
		set = make(map[string]int)
	)
	reader := bufio.NewReader(os.Stdin)
	bytes, _, _ := reader.ReadLine()
	data = string(bytes)
	data = strings.Replace(data, "{", "", 1)
	data = strings.Replace(data, "}", "", 1)
	fmt.Println(data)
	for _, letter := range strings.Split(data, ", "){
		if "" != letter {
			_, ok := set[letter]
			if !ok {
				set[letter] = 1
			}
		}
	}

	fmt.Println(len(set))
}

package main
import (
	"fmt"
//	"unicode/utf8"
	"bufio"
	"os"
)
func main() {
	nn:=0
	var s string
	var u int

	input := bufio.NewScanner(os.Stdin)
    	s = input.Text();
	//len:=utf8.RuneCountInString(s)
	//a:=[]rune(s)
	v :=make([]int,1005)
	for i:=0;i<len(s);i++ {
		fmt.Println(s[i])
	}
	for i:=0;i<len(s);i++ {
		if  (s[i]>='A' && s[i]<='Z') || (s[i]>='a' && s[i]<='b'){
			u =int(s[i]-'A')
			if v[u]==0 {
				nn++
			}
			v[u]=1
		}
	}
	fmt.Println(nn)
}

package main
import (
	"fmt"
	"unicode/utf8"
)
func main() {
	var s string
	nn:=0
	fmt.Scan(&s)
	len:=utf8.RuneCountInString(s)
	v :=make([]int,1005)
	for i:=0;i<len;i++ {
	if  (s[i]>='A' && s[i]<='z'){
		u:=int(s[i]-'A')
		if v[u]==0 {
		nn++
		}
		v[u]=1
	}
	}
	fmt.Println(nn)
}

package main
import (
	"fmt"
	"unicode/utf8"
	"bufio"
	"os"
)
func main() {
	nn:=0
	var s string
	var u int
	input := bufio.NewScanner(os.Stdin)
    	s = input.Text();
	len:=utf8.RuneCountInString(s)
	a:=[]rune(s)
	v :=make([]int,1005)
	for i:=0;i<len;i++ {
		fmt.Println(a[i])
	}
	for i:=0;i<len;i++ {
		if  (a[i]>='A' && a[i]<='Z') || (a[i]>='a' && a[i]<='b'){
			u =int(s[i]-'A')
			if v[u]==0 {
				nn++
			}
			v[u]=1
		}
	}
	fmt.Println(nn)
}

package main

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

func main() {
	var input string
	// fmt.Scan(&input)
	in := bufio.NewReader(os.Stdin)
	input, _ = in.ReadString('\n')
	var results int
	if len(input) < 3 {
		fmt.Println(results)
		return
	}
	// input = input[1 : len(input)-2]
	records := make(map[rune]bool)
	for _, i := range input {
		if i == '{' || i == '}' || i == ',' || i == ' ' || i == '\n' {
			continue
		}
		records[i] = true
	}
	// fmt.Println(records)
	fmt.Println(len(records))
}

package main

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

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt() uint64 {
    scanner.Scan()
    ans, _ := strconv.ParseUint(scanner.Text(), 10, 64)
    return ans
}

func PrintInt(value uint64) {
    writer.WriteString(strconv.FormatUint(value, 10))
    writer.WriteByte('\n')
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanLines)

    scanner.Scan()

    var line string = strings.Trim(scanner.Text(), "{}")
    var letters []string = strings.Split(line, ", ")
    var s map[string]bool = make(map[string]bool, 40)
    for _, val := range letters {
        s[val] = true
    }
    fmt.Println(len(s))
}

package main

import (
  "fmt"
)

const N = 500000

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

var v, stk [N]int

func main() {
  var line string
  letter := make(map[rune]bool)
  fmt.Scanln(&line)
  for _, char := range line {
    if 'a' <= char && char <= 'z' {
      letter[char] = true
    }
  }
  fmt.Println(len(letter))
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strings"
)

func main() {
	inputBytes, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	input := string(inputBytes)
	input = strings.NewReplacer("{", "", "}", "", "\n", "").Replace(input)

	var seen = map[string]struct{}{}
	var ok bool

	for _, symb := range strings.Split(input, ", ") {
		if _, ok = seen[symb]; ok || symb == "" {
			continue
		}
		seen[symb] = struct{}{}
	}

	fmt.Println(len(seen))
}

package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var s string

func main() {
	sb, _, _ := reader.ReadLine()
	s = string(sb)

	s = s[1:len(s)-1] + ","
	list := strings.Fields(s)
	m := make(map[string]int)
	for i := 0; i < len(list); i++ {
		m[list[i]] = 1
	}
	fmt.Println(len(m))
}

package main

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

type void struct{}

func main() {

	in := bufio.NewReader(os.Stdin)
	line, _ := in.ReadString('\n')

	set := make(map[string]void)
	var member void

	letters := strings.Replace(line, " ", "", -1)
	letters = strings.Replace(letters, "{", "", -1)
	letters = strings.Replace(letters, "}", "", -1)
	letters = strings.Replace(letters, "\n", "", -1)

	//letters := replacer.Replace(line)
	//fmt.Println(letters)
	if len(letters) == 0 {
		fmt.Println(0)
		return
	}
	values := strings.Split(letters, ",")

	for _, v := range values {
		set[v] = member
	}

	fmt.Println(len(set))

}

package main

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

type void struct{}

func main() {

	in := bufio.NewReader(os.Stdin)
	line, _ := in.ReadString('\n')

	set := make(map[string]void)
	var member void

	letters := strings.Trim(line, "{}")
	values := strings.Split(letters, ",")

	for _, v := range values {
		set[v] = member
	}

	fmt.Println(len(set))

}

package main

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

type void struct{}

func main() {

	in := bufio.NewReader(os.Stdin)
	line, _ := in.ReadString('\n')

	set := make(map[string]void)
	var member void

	letters := strings.Replace(line, " ", "", -1)
	letters = strings.Replace(letters, "{", "", -1)
	letters = strings.Replace(letters, "}", "", -1)
	letters = strings.Replace(letters, "\n", "", -1)

	//letters := replacer.Replace(line)
	//fmt.Println(letters)
	values := strings.Split(letters, ",")

	for _, v := range values {
		set[v] = member
	}

	fmt.Println(len(set))

}

package main

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

type void struct{}

func main() {

	in := bufio.NewReader(os.Stdin)
	line, _ := in.ReadString('\n')

	set := make(map[string]void)
	var member void

	letters := strings.Replace(line, " ", "", -1)
	letters = strings.Replace(letters, "{", "", -1)
	letters = strings.Replace(letters, "}", "", -1)
	letters = strings.Replace(letters, "\n", "", -1)

	//letters := replacer.Replace(line)
	fmt.Println(letters)
	values := strings.Split(letters, ",")

	for _, v := range values {
		set[v] = member
	}

	fmt.Println(len(set))

}

package main

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

func main() {
	// var s string
	// fmt.Scanln(&s)
	// fmt.Println(s)
	in := bufio.NewReader(os.Stdin)
	s, _ := in.ReadString('\n')

	m := make(map[string]bool)
	for _, tok := range strings.Split(s[1:len(s)-2], ", ") {
		m[tok] = true
	}
	delete(m, "")
	fmt.Println(m)
	fmt.Println(len(m))
}

package main

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

func main() {
	// var s string
	// fmt.Scanln(&s)
	// fmt.Println(s)
	in := bufio.NewReader(os.Stdin)
	s, _ := in.ReadString('\n')

	m := make(map[string]bool)
	for _, tok := range strings.Split(s[1:len(s)-2], ", ") {
		m[tok] = true
	}
	fmt.Println(len(m))
}

package main

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

func main() {
	// var s string
	// fmt.Scanln(&s)
	// fmt.Println(s)
	in := bufio.NewReader(os.Stdin)
	s, _ := in.ReadString('\n')

	m := make(map[string]bool)
	for _, tok := range strings.Split(s[1:len(s)-2], ", ") {
		m[tok] = true
	}
	delete(m, "")
	// fmt.Println(m)
	fmt.Println(len(m))
}

package main

import (
	"regexp"
	"fmt"
	"os"
	"strings"
)

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func main() {
	var str string
	m := make(map[string]string, 0)
	scanf("%s ", &str)
	reg, _ := regexp.Compile("[^a-z,]")
	match := reg.ReplaceAllString(str,"")

	charLength := strings.Split(match, ",")
	if len(charLength) > 1 {
		for _, c := range charLength {
			m[c] = c
		}
		printf("%d", len(m))
	}else{
		printf("%d", 0)
	}
}

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

func scanf(format string, x ...interface{}) {
	if _, err := fmt.Fscanf(os.Stdin, format, x...); err != nil {
		panic(err)
	}
}

package main

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

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func main() {
	var str string
	m := make(map[string]string, 0)
	reader := bufio.NewReader(os.Stdin)
	str, _ = reader.ReadString('\n')
	reg, _ := regexp.Compile("[^a-z,]")
	match := reg.ReplaceAllString(str,"")
	charLength := strings.Split(strings.TrimSpace(match), ",")
	if len(charLength) > 1 {
		idx := 0
		for _, c := range charLength {
			m[c] = c
			idx++
		}
		printf("%d", len(m))
	}else{
		printf("%d", 0)
	}
}

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

func scanf(format string, x ...interface{}) {
	if _, err := fmt.Fscanf(os.Stdin, format, x...); err != nil {
		panic(err)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	data, _, _ := reader.ReadLine()
	str := string(data)
	str = strings.Replace(str, " ", "", -1)
	str = strings.Replace(str, "{", "", -1)
	str = strings.Replace(str, "}", "", -1)
	slice := strings.Split(str, ",")

	temp := make([]string, 0)

	for _, s := range slice {
		flag := false
		for _, t := range temp {
			if s == t {
				flag = true
				break
			}
		}
		if flag == false {
			temp = append(temp, s)
		}
	}
	fmt.Println(len(temp))
}

package main

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

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

	str, err := buf.ReadString('\n')
	if err != nil {
		panic(err)
	}
	// if str == "{}\n" || str == "()\n" {
	// 	fmt.Println("0")
	// 	return
	// }
	newStr := str[strings.Index(str, "{")+1 : strings.Index(str, "}")]
	if newStr == "" {
		fmt.Println("0")
		return
	}
	// fmt.Printf("NEWSTR: %v, len %v\n", newStr, len(newStr))
	res := make(map[string]int)
	chars := strings.Split(newStr, ", ")
	if len(chars) == 1 {
		// fmt.Printf("%v\n", 1)
		return
	}
	for _, char := range chars {
		res[char]++
	}
	fmt.Printf("%v\n", len(res))
}

package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	// for {

	str, err := buf.ReadString('\n')
	if err != nil {
		panic(err)
	}
	if str == "{}\n" || str == "()\n" {
		fmt.Println("0")
		return
		// continue
	}
	newStr := str[1 : len(str)-2]
	// fmt.Println(newStr)
	// fmt.Println("%v", len(newStr))
	res := make(map[string]int)
	for _, char := range strings.Split(newStr, ", ") {
		// fmt.Printf("char %v", char)
		res[char]++
	}
	fmt.Printf("%v\n", len(res))
	// fmt.Printf("%#v\n", res)
	// }
}


package main

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

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int64
		fmt.Fscan(in, &n)
		if n&1 == 1 {
			fmt.Fprintln(out, 2)
		} else {
			if n&(n-1) == 0 {
				fmt.Fprintln(out, -1)
			} else {
				temp := n
				for temp&1 == 0 {
					temp >>= 1
				}
				if temp > n*2/temp {
					fmt.Fprintln(out, n*2/temp)
				} else {
					fmt.Fprintln(out, temp)
				}
			}
		}
	}
}

// (k-1 + X*2)*k

package main

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

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) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n,_ := strconv.ParseInt(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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt64(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(min(n*2/x, x))
		}
	}
}
func min(i, j int64) int64 {
	if i > j {
		return j
	}
	return i
}

package main

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

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

func CF1656D(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	c := 0
	fmt.Fscan(in, &c)
	for ; c > 0; c-- {
		var n uint64
		fmt.Fscan(in, &n)
		x := n
		for x % 2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Fprintln(out, -1)
		} else if x <= 2e9 && x*(x+1)/2 <= n {
			fmt.Fprintln(out, x)
		} else {
			fmt.Fprintln(out, n/x*2)
		}
	}
}

package main

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

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 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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(int64(min(n*2/x, x)))
		}
	}
}
func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

package main

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

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 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 main() {
	ip, op := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Fprintln(op, int64(-1))
		} else {
			fmt.Fprintln(op, int64(min(n*2/x, x)))
		}
	}
}
func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

package main

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

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 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 main() {
	ip,op := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Fprintln(op,-1)
		} else {
			fmt.Fprintln(op,min(n*2/x, x))
		}
	}
}
func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

package main

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

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 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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(min(n*2/x, x))
		}
	}
}
func min(i, j int) int {
	if i > j {
		return j
	}
	return i
}

package main

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

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 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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(min(n*2/x, x))
		}
	}
}
func min(i,j int)int{
	if i>j{
		return j
	}
	return i
}

package main

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

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 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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Println(-1)
		} else if (x*(x+1))/2 <= n {
			fmt.Println(x)
		} else {
			fmt.Println(2 * (n / x))
		}
	}
}

package main

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

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 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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x >>=1
		}
		if x == 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(2 * (n / x))
		}
	}
}

package main

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

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 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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Println(-1)
		} else if x <= 2e9 && (x*(x+1))/2 <= n {
			fmt.Println(x)
		} else {
			fmt.Println(2 * (n / x))
		}
	}
}

package main

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

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 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 main() {
	ip := bufio.NewReader(os.Stdin)
	t := readInt(ip)
	for t > 0 {
		t--
		n := readInt(ip)
		x := n
		for x%2 == 0 {
			x /= 2
		}
		if x == 1 {
			fmt.Println(-1)
		} else if x <= 2e9 && (x*(x+1)/2 <= n) {
			fmt.Println(x)
		} else {
			fmt.Println(2 * (n / x))
		}
	}
}

package main

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

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int64
		fmt.Fscan(in, &n)
		if n&1 == 1 {
			fmt.Fprintln(out, 2)
		} else {
			if n&(n-1) == 0 {
				fmt.Fprintln(out, -1)
			} else {
				temp := n
				for temp&1 == 0 {
					temp >>= 1
				}
				if temp*(temp+1) > 2*n {
					fmt.Fprintln(out, n*2/temp)
				} else {
					fmt.Fprintln(out, temp)
				}
			}
		}
	}
}

// (k-1 + X*2)*k

package main

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

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int64
		fmt.Fscan(in, &n)
		if n&1 == 1 {
			fmt.Fprintln(out, 2)
		} else {
			if n&(n-1) == 0 {
				fmt.Fprintln(out, -1)
			} else {
				temp := n
				for temp&1 == 0 {
					temp >>= 1
				}
				if temp*(temp+1) > 1*n {
					fmt.Fprintln(out, n*2/temp)
				} else {
					fmt.Fprintln(out, temp)
				}

			}
		}
	}
}

// (k-1 + X*2)*k

package main

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

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int64
		fmt.Fscan(in, &n)
		if n&1 == 1 {
			fmt.Fprintln(out, 2)
		} else {
			if n&(n-1) == 0 {
				fmt.Fprintln(out, -1)
			} else {
				temp := n
				for temp&1 == 0 {
					temp >>= 1
				}
				if temp*(temp-1) > 2*n {
					fmt.Fprintln(out, n*2/temp)
				} else {
					fmt.Fprintln(out, temp)
				}

			}
		}
	}
}

// (k-1 + X*2)*k

package main

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

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int64
		fmt.Fscan(in, &n)
		if n&1 == 1 {
			fmt.Fprintln(out, 2)
		} else {
			if n&(n-1) == 0 {
				fmt.Fprintln(out, -1)
			} else {
				temp := n
				for temp&1 == 0 {
					temp >>= 1
				}
				if temp*(temp-1) > n {
					fmt.Fprintln(out, n*2/temp)
				} else {
					fmt.Fprintln(out, temp)
				}

			}
		}
	}
}

// (k-1 + X*2)*k

package main

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

// 1 2 3 4
func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var n int64
		fmt.Fscan(in, &n)
		if n&1 == 1 {
			fmt.Fprintln(out, 2)
		} else {
			if n&(n-1) == 0 {
				fmt.Fprintln(out, -1)
			} else {
				temp := n
				for temp&1 == 0 {
					temp >>= 1
				}
				fmt.Fprintln(out, temp)
			}
		}
	}
}

// (k-1 + X*2)*k


package main

import (
	"fmt"
)

func main() {
	var N, M, K, L int64
	fmt.Scan(&N, &M, &K, &L)
	minCount := K + L
	if minCount > N {
		// Not enough coins to meet condition 3
		fmt.Println(-1)
	} else {
		// Cannot use math.Ceil here because float64 is not that acurate
		eachBuy := minCount / M
		if minCount%M > 0 {
			eachBuy++
		}
		// Not enough coins to meet condition 1
		if eachBuy*M > N {
			fmt.Println(-1)
		} else {
			fmt.Println(eachBuy)
		}
	}
}

package main

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

var (
  in *bufio.Reader
  out *bufio.Writer
)

func main() {
  in = bufio.NewReader(os.Stdin)
  out = bufio.NewWriter(os.Stdout)
  var N,M,K,L int64
  fmt.Fscanln(in, &N,&M,&K,&L)
  L += K
  ans := L/M
  if ans*M != L {
    ans++
  }

  if ans*M <= N {
    fmt.Println(ans)
  } else {
    fmt.Println(-1)
  }

  return
}

package main

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

var (
  in *bufio.Reader
  out *bufio.Writer
)

func main() {
  in = bufio.NewReader(os.Stdin)
  out = bufio.NewWriter(os.Stdout)
  var N,M,K,L int64
  fmt.Fscanln(in, &N,&M,&K,&L)
  //fmt.Println(N,M,K,L)
  if N < M {
    fmt.Println(-1)
    return
  }

  var ans int64
  if L%M == 0 {
    ans = L/M
  } else {
    ans = L/M + 1
  }
  fmt.Println(ans)
  return
}

package main

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

var (
  in *bufio.Reader
  out *bufio.Writer
)

func main() {
  in = bufio.NewReader(os.Stdin)
  out = bufio.NewWriter(os.Stdout)
  var N,M,K,L int64
  fmt.Fscanln(in, &N,&M,&K,&L)
  //fmt.Println(N,M,K,L)
  if N < M || L > N {
    fmt.Println(-1)
    return
  }
  L += K
  var ans int64
  if L%M == 0 {
    fmt.Println(L/M)
  } else {
    ans = L/M +1
    if ans*M > N {
     fmt.Println(-1)
    } else {
     fmt.Println(ans)
    }
  }

  return
}

package main

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

var (
  in *bufio.Reader
  out *bufio.Writer
)

func main() {
  in = bufio.NewReader(os.Stdin)
  out = bufio.NewWriter(os.Stdout)
  var N,M,K,L int64
  fmt.Fscanln(in, &N,&M,&K,&L)
  //fmt.Println(N,M,K,L)
  if N < M || L > N {
    fmt.Println(-1)
    return
  }

  var ans int64
  if L%M == 0 {
    fmt.Println(L/M)
  } else {
    ans = L/M +1
    if ans*M > N {
     fmt.Println(-1)
    } else {
     fmt.Println(ans)
    }
  }

  return
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var N, M, K, L int64
	fmt.Scan(&N, &M, &K, &L)
	minCount := K + L
	if minCount > N {
		// Not enough coins to meet condition 3
		fmt.Println(-1)
	} else {
		eachBuy := int64(math.Ceil(float64(minCount) / float64(M)))
		// Not enough coins to meet condition 1
		if eachBuy*M > N {
			fmt.Println(-1)
		} else {
			fmt.Println(eachBuy)
		}
	}
}


package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
// https://www.codementor.io/@tucnak/using-golang-for-competitive-programming-h8lhvxzt3

func main() {
	var T int
	scanf("%d\n", &T)
	for tt := 0; tt < T; tt++ {
		var N int
		scanf("%d\n", &N)
		//fmt.Printf("%d test case has N=%d\n", tt, N)

		arr := make([]int, N)
		var a int
		for i := 0; i < N; i++ {
			if i != N - 1 {
				scanf("%d ", &a)
			} else {
				scanf("%d\n", &a)
			}
			arr[i] = a
		}

		ppsum := make([][]int, 27)

		for i := 1; i < 27; i++ {
			ppsum[i] = make([]int, N + 2)
			ppsum[i][0] = 0

			for j, e := range arr {
				if e == i {
					ppsum[i][j + 1] = ppsum[i][j] + 1
				} else {
					ppsum[i][j + 1] = ppsum[i][j]
				}
			}

			ppsum[i][N+1] = ppsum[i][N]
		}

		csum := func(l int, r int, e int) int {
			return ppsum[e][r] - ppsum[e][l - 1]
		}

		min := func(l int, r int) int {
			if l < r {
				return l
			} else {
				return r
			}
		}

		ans := 0

		for i, _ := range arr {
			for j, _ := range arr {
				if j < i {
					continue
				}

				m := 0

				for k := 1; k < 27; k++ {
					if tmp := csum(i+1, j+1, k); tmp > m {
						m = tmp
					}
				}

				r := 0

				for k := 1; k < 27; k++ {
					if tmp := min(csum(1, i, k), csum(j+2, N+1, k)); tmp > r {
						r = tmp
					}
				}

				if r * 2 + m > ans {
					ans = r * 2 + m
				}
			}
		}

		defer writer.Flush()
		printf("%d\n", ans)
	}
}

package main

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

func solve() {

	n := fs()

	input := make([]int, n+1)
	pos := make([][]int, 201)
	freq := make([][]int, 201)

	for i := 1; i < 201; i++ {
		pos[i] = make([]int, 0)
		freq[i] = make([]int, n+1)
	}
	for i := 1; i <= n; i++ {
		input[i] = fs()
		pos[input[i]] = append(pos[input[i]], i)
	}

	for i := 1; i < 201; i++ {
		for j := 1; j <= n; j++ {
			if input[j] == i {
				freq[i][j]++
			}
			freq[i][j] += freq[i][j-1]
		}
	}

	ans := 0
	for i := 1; i < 201; i++ {
		ans = max(ans, freq[i][n])
	}
	var left, right, l, r int

	for i := 1; i < 201; i++ {

		m := len(pos[i])
		left, right = 0, m-1

		for left < right {
			l = pos[i][left]
			r = pos[i][right]
			mid := 0
			for j := 1; j < 201; j++ {
				if i == j {
					continue
				}
				mid = max(mid, freq[j][r-1]-freq[j][l])
			}
			ans = max(ans, mid+2*(left+1))
			left++
			right--
		}
	}
	fmt.Println(ans)
}

func main() {

	in, err := os.Open("input.txt")
	if err == nil {
		os.Stdin = in
	}
	bytes, _ = ioutil.ReadAll(bufio.NewReader(os.Stdin))
	maxV = len(bytes) - 1

	testcase := fs()

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

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

var bytes []byte
var l, maxV int

func fs() int {
	b := bytes[l]

	for b < 48 || b > 57 {
		l++
		b = bytes[l]
	}

	result := 0
	for 47 < b && b < 58 {
		result = (result << 3) + (result << 1) + int(b-48)

		l++
		if l > maxV {
			return result
		}
		b = bytes[l]
	}
	return result
}

package main

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

const M = 200
const N = 200010
var nt int
var n int
var a[N] int

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

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d\n", &nt)
	for kk := 0; kk < nt; kk++ {
		fmt.Fscanf(reader, "%d\n", &n)
		for i := 1; i <= n; i++ {
			fmt.Fscanf(reader, "%d", &a[i])
			a[i]--
		}
		fmt.Fscanf(reader, "\n")

		var at = make([][]int, M)
		for i := 0; i < M; i++ {
			at[i] = make([]int, 0)
		}

		var prefix = make([][]int, M)
		for i := 0; i < M; i++ {
			prefix[i] = make([]int, n + 1)
		}

		for i := 1; i <= n; i++ {
			for j := 0; j < M; j++ {
				prefix[j][i] = prefix[j][i - 1]
				if j == a[i] {
					prefix[j][i]++
				}
			}
			at[a[i]] = append(at[a[i]], i)
		}

		var ret = 0
		for i := 0; i < M; i++ {
			var z = prefix[i][n]
			ret = max(ret, z)
			for c := 1; c * 2 <= z; c++ {
				var from = at[i][c - 1] + 1
				var to = at[i][z - c] - 1

				for j := 0; j < M; j++ {
					ret = max(ret, 2 * c + prefix[j][to] - prefix[j][from - 1])
				}
			}
		}
		fmt.Fprintf(writer, "%d\n", ret)
	}

}

// Author: sighduck
// URL: https://codeforces.com/contest/1335/problem/E2

package main

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

const MaxElem = 200

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func Solve(n int, a []int) int {
	count := make([][]int, MaxElem+1)
	for i := 0; i <= MaxElem; i++ {
		count[i] = make([]int, n)
	}
	indexes := make([][]int, MaxElem+1)
	for i, elem := range a {
		count[elem][i] += 1
		indexes[elem] = append(indexes[elem], i)
	}
	for i := 1; i <= MaxElem; i++ {
		for j := 1; j < n; j++ {
			count[i][j] += count[i][j-1]
		}
	}
	ans := 0
	for i := 1; i <= MaxElem; i++ {
		ans = max(ans, len(indexes[i]))
		for j := 0; j < len(indexes[i])/2; j++ {
			l := indexes[i][j] + 1
			r := indexes[i][len(indexes[i])-1-j] - 1
			for k := 1; k <= MaxElem; k++ {
				s := (j+1)*2 + count[k][r] - count[k][l-1]
				ans = max(ans, s)
			}
		}
	}
	return ans
}

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscanf(reader, "%d\n", &n)
		a := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscanf(reader, "%d", &a[i])
		}
		fmt.Fscanf(reader, "\n")
		fmt.Fprintf(writer, "%d\n", Solve(n, a))
	}
}

package main

import (
	"fmt"
	"os"
)

func solve() {

	var n int
	fmt.Scan(&n)

	input := make([]int, n)

	for i := 0; i < n; i++{
		fmt.Scan(&input[i])
	}

	freq := make([][]int, 26)
	for i := 0; i < 26; i++ {
		freq[i] = make([]int, n)
	}

	for i := 0; i < 26; i++ {
		for j := 0; j < n; j++ {
			if input[j] - 1 == i {
				freq[i][j]++
			}
			if j - 1 > -1 {
				freq[i][j] += freq[i][j - 1]
			}
		}
	}

	ans := 0
	for i := 0; i < 26; i++ {
		ans = max(ans, freq[i][n - 1])
	}

	for l := 1; l < n - 1; l++ {
		for r := l; r < n - 1 ; r++ {
			edge, mid := 0, 0

			for x := 0; x < 26; x++ {
				edge = max(edge, min(freq[x][l - 1], freq[x][n - 1] - freq[x][r]))
				mid = max(mid, freq[x][r] - freq[x][l - 1])
			}
			ans = max(ans, 2 * edge + mid)
		}
	}
	fmt.Println(ans)

}

func main() {

	in, err := os.Open("input.txt")
	if err == nil {
		os.Stdin = in
	}

	testcase := 1
	fmt.Scan(&testcase)

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

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

package main

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

func solve() {

	n := fs()
	input := make([]int, n)

	for i := 0; i < n; i++{
		input[i] = fs()
	}

	freq := make([][]int, 26)
	for i := 0; i < 26; i++ {
		freq[i] = make([]int, n)
	}

	for i := 0; i < 26; i++ {
		for j := 0; j < n; j++ {
			if input[j] - 1 == i {
				freq[i][j]++
			}
			if j - 1 > -1 {
				freq[i][j] += freq[i][j - 1]
			}
		}
	}

	ans := 0
	for i := 0; i < 26; i++ {
		ans = max(ans, freq[i][n - 1])
	}

	for l := 1; l < n - 1; l++ {
		for r := l; r < n - 1 ; r++ {
			edge, mid := 0, 0

			for x := 0; x < 26; x++ {
				edge = max(edge, min(freq[x][l - 1], freq[x][n - 1] - freq[x][r]))
				mid = max(mid, freq[x][r] - freq[x][l - 1])
			}
			ans = max(ans, 2 * edge + mid)
		}
	}
	fmt.Println(ans)

}

func main() {

	in, err := os.Open("input.txt")
	if err == nil {
		os.Stdin = in
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(os.Stdin))
	maxV = len(bytes) - 1

	testcase := 1
	testcase = fs();

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

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

var bytes []byte
var l, maxV int

func fs() int {
	b := bytes[l]

	for b < 48 || b > 57 {
		l++
		b = bytes[l]
	}

	result := 0
	for 47 < b && b < 58 {
		result = (result << 3) + (result << 1) + int(b-48)

		l++
		if l > maxV {
			return result
		}
		b = bytes[l]
	}
	return result
}

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    // adjust the following size as needed
    // 2 << 17 is good enough to scan strings of len 2*10^5
    // it could go as high as 2 << 26 before cf judge breaks
    size := 2 << 20
    buf := make([]byte, size)
    s.Buffer(buf, size)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t -- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        writer.Printf("%d\n", sol(aa))
    }
}

func sol(aa []int64) int64 {
    maxSoFar := int64(0)
    for i := int64(1); i <= 200; i++ {
        for j := int64(1); j <= 200; j++ {
            newArr := []int64{}
            count0 := int64(0)
            count1 := int64(0)
            for _, a := range aa {
                if a == i {
                    newArr = append(newArr, 0)
                    count0++
                } else if a == j {
                    newArr = append(newArr, 1)
                    count1++
                }
            }
            if len(newArr) > 0 {
                maxSoFar = max(maxSoFar, solve(newArr, count0, count1))
            }
        }
    }
    if maxSoFar == 0 {
        return 1
    }
    return maxSoFar
}

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

func solve(arr []int64, count0, count1 int64) int64 {
    lp := -1
    rp := len(arr)
    sideCount := int64(0)
    midCount := count1
    maxSoFar := midCount
    for {
        lp++
        for lp < len(arr) && arr[lp] != 0 {
            midCount--
            lp++
        }
        rp--
        for rp > -1 && arr[rp] != 0 {
            midCount--
            rp--
        }
        if lp >= rp {
            break
        }
        sideCount++
        maxSoFar = max(maxSoFar, sideCount*2 + midCount)
    }
    return maxSoFar
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
// https://www.codementor.io/@tucnak/using-golang-for-competitive-programming-h8lhvxzt3

func main() {
	var T int
	scanf("%d\n", &T)
	for tt := 0; tt < T; tt++ {
		var N int
		scanf("%d\n", &N)
		//fmt.Printf("%d test case has N=%d\n", tt, N)

		arr := make([]int, N)
		var a int
		for i := 0; i < N; i++ {
			if i != N - 1 {
				scanf("%d ", &a)
			} else {
				scanf("%d ", &a)
			}
			arr[i] = a
		}

		ppsum := make([][]int, 27)

		for i := 1; i < 27; i++ {
			ppsum[i] = make([]int, N + 2)
			ppsum[i][0] = 0

			for j, e := range arr {
				if e == i {
					ppsum[i][j + 1] = ppsum[i][j] + 1
				} else {
					ppsum[i][j + 1] = ppsum[i][j]
				}
			}

			ppsum[i][N+1] = ppsum[i][N]
		}

		csum := func(l int, r int, e int) int {
			return ppsum[e][r] - ppsum[e][l - 1]
		}

		min := func(l int, r int) int {
			if l < r {
				return l
			} else {
				return r
			}
		}

		ans := 0

		for i, _ := range arr {
			for j, _ := range arr {
				if j < i {
					continue
				}

				m := 0

				for k := 1; k < 27; k++ {
					if tmp := csum(i+1, j+1, k); tmp > m {
						m = tmp
					}
				}

				r := 0

				for k := 1; k < 27; k++ {
					if tmp := min(csum(1, i, k), csum(j+2, N+1, k)); tmp > r {
						r = tmp
					}
				}

				if r * 2 + m > ans {
					ans = r * 2 + m
				}
			}
		}

		defer writer.Flush()
		printf("%d\n", ans)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
// https://www.codementor.io/@tucnak/using-golang-for-competitive-programming-h8lhvxzt3

func main() {
	var T int
	scanf("%d\n", &T)
	for tt := 0; tt < T; tt++ {
		var N int
		scanf("%d\n", &N)

		arr := make([]int, N)
		var a int
		for i := 0; i < N; i++ {
			scanf("%d", &a)
			arr[i] = a
		}

		ppsum := make([][]int, 27)

		for i := 1; i < 27; i++ {
			ppsum[i] = make([]int, N + 2)
			ppsum[i][0] = 0

			for j, e := range arr {
				if e == i {
					ppsum[i][j + 1] = ppsum[i][j] + 1
				} else {
					ppsum[i][j + 1] = ppsum[i][j]
				}
			}

			ppsum[i][N+1] = ppsum[i][N]
		}

		csum := func(l int, r int, e int) int {
			return ppsum[e][r] - ppsum[e][l - 1]
		}

		min := func(l int, r int) int {
			if l < r {
				return l
			} else {
				return r
			}
		}

		ans := 0

		for i, _ := range arr {
			for j, _ := range arr {
				if j < i {
					continue
				}

				m := 0

				for k := 1; k < 27; k++ {
					if tmp := csum(i+1, j+1, k); tmp > m {
						m = tmp
					}
				}

				r := 0

				for k := 1; k < 27; k++ {
					if tmp := min(csum(1, i, k), csum(j+2, N+1, k)); tmp > r {
						r = tmp
					}
				}

				if r * 2 + m > ans {
					ans = r * 2 + m
				}
			}
		}

		defer writer.Flush()
		printf("%d\n", ans)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
// https://www.codementor.io/@tucnak/using-golang-for-competitive-programming-h8lhvxzt3

func main() {
	var T int
	scanf("%d\n", &T)
	for tt := 0; tt < T; tt++ {
		var N int
		scanf("%d\n", &N)

		arr := make([]int, N)
		var a int
		for i := 0; i < N; i++ {
			scanf("%d ", &a)
			arr[i] = a
		}

		ppsum := make([][]int, 27)

		for i := 1; i < 27; i++ {
			ppsum[i] = make([]int, N + 2)
			ppsum[i][0] = 0

			for j, e := range arr {
				if e == i {
					ppsum[i][j + 1] = ppsum[i][j] + 1
				} else {
					ppsum[i][j + 1] = ppsum[i][j]
				}
			}

			ppsum[i][N+1] = ppsum[i][N]
		}

		csum := func(l int, r int, e int) int {
			return ppsum[e][r] - ppsum[e][l - 1]
		}

		min := func(l int, r int) int {
			if l < r {
				return l
			} else {
				return r
			}
		}

		ans := 0

		for i, _ := range arr {
			for j, _ := range arr {
				if j < i {
					continue
				}

				m := 0

				for k := 1; k < 27; k++ {
					if tmp := csum(i+1, j+1, k); tmp > m {
						m = tmp
					}
				}

				r := 0

				for k := 1; k < 27; k++ {
					if tmp := min(csum(1, i, k), csum(j+2, N+1, k)); tmp > r {
						r = tmp
					}
				}

				if r * 2 + m > ans {
					ans = r * 2 + m
				}
			}
		}

		defer writer.Flush()
		printf("%d\n", ans)
	}
}

package main

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

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }
// https://www.codementor.io/@tucnak/using-golang-for-competitive-programming-h8lhvxzt3

func main() {
	var T int
	scanf("%d\n", &T)
	for tt := 0; tt < T; tt++ {
		var N int
		scanf("%d\n", &N)
		//fmt.Printf("%d test case has N=%d\n", tt, N)

		arr := make([]int, N)
		var a int
		for i := 0; i < N; i++ {
			if i != N - 1 {
				scanf("%d ", &a)
			} else {
				scanf("%d", &a)
			}
			arr[i] = a
		}

		ppsum := make([][]int, 27)

		for i := 1; i < 27; i++ {
			ppsum[i] = make([]int, N + 2)
			ppsum[i][0] = 0

			for j, e := range arr {
				if e == i {
					ppsum[i][j + 1] = ppsum[i][j] + 1
				} else {
					ppsum[i][j + 1] = ppsum[i][j]
				}
			}

			ppsum[i][N+1] = ppsum[i][N]
		}

		csum := func(l int, r int, e int) int {
			return ppsum[e][r] - ppsum[e][l - 1]
		}

		min := func(l int, r int) int {
			if l < r {
				return l
			} else {
				return r
			}
		}

		ans := 0

		for i, _ := range arr {
			for j, _ := range arr {
				if j < i {
					continue
				}

				m := 0

				for k := 1; k < 27; k++ {
					if tmp := csum(i+1, j+1, k); tmp > m {
						m = tmp
					}
				}

				r := 0

				for k := 1; k < 27; k++ {
					if tmp := min(csum(1, i, k), csum(j+2, N+1, k)); tmp > r {
						r = tmp
					}
				}

				if r * 2 + m > ans {
					ans = r * 2 + m
				}
			}
		}

		defer writer.Flush()
		printf("%d\n", ans)
	}
}

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    // adjust the following size as needed
    // 2 << 17 is good enough to scan strings of len 2*10^5
    // it could go as high as 2 << 26 before cf judge breaks
    size := 2 << 20
    buf := make([]byte, size)
    s.Buffer(buf, size)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t -- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        writer.Printf("%d\n", sol(aa))
    }
}

func sol(aa []int64) int64 {
    prefixes := make([]map[int64]int64, len(aa)+1)
    currMap := map[int64]int64{}
    prefixes[0] = currMap
    for i, a := range aa {
        tmp := copyMap(currMap)
        tmp[a]++
        prefixes[i+1] = tmp
        currMap = tmp
    }
    suffixes := make([]map[int64]int64, len(aa)+1)
    currMap = map[int64]int64{}
    suffixes[len(suffixes)-1] = currMap
    for i := len(aa)-1; i > -1; i-- {
        tmp := copyMap(currMap)
        tmp[aa[i]]++
        suffixes[i] = tmp
        currMap = tmp
    }
    //writer.Printf("prefixes: %v\n", prefixes)
    //writer.Printf("suffixes: %v\n", suffixes)
    maxSoFarEle := int64(0)
    maxSoFarCount := int64(0)
    for i := 0; i < len(aa)+1; i++ {
        maxEle, maxCount := tally(prefixes[i], suffixes[i])
        if maxCount > maxSoFarCount {
            maxSoFarEle = maxEle
            maxSoFarCount = maxCount
        }
    }
    countLeft := int64(0)
    ptrLeft := 0
    for {
        if aa[ptrLeft] == maxSoFarEle {
            countLeft++
        }
        ptrLeft++
        if countLeft == maxSoFarCount {
            break
        }
    }
    countRight := int64(0)
    ptrRight := len(aa)-1
    for {
        if aa[ptrRight] == maxSoFarEle {
            countRight++
        }
        ptrRight--
        if countRight == maxSoFarCount {
            break
        }
    }
    //writer.Printf("%d %d\n", ptrLeft, ptrRight)
    midMap := map[int64]int64{}
    for i := ptrLeft; i <= ptrRight; i++ {
        midMap[aa[i]]++
    }
    maxSoFar := int64(0)
    for _, n := range midMap {
        if n > maxSoFar {
            maxSoFar = n
        }
    }
    ret := (maxSoFarCount * 2) + maxSoFar
    if ret == 0 {
        return 1
    }
    return ret
}

func copyMap(m map[int64]int64) map[int64]int64 {
    ret := map[int64]int64{}
    for k, v := range m {
        ret[k] = v
    }
    return ret
}

// returns element, count
func tally(p, s map[int64]int64) (int64, int64) {
    retCount := int64(0)
    retElement := int64(0)
    for k, v := range p {
        if v2, ok := s[k]; ok {
            if v2 > retCount {
                retElement = k
                retCount = min(v, v2)
            }
        }
    }
    return retElement, retCount
}

func min(a, b int64) int64 {
    if a < b {
        return a
    }
    return b
}

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    // adjust the following size as needed
    // 2 << 17 is good enough to scan strings of len 2*10^5
    // it could go as high as 2 << 26 before cf judge breaks
    size := 2 << 20
    buf := make([]byte, size)
    s.Buffer(buf, size)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t -- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        writer.Printf("%d\n", sol(aa))
    }
}

func sol(aa []int64) int64 {
    total := map[int64]int64{}
    track := map[int64]int64{}
    for _, a := range aa {
        total[a]++
        track[a]++
    }
    maxSoFar := int64(0)
    maxSoFarEle := int64(0)
    for _, a := range aa {
        track[a]--
        totalLeft := total[a] - track[a]
        totalRight := track[a]
        bal := min(totalLeft, totalRight)
        if bal > maxSoFar {
            maxSoFar = bal
            maxSoFarEle = a
        }
    }
    ptrLeft := findLeftPtr(aa, maxSoFar, maxSoFarEle)
    ptrRight := findRightPtr(aa, maxSoFar, maxSoFarEle)
    writer.Printf("%d %d\n", ptrLeft, ptrRight)
    midMap := map[int64]int64{}
    for i := ptrLeft; i <= ptrRight; i++ {
        midMap[aa[i]]++
    }
    midMaxSoFar := int64(0)
    for _, n := range midMap {
        if n > midMaxSoFar {
            midMaxSoFar = n
        }
    }
    ret := (maxSoFar * 2) + midMaxSoFar
    if ret == 0 {
        return 1
    }
    return ret
}

func findLeftPtr(aa []int64, maxSoFar int64, maxSoFarEle int64) int64 {
    p := int64(0)
    for {
        if aa[p] == maxSoFarEle {
            maxSoFar--
        }
        p++
        if maxSoFar == 0 {
            break
        }
    }
    return p
}

func findRightPtr(aa []int64, maxSoFar int64, maxSoFarEle int64) int64 {
    p := int64(len(aa))-1
    for {
        if aa[p] == maxSoFarEle {
            maxSoFar--
        }
        p--
        if maxSoFar == 0 {
            break
        }
    }
    return p
}

func min(a, b int64) int64 {
    if a < b {
        return a
    }
    return b
}

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    NextInt() int
    NextInt64() int64
    NextString() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    // adjust the following size as needed
    // 2 << 17 is good enough to scan strings of len 2*10^5
    // it could go as high as 2 << 26 before cf judge breaks
    size := 2 << 20
    buf := make([]byte, size)
    s.Buffer(buf, size)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt() int {
    impl.Scan()
    bb := impl.Bytes()
    i := 0
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextInt64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) NextString() string {
    impl.Scan()
    return impl.Text()
}

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
    t := reader.NextInt64()
    for ; t > 0; t -- {
        n := reader.NextInt64()
        aa := []int64{}
        for ; n > 0; n-- {
            aa = append(aa, reader.NextInt64())
        }
        writer.Printf("%d\n", sol(aa))
    }
}

func sol(aa []int64) int64 {
    total := map[int64]int64{}
    track := map[int64]int64{}
    for _, a := range aa {
        total[a]++
        track[a]++
    }
    maxSoFar := int64(0)
    maxSoFarEle := int64(0)
    for _, a := range aa {
        track[a]--
        totalLeft := total[a] - track[a]
        totalRight := track[a]
        bal := min(totalLeft, totalRight)
        if bal > maxSoFar {
            maxSoFar = bal
            maxSoFarEle = a
        }
    }
    ptrLeft := findLeftPtr(aa, maxSoFar, maxSoFarEle)
    ptrRight := findRightPtr(aa, maxSoFar, maxSoFarEle)
    midMap := map[int64]int64{}
    for i := ptrLeft; i <= ptrRight; i++ {
        midMap[aa[i]]++
    }
    midMaxSoFar := int64(0)
    for _, n := range midMap {
        if n > midMaxSoFar {
            midMaxSoFar = n
        }
    }
    ret := (maxSoFar * 2) + midMaxSoFar
    if ret == 0 {
        return 1
    }
    return ret
}

func findLeftPtr(aa []int64, maxSoFar int64, maxSoFarEle int64) int64 {
    p := int64(0)
    for {
        if aa[p] == maxSoFarEle {
            maxSoFar--
        }
        p++
        if maxSoFar == 0 {
            break
        }
    }
    return p
}

func findRightPtr(aa []int64, maxSoFar int64, maxSoFarEle int64) int64 {
    p := int64(len(aa))-1
    for {
        if aa[p] == maxSoFarEle {
            maxSoFar--
        }
        p--
        if maxSoFar == 0 {
            break
        }
    }
    return p
}

func min(a, b int64) int64 {
    if a < b {
        return a
    }
    return b
}


package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanInt() int {
	sc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a
}

func scanInt64() int64 {
	sc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a
}

func scanFloat64() float64 {
	sc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a
}

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanString() string {
	sc.Scan(); return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr); wr.Flush()
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	in := scanInt()
	for t := 0; t < in; t++ {
		_ = scanInt()
		s := scanString()
		c := map[point]int{}

		p := point{0,0}
		c[p] = 0

		ans := p
		f := false
		mi := 1 << 31 -1

		for i, e := range s {
			switch e {
			case 'L':
				p.x++
			case 'R':
				p.x--
			case 'U':
				p.y++
			case 'D':
				p.y--
			}

			if val, ok := c[p]; ok {
				if mi > i-val+1 {
					ans = point{val+1,i+1}
					mi = i-val+1
					f = true
				}
			}

			c[p] = i+1
		}

		if !f {
			fmt.Println(-1)
		} else {
			fmt.Println(ans.x,ans.y)
		}
	}
}

type point struct {
	x int
	y int
}

package main

import "fmt"

const maxn int = 2e5 + 10

type pair struct {
	fir, sec int
}

var t int

func main() {
	fmt.Scan(&t)
	for ; t > 0; t-- {
		var n int
		var s string
		fmt.Scan(&n, &s)
		s = " " + s
		var ans, l, r, x, y = n + 1, 0, 0, 0, 0
		m := make(map[pair]int)
		m[pair{fir: 0, sec: 0}] = 1
		for i := 1; i < len(s); i++ {
			switch s[i] {
			case 'L':
				x--
			case 'R':
				x++
			case 'U':
				y++
			case 'D':
				y--
			}
			v := m[pair{fir: x, sec: y}]
			if v != 0 {
				if ans > (i - v + 1) {
					ans = i - v + 1
					l = v
					r = i
				}
			}
			m[pair{fir: x, sec: y}] = i + 1
		}
		if ans == (n + 1) {
			fmt.Println("-1")
		} else {
			fmt.Println(l, r)
		}
	}
}

package main

import "fmt"

const maxn int = 2e5 + 10

type pair struct {
	fir, sec int
}

var t int

func main() {
	fmt.Scan(&t)
	for cnt := 1; cnt <= t; cnt++ {
		var n int
		var s string
		fmt.Scan(&n, &s)
		s = " " + s
		var ans, l, r, x, y = n + 1, 0, 0, 0, 0
		m := make(map[pair]int)
		m[pair{fir: 0, sec: 0}] = 1
		for i := 1; i < len(s); i++ {
			switch s[i] {
			case 'L':
				x--
			case 'R':
				x++
			case 'U':
				y++
			case 'D':
				y--
			}
			v := m[pair{fir: x, sec: y}]
			if v != 0 {
				if ans > (i - v + 1) {
					ans = i - v + 1
					l = v
					r = i
				}
			}
			m[pair{fir: x, sec: y}] = i + 1
		}
		if ans == (n + 1) {
			fmt.Println("-1")
		} else {
			fmt.Println(l, r)
		}
	}
}

package main

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

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		var s string
		fmt.Fscanf(reader, "%d\n%s\n", &n, &s)
		l, r := optimize(s)
		if l == -1 {
			fmt.Fprintf(writer, "-1\n")
		} else {
			fmt.Fprintf(writer, "%d %d\n", l, r)
		}
	}
}

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

	mp := make(map[int64]int)
	mp[hash(0, 0)] = -1
	l, r := -2, n+1
	x, y := 0, 0
	for i, c := range s {
		switch c {
		case 'L':
			x--
		case 'R':
			x++
		case 'U':
			y++
		case 'D':
			y--
		}

		cord := hash(x, y)
		j, ok := mp[cord]
		if ok && (r-l+1 > i-j) {
			l, r = j+1, i
		}

		mp[cord] = i
	}

	return l + 1, r + 1
}

func hash(x, y int) int64 {
	return int64(x)*int64(1000000) + int64(y)
}

package main

import (
	"fmt"
)

type Point struct {
	x int
	y int
}

func main() {
	t := 0
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		n := 0
		fmt.Scanln(&n)
		s := ""
		fmt.Scanln(&s)
		l := 0
		r := -1
		x := 0
		y := 0
		m := make(map[Point]int)
		m[Point{x: 0, y: 0}] = 0
		for ii, v := range s {
			ii++
			switch v {
			case 'U':
				y++
			case 'D':
				y--
			case 'L':
				x--
			case 'R':
				x++
			}
			p := Point{x: x, y: y}
			oldP, exists := m[p]
			if exists {
				if r == -1 || ii - oldP < r - l {
					r = ii
					l = oldP
				}
			}
			m[p] = ii
		}
		if r == -1 {
			fmt.Println(-1)
		} else {
			fmt.Println(l + 1, r)
		}
	}
}

package main

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

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

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

type point struct {
	x int
	y int
}

func solve() {
	var n int
	scanf("%d\n", &n)
	var s string
	scanf("%s\n", &s)
	idx, len, x, y := -1, n+1, 0, 0
	m := make(map[point]int)
	m[point{x: 0, y: 0}] = 0

	for i := 0; i < n; i++ {
		switch s[i] {
		case 'L':
			x--
		case 'R':
			x++
		case 'U':
			y++
		case 'D':
			y--
		default:
			x++
		}
		p := point{x: x, y: y}
		if _, ok := m[p]; ok {
			l := i + 1 - m[p]
			if l < len {
				len = l
				idx = i + 1
			}
		}
		m[p] = i + 1
	}
	if len <= n {
		printf("%d %d\n", idx-len+1, idx)
	} else {
		printf("-1\n")
	}
}

func main() {
	t := 1
	scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
	writer.Flush()
}

package main

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

type point struct {
	x int
	y int
}
const MAXINT = 2147483647;
func main() {
	in := bufio.NewReader(os.Stdin);
	out := bufio.NewWriter(os.Stdout);
	var t, n int;
	fmt.Fscanln(in, &t);
	for i := 0; i < t; i++ {
		fmt.Fscanln(in, &n);
		cur := point{0, 0};
		var commands string;
		positions := map[point]int{};
		positions[cur] = 0;
		ansLeft := -1;
		ansRight := -1;
		minAns := MAXINT;
		fmt.Fscanln(in, &commands);
		for j := 1; j <= n; j++ {
			command := commands[j - 1];
			switch command {
				case 'L':
					cur.x--
				case 'R':
					cur.x++
				case 'U':
					cur.y++
				case 'D':
					cur.y--
			}
			if val, ok := positions[cur]; ok {
				ans := j - val;
				if (ans < minAns) {
					minAns = ans;
					ansLeft = val + 1;
					ansRight = j;
				}
			}
			positions[cur] = j;
		}
		if (ansLeft != -1) {
			fmt.Fprintln(out, ansLeft, ansRight);
		} else {
			fmt.Fprintln(out, "-1");
		}
	}
	out.Flush();
}

package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanInt() int {
	sc.Scan(); a,_ := strconv.Atoi(sc.Text()); return a
}

func scanInt64() int64 {
	sc.Scan(); a,_ := strconv.ParseInt(sc.Text(),10,64); return a
}

func scanFloat64() float64 {
	sc.Scan(); a,_ := strconv.ParseFloat(sc.Text(),64); return a
}

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanString() string {
	sc.Scan(); return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e); if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr); wr.Flush()
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	in := scanInt()
	T: for t := 0; t < in; t++ {
		_ = scanInt()
		s := scanString()
		c := map[point]int{}

		p := point{0,0}
		c[p] = 0

		for i, e := range s {
			switch e {
			case 'L':
				p.x++
			case 'R':
				p.x--
			case 'U':
				p.y++
			case 'D':
				p.y--
			}

			if val, ok := c[p]; ok {
				fmt.Println(val+1, i+1)
				continue T
			}

			c[p] = i+1
		}

		fmt.Println(-1)

	}
}

type point struct {
	x int
	y int
}

package main

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

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

	var t int
	fmt.Fscanf(reader, "%d\n", &t)
	for i := 0; i < t; i++ {
		var n int
		var s string
		fmt.Fscanf(reader, "%d\n%s\n", &n, &s)
		l, r := optimize(s)
		if l == -1 {
			fmt.Fprintf(writer, "-1\n")
		} else {
			fmt.Fprintf(writer, "%d %d\n", l, r)
		}
	}
}

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

	mp := make(map[int64]int)
	mp[hash(0, 0)] = -1
	l, r := -2, n+1
	x, y := 0, 0
	for i, c := range s {
		switch c {
		case 'L':
			x--
		case 'R':
			x++
		case 'U':
			y++
		case 'D':
			y--
		}

		cord := hash(x, y)
		j, ok := mp[cord]
		if ok {
			fmt.Println(j)
		}
		if ok && (r-l+1 > i-j) {
			l, r = j+1, i
		}

		mp[cord] = i
	}

	return l + 1, r + 1
}

func hash(x, y int) int64 {
	return int64(x)*int64(1000000) + int64(y)
}


package main

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

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s = re.ReplaceAllString(s, "")

		moves := [2]int{}
		l := [2][]int{make([]int, n), make([]int, n)}

		for i, c := range s {
			if c == 'r' {
				l[0][i] = 1
				l[1][i] = 1
			} else if c == 'b' {
				l[0][i] = 0
				l[1][i] = 0
			}
		}

		disorder_start := [2][2]int{}
		for i := 0; i < n; i++ {
			for j := 0; j < 2; j++ {
				if l[j][i] != (i+j)%2 {
					moves[j] += 1
					swap := false
					if disorder_start[j][(i+1)%2] < n {
						for k := max(disorder_start[j][(i+1)%2], i+1); k < n; k += 2 { // Swap with k
							if l[j][k] != (k+j)%2 {
								l[j][i], l[j][k] = l[j][k], l[j][i]
								swap = true
								for f := k + 2; f < n; f += 2 {
									if l[j][f] != (f+j)%2 {
										disorder_start[j][(i+1)%2] = f
										break
									}
								}
								break
							}
						}
					}
					if !swap { // Change color
						disorder_start[j][(i+1)%2] = n
						l[j][i] = (i + j) % 2
					}
				}
			}
		}

		if moves[0] < moves[1] {
			fmt.Println(moves[0])
		} else {
			fmt.Println(moves[1])
		}
	}
}

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

package main

import "fmt"
import "bufio"
import "os"

var bufin *bufio.Reader
var bufout *bufio.Writer

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

func cost(c []int, n int, color int) int {
	diff := make([]int, 2)
	for i := 0; i < n; i++ {
		if c[i] != color {
			diff[c[i]]++
		}
		color = 1 - color
	}

	ret := min(diff[0], diff[1])
	return ret + diff[0] - ret + diff[1] - ret
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n int
	fmt.Fscanf(bufin, "%d\n", &n)

	a := make([]byte, n)
	fmt.Fscanf(bufin, "%s\n", &a)

	c := make([]int, n)
	for i := 0; i < n; i++ {
		if a[i] == 'r' {
			c[i] = 0
		} else {
			c[i] = 1
		}
	}

	res := n
	for color := 0; color < 2; color++ {
		res = min(res, cost(c, n, color))
	}

	fmt.Fprintf(bufout, "%d\n", res)
}

// http://codeforces.com/problemset/problem/719/B
package main

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

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

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

func main() {
	var n int

	input := bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &n)

	if n == 1 {
		fmt.Println(0)
		return
	}

	even := make(map[rune]int)
	odd := make(map[rune]int)

	for i := 0; i < n; i++ {
		var t rune
		fmt.Fscanf(input, "%c", &t)
		if i % 2 == 0 {
			even[t]++
		} else {
			odd[t]++
		}
	}

	// Solve
	// b - odd, r - even
	swaps := min(even['b'], odd['r'])
	y := max(even['b'], odd['r'])
	p1 := swaps + (y - swaps)

	// b - even, r - odd
	swaps = min(even['r'], odd['b'])
	y = max(even['r'], odd['b'])
	p2 := swaps + (y - swaps)

	fmt.Println(min(p1, p2))
}

package main

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

func I(t interface{}, delim string) {
	fmt.Fscanf(r, "%v"+delim, t)
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var r *bufio.Reader
var w *bufio.Writer

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

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

	var a, b, ra, ba, rb, bb, n int

	I(&n, "\n")
	var s string
	I(&s, "\n")
	for i := 0; i < n; i++ {
		if (s[i] != 'r' && i%2 == 0) || (s[i] != 'b' && i%2 == 1) {
			if s[i] == 'r' {
				ra++
			} else {
				ba++
			}
		}
		if (s[i] != 'b' && i%2 == 0) || (s[i] != 'r' && i%2 == 1) {
			if s[i] == 'r' {
				rb++
			} else {
				bb++
			}
		}
	}
	a = abs(ra-ba) + min(ra, ba)
	b = abs(rb-bb) + min(rb, bb)
	O(min(a, b), "\n")
}

package main

import "fmt"
import "bufio"
import "os"

var bufin *bufio.Reader
var bufout *bufio.Writer

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

func cost(from int, to int) int {
	if from == to {
		return 0
	}
	return 1
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n int
	fmt.Fscanf(bufin, "%d\n", &n)

	a := make([]byte, n)
	fmt.Fscanf(bufin, "%s\n", &a)

	c := make([]int, n+1)
	for i := 0; i < n; i++ {
		if a[i] == 'r' {
			c[i+1] = 0
		} else {
			c[i+1] = 1
		}
	}

	f := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		f[i] = make([]int, 2)
		f[i][0] = n
		f[i][1] = n
	}
	f[0][0] = 0
	f[0][1] = 0

	for i := 1; i <= n; i++ {
		for j := 0; j < 2; j++ {
			f[i][j] = min(f[i][j], f[i-1][1-j]+cost(c[i], j))
			if i >= 2 {
				f[i][j] = min(f[i][j], f[i-2][j]+cost(c[i-1], j)+cost(c[i], 1-j)+1)
				f[i][j] = min(f[i][j], f[i-1][j]+cost(c[i], 1-j)+1)
			}
		}
	}

	res := min(f[n][0], f[n][1])
	fmt.Fprintf(bufout, "%d\n", res)
}

package main

import "fmt"
import "bufio"
import "os"

var bufin *bufio.Reader
var bufout *bufio.Writer

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

func cost(from int, to int) int {
	if from == to {
		return 0
	}
	return 1
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n int
	fmt.Fscanf(bufin, "%d\n", &n)

	a := make([]byte, n)
	fmt.Fscanf(bufin, "%s\n", &a)

	c := make([]int, n+1)
	for i := 0; i < n; i++ {
		if a[i] == 'r' {
			c[i+1] = 0
		} else {
			c[i+1] = 1
		}
	}

	f := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		f[i] = make([]int, 2)
		f[i][0] = n
		f[i][1] = n
	}
	f[0][0] = 0
	f[0][1] = 0

	for i := 1; i <= n; i++ {
		for j := 0; j < 2; j++ {
			f[i][j] = min(f[i][j], f[i-1][1-j]+cost(c[i], j))
			if (i >= 2) && (c[i-1] == j) && (c[i] == 1-j) {
				f[i][j] = min(f[i][j], f[i-2][j]+1)
			}
		}
	}

	res := min(f[n][0], f[n][1])
	fmt.Fprintf(bufout, "%d\n", res)
}

package main

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

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

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

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

func main() {
	var n int

	input := bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &n)

	if n == 1 {
		fmt.Println(0)
		return
	}

	even := make(map[rune]int)
	odd := make(map[rune]int)

	for i := 0; i < n; i++ {
		var t rune
		fmt.Fscanf(input, "%c", &t)
		if i % 2 == 0 {
			even[t]++
		} else {
			odd[t]++
		}

	}

	x1, x2 := even['b'] - odd['r'], odd['b'] - even['r']
	y1, y2 := even['r'] - odd['b'], odd['r'] - even['b']

	ans, ansy := 0, 0
	if (x1 <= 0 && x2 <= 0) || (x1 >= 0 && x2 >= 0) {
		ans = (x1 + x2) / 2
	} else {
		ans = min(abs(x1), abs(x2)) + (abs(x1 + x2) / 2)

	}

	if (y1 <= 0 && y2 <= 0) || (y1 >= 0 && y2 >= 0) {
		ansy = (y1 + y2) / 2
	} else {
		ansy = min(abs(y1), abs(y2)) + (abs(y1 + y2) / 2)

	}

	if ans < ansy {
		fmt.Println(ans)
	} else {
		fmt.Println(ansy)
	}

}

package main

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

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s = re.ReplaceAllString(s, "")

		moves := [2]int{}
		l := [2][]int{make([]int, n), make([]int, n)}

		for i, c := range s {
			if c == 'r' {
				l[0][i] = 1
				l[1][i] = 1
			} else if c == 'b' {
				l[0][i] = 0
				l[1][i] = 0
			}
		}

		for j := 0; j < 2; j++ {
			for i := 0; i < n; i++ {
				if l[j][i] != (i+j)%2 {
					moves[j] += 1
					swap := false
					for k := i + 1; k < n; k++ {
						if l[j][k] != (k+j)%2 {
							l[j][i], l[j][k] = l[j][k], l[j][i]
							swap = true
							break
						}
					}
					if !swap { // Change color
						l[j][i] = (i + j) % 2
					}
				}
			}
		}

		if moves[0] < moves[1] {
			fmt.Println(moves[0])
		} else {
			fmt.Println(moves[1])
		}
	}
}

package main

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

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		s = re.ReplaceAllString(s, "")

		moves := [2]int{}
		l := [2][]int{make([]int, n), make([]int, n)}

		for i, c := range s {
			if c == 'r' {
				l[0][i] = 1
				l[1][i] = 1
			} else if c == 'b' {
				l[0][i] = 0
				l[1][i] = 0
			}
		}

		for i := 0; i < n; i++ {
			for j := 0; j < 2; j++ {
				if l[j][i] != (i+j)%2 {
					moves[j] += 1
					if i < n-1 && l[j][i+1] != (i+j+1)%2 { // Swap
						l[j][i], l[j][i+1] = l[j][i+1], l[j][i]
					} else { // Change color
						l[j][i] = (i + j) % 2
					}
				}
			}
		}

		if moves[0] < moves[1] {
			fmt.Println(moves[0])
		} else {
			fmt.Println(moves[1])
		}
	}
}