package main

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

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

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

	mp := make(map[string]int)
	k := 1
	for i := 'a'; i <= 'z'; i++ {
		for j := 'a'; j <= 'z'; j++ {
			if i == j {
				continue
			}
			mp[string(i)+string(j)] = k
			k++
		}
	}
	t := 0
	str := ""
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		fmt.Fscan(in, &str)
		fmt.Fprintln(out, mp[str])
	}
}

package main

import "fmt"

func main() {
    var t int
    fmt.Scanf("%d\n", &t)
    for i := 0; i < t; i++ {
        var word string
        fmt.Scanf("%s\n", &word)
        temp := uint64(word[0] - 'a')*25
        if word[1] > word[0] {
            temp += uint64(word[1] - 'a')
        } else {
            temp += uint64(word[1] - 'a')
            temp++
        }
        fmt.Printf("%d\n", temp)
    }
}

package main

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

// source: https://codeforces.com/contest/1674/problem/B?locale=en

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

func solve() string {
	const letters = 25
	var s string
	fmt.Fscan(in, &s)
	var x, y = s[0], s[1]

	res := int64(x-'a')*letters + int64(y-'a')
	if x > y {
		res++
	}
	return strconv.FormatInt(res, 10)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscanln(in, &t); t > 0; t-- {
		fmt.Fprintln(out, solve())
	}
}

package main

import (
	"fmt"
	"strconv"
)

func solve2() string {
	const letters = 25
	var s string
	fmt.Scan(&s)
	var x, y = s[0], s[1]

	res := int64(x-'a')*letters + int64(y-'a')
	if x > y {
		res++
	}
	return strconv.FormatInt(res, 10)
}

func main() {
	var t int
	fmt.Scanln(&t)

	for i := 0; i < t; i++ {
		fmt.Println(solve2())
	}
}

package main

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

const mod = 998244353

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var str string
	fmt.Fscan(in, &str)
	ans := 0
	ans += (int(str[0]) - 'a') * 25
	ans += (int(str[1]) - 'a') + 1
	if str[1] > str[0] {
		ans--
	}
	fmt.Println(ans)
}

func abs(a int64) int64 {
	if a > 0 {
		return a
	}
	return -a
}
func sum(a, b int64) int64 {
	return (b + a) * (b - a + 1) / 2
}

func max(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}
func min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func gcd(a, b int) int {
	if a%b == 0 {
		return b
	}
	return gcd(b, a%b)
}

func main() {
	//stdin, _ := os.Open("/project/go/algo/input")
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	fmt.Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
var alphabet = []string{"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}

func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	mapper:= make(map[string]int)
	counter:=1
	for j:=0;j<26;j++{
		for k:=0;k<26;k++{
			if j != k {
				mapper[string(alphabet[j])+string(alphabet[k])]= counter
				counter++
			}
		}
	}
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var word string
		fmt.Fscan(in,&word)
		fmt.Fprintln(out,mapper[word])
	}
}

// https://codeforces.com/problemset/problem/1674/B

// 1674B - Dictionary

// The Berland language consists of words having exactly two letters. Moreover, the first letter of a word is different from the second letter. Any combination of two different Berland letters (which, by the way, are the same as the lowercase letters of Latin alphabet) is a correct word in Berland language.
// The Berland dictionary contains all words of this language. The words are listed in a way they are usually ordered in dictionaries. Formally, word a comes earlier than word b in the dictionary if one of the following conditions hold:
//  • the first letter of a is less than the first letter of b;
//  • the first letters of a and b are the same, and the second letter of a is less than the second letter of b.
// So, the dictionary looks like that:
//  • Word 1: ab
//  • Word 2: ac
//  • ...
//  • Word 25: az
//  • Word 26: ba
//  • Word 27: bc
//  • ...
//  • Word 649: zx
//  • Word 650: zy
// You are given a word s from the Berland language. Your task is to find its index in the dictionary.

// Input
// The first line contains one integer t (1≤t≤650) — the number of test cases.
// Each test case consists of one line containing s — a string consisting of exactly two different lowercase Latin letters (i. e. a correct word of the Berland language).

// Output
// For each test case, print one integer — the index of the word s in the dictionary.

// Example
// input
// 7
// ab
// ac
// az
// ba
// bc
// zx
// zy
// output
// 1
// 2
// 25
// 26
// 27
// 649
// 650

// Tutorial

// There are many different ways to solve this problem:
//  • generate all Berland words with two for-loops and store them in an array, then for each test case, go through the array of words to find the exact word you need;
//  • generate all Berland words with two for-loops and store them in a dictionary-like data structure (map in C++, dict in Python, etc), using words as keys and their numbers as values. This allows to search for the index of the given word quickly;
//  • for each test case, run two for-loops to iterate over the words, count the number of words we skipped, and stop at the word from the test case;
//  • try to invent some formulas that allow counting the number of words before the given one.

package main

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

func main() {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	var c int
	var t, i uint
	var s string
	var idx map[string]uint
	var chr1, chr2 byte

	i = 1
	idx = make(map[string]uint)

	for chr1 = 'a'; chr1 <= 'z'; chr1++ {
		for chr2 = 'a'; chr2 <= 'z'; chr2++ {
			if chr1 != chr2 {
				s = string(chr1) + string(chr2)
				idx[s] = i
				i++
			}
		}
	}

	for c, _ = fmt.Fscan(reader, &t); c == 1; c, _ = fmt.Fscan(reader, &t) {
		for ; t > 0; t-- {
			fmt.Fscan(reader, &s)
			fmt.Fprintln(writer, idx[s])
		}
	}

	writer.Flush()
}

package main

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

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

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var s string
		fmt.Fscan(in, &s)
		ans := (int(s[0])-int('a'))*26 + int(s[1]) - int('a') - int(s[0]) + int('a')
		if s[0] > s[1] {
			ans++
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1674B
Date: 10/05/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1674/B
Problem: CF1674B
**/
func (in *CF1674B) Run() {
	mapa := make(map[string]int)
	index := 1
	for i:= 'a'; i <= 'z'; i++{
		for j:='a';j<='z';j++{
			if i != j {
				mapa[fmt.Sprintf("%s%s", string(i), string(j))] = index
				index++
			}
		}
	}
	var str strings.Builder
	for t:=in.NextInt(); t > 0; t-- {
		str.WriteString(fmt.Sprintf("%d", mapa[in.NextString()]))
		str.WriteString("\n")
	}
	fmt.Print(str.String())
}

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

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

package main

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

var m = map[string]int{}

var letters = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}

func f() {
	m = make(map[string]int)
	count := 0
	for _, x := range letters {
		for _, y := range letters {
			if x == y {
				continue
			}
			count++
			m[x+y] = count
		}
	}
}

func main() {
	f()
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var s string
		fmt.Fscan(in, &s)
		fmt.Fprintln(out, m[s])
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		s := gs();
		idx := 25*int(s[0]-'a') + int(s[1]-'a') + 1
		if s[1] > s[0] { idx-- }
		fmt.Fprintln(wrtr,idx)
	}
}

package main

import (
	"fmt"
)

func getA(z, base int) int {
	result := 0
	for z != 1 {
		if z%base != 0 {
			return 0
		}
		z /= base
		result++
	}
	return result
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		var a, b byte
		fmt.Scanf("%c%c\n", &a, &b)
		result := int(a-'a') * int(25)
		if b < a {
			result += int(b - 'a')
		} else {
			result += int(b - 'a' - 1)
		}
		fmt.Println(result + 1)
	}
}

package main

import "fmt"

func sol() {
	var s string
	fmt.Scanf("%s\n", &s)
	var v1 = int(s[0] - 'a')
	var v2 = int(s[1] - 'a')
	var c int
	if v1 < v2 {
		c = v1*25 + v2
	} else {
		c = v1*25 + v2 + 1
	}
	fmt.Println(c)

}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		sol()
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		s, _ := reader.ReadString('\n')
		if s[len(s)-1] == 10 {
			s = s[:len(s)-1]
		}
		if s[len(s)-1] == 13 {
			s = s[:len(s)-1]
		}

		i := int(rune(s[0]) - 97)
		j := int(rune(s[1]) - 97)
		ans := ( ( 25 * i ) + j )
		if j < i {
			ans += 1
		}
		fmt.Println(ans)
	}
}

package main

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

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

	key := map[uint8]map[uint8]int{}

	cnt := 1
	for i := 0; i <= 25; i++ {
		key[uint8('a'+i)] = map[uint8]int{}
		for j := 0; j <= 25; j++ {
			if i == j {
				continue
			}
			key[uint8('a'+i)][uint8('a'+j)] = cnt
			cnt++
		}
	}

	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		var s string
		fmt.Fscan(in, &s)
		//fmt.Println(int(s[1]))
		//fmt.Fprintln(out, key[s[0]]+int(s[1])-int('a'))
		fmt.Fprintln(out, key[s[0]][s[1]])
	}
}

package main

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

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

func solve() {
	var s string
	fmt.Fscan(in, &s)
	c := 1
	if s[0] < s[1] {
		c = 0
	}
	fmt.Fprintf(out, "%d\n", int(s[0]-'a')*25+int(s[1])-'a'+c)
}

func main() {
	defer out.Flush()
	var t int
	for fmt.Fscan(in, &t); t > 0; t-- {
		solve()
	}
}

package main

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

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

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

		idx := 1
	Loop:
		for i := 0; i < 26; i++ {
			for j := 0; j < 26; j++ {
				if i == j {
					continue
				}

				if int(s[0]-'a') == i && int(s[1]-'a') == j {
					break Loop
				}
				idx++
			}
		}
		fmt.Fprintln(out, idx)
	}
}

package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		var a, b byte
		fmt.Scanf("%c%c\n", &a, &b)
		var res int
		res = 25*int(a-'a') + 1
		if b > a {
			res = res + int(b-'a'-1)
		} else {
			res = res + int(b-'a')
		}
		fmt.Println(res)
	}
}

package main

import "fmt"

func main() {
	var t int
    fmt.Scanf("%d\n",&t)
    for i:=1;i<=t;i++{
        var str string
        fmt.Scanf("%s\n",&str)
        ans:=(int(str[0])-'a')*26
        ans+=int(str[1])-'a'
        if str[0]>str[1]{
            ans-=int(str[0]-1)-'a'
        }else{
            ans-=int(str[0])-'a'
        }
        fmt.Println(ans)
    }
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var T int
	var S string
	var val,anc int32

	fmt.Fscan(in, &T)
	//list := make([]string,N)
	A := rune('a')
	for i := 0;i < T;i++{
		fmt.Fscan(in, &S)
		for num,l := range S{
			if num == 0{
				val = l - A
			}else{
				if (l - A + 1) > val{
					anc = val*25 + l - A
				}else{
					anc = val*25 + l - A + 1
				}
			}

		}
		fmt.Println(anc)

	}
}

package main

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

/*

 */

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

	fmt.Fprintln(writer, dict[s])
}

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

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

	dict := make(map[string]int)

	skipCnt := 0

	for i := 'a'; i <= 'z'; i++ {
		for j := 'a'; j <= 'z'; j++ {
			if i != j {
				word := []rune{i, j}
				idx := 26*int(i-'a') + int(j-'a') - skipCnt + 1

				dict[string(word)] = idx
			} else {
				skipCnt++
			}
		}
	}

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

const maxUint = ^uint(0)

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

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

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

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

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

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

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

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

	return minNumIdx
}

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

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

	return maxNumIdx
}

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

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

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

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

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

	return true
}

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

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

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

	num = abs(num)

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

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

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

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

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

	return factors
}

package main

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

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

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

	var T int
	var x string

	m := map[string]int{}
	idx := 1
	for i := 'a'; i <= 'z'; i++ {
		for j := 'a'; j <= 'z'; j++ {
			if i != j {
				m[string(i)+string(j)] = idx
				idx++
			}
		}
	}

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x)

		Fprintln(out, m[x])
	}
}

package main

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

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func slove() {
	defer w.Flush()
	var x string
	fmt.Fscan(r, &x)
	a := (int(x[0]) - 'a') * 25
	if x[1] > x[0] {
		a += int(x[1] - 'a')
	} else {
		a += int(x[1] - 'a') + 1
	}
	fmt.Fprintf(w, "%d\n", a)
}

func main() {
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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 abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	p := make([]string, 0)
	for i := byte('a'); i <= 'z'; i++ {
		for j := byte('a'); j <= 'z'; j++ {
			if i == j {
				continue
			}
			p = append(p, string([]byte{i, j}))
		}
	}

	for t := io.ReadInt(); t > 0; t-- {
		s := io.ReadString()
		for i, v := range p {
			if s == v {
				fmt.Println(i + 1)
				break
			}
		}
	}
}


package main

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

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

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

func main() {
	io := bufio.NewReader(os.Stdin)
	var n, a int
	fmt.Fscanf(io, "%d %d\n", &n, &a)

	coordinates := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io, "%d", &coordinates[i])
	}

	sort.Ints(coordinates)

	if n == 1 {
		fmt.Printf("%d\n", 0)
		os.Exit(0)
	}

	right := abs(coordinates[len(coordinates)-1]-a) + abs(coordinates[len(coordinates)-1]-coordinates[1])
	right = min(right, abs(coordinates[len(coordinates) - 2] - a) + abs(coordinates[len(coordinates) - 2] - coordinates[0]))
	left := abs(coordinates[0]-a) + abs(coordinates[len(coordinates)-2]-coordinates[0])
	left = min(left, abs(coordinates[1]-a) + abs(coordinates[len(coordinates)-1]-coordinates[1]))

	result := min(right, left)
	fmt.Printf("%d\n", result)
}

package main

import "bufio"
import "os"
import "sort"
import "strconv"

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

	n := readInt()
	a := readInt()
	x := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = readInt()
	}

	if n == 1 {
		write(0)
		return
	}

	sort.Ints(x)

	pos := 0
	for (pos < n) && (x[pos] <= a) {
		pos++
	}

	if pos <= 0 {
		res := x[n-2] - a
		write(res)
		return
	}

	if pos >= n {
		res := a - x[1]
		write(res)
		return
	}

	c1 := max(a-x[1], 0)
	c2 := x[n-1] - a
	r1 := min(2*c1+c2, 2*c2+c1)

	d1 := a - x[0]
	d2 := max(x[n-2]-a, 0)
	r2 := min(2*d2+d1, 2*d1+d2)

	write(min(r1, r2))
}

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

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

// Heap
type Node struct {
	name  int
	value int64
	index int
}

type NodeList []*Node

func (nodes NodeList) Len() int {
	return len(nodes)
}

func (nodes NodeList) Less(i int, j int) bool {
	return nodes[i].value < nodes[j].value
}

func (nodes NodeList) Swap(i int, j int) {
	nodes[i], nodes[j] = nodes[j], nodes[i]
	nodes[i].index = i
	nodes[j].index = j
}

func (nodes *NodeList) Push(x interface{}) {
	node := x.(*Node)
	node.index = len(*nodes)
	*nodes = append(*nodes, node)
}

func (nodes *NodeList) Pop() interface{} {
	s := *nodes
	last := len(s) - 1
	r := s[last]
	*nodes = s[:last]
	r.index = -1
	return r
}

// Int64Slice Sort
type Int64Slice []int64

func (s Int64Slice) Len() int               { return len(s) }
func (s Int64Slice) Less(i int, j int) bool { return s[i] < s[j] }
func (s Int64Slice) Swap(i int, j int)      { s[i], s[j] = s[j], s[i] }

// Input and Output
var in *bufio.Scanner
var out *bufio.Writer

func readString() string {
	in.Scan()
	return in.Text()
}

func readInt() int {
	in.Scan()
	val, _ := strconv.Atoi(in.Text())
	return val
}

func readInt64() int64 {
	in.Scan()
	val, _ := strconv.ParseInt(in.Text(), 10, 64)
	return val
}

func readFloat64() float64 {
	in.Scan()
	val, _ := strconv.ParseFloat(in.Text(), 64)
	return val
}

func write(args ...interface{}) {
	for i, e := range args {
		switch e.(type) {
		case string:
			out.WriteString(e.(string))
		case int:
			out.WriteString(strconv.Itoa(e.(int)))
		case int64:
			out.WriteString(strconv.FormatInt(e.(int64), 10))
		case float64:
			out.WriteString(strconv.FormatFloat(e.(float64), 'f', -1, 64))
		case []string:
			a := e.([]string)
			for j, x := range a {
				out.WriteString(x)
				if j+1 < len(a) {
					out.WriteByte(' ')
				}
			}
		case []int:
			a := e.([]int)
			for j, x := range a {
				out.WriteString(strconv.Itoa(x))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []int64:
			a := e.([]int64)
			for j, x := range a {
				out.WriteString(strconv.FormatInt(x, 10))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		case []float64:
			a := e.([]float64)
			for j, x := range a {
				out.WriteString(strconv.FormatFloat(x, 'f', -1, 64))
				if j+1 < len(a) {
					out.WriteByte(' ')
				}

			}
		default:
			out.WriteString("###")
		}
		if i+1 < len(args) {
			out.WriteByte(' ')
		}
	}
	out.WriteByte('\n')
}

package main

import (
	"fmt"
	"sort"
)

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

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

func main() {
	var n, a int
	fmt.Scanf("%d %d", &n, &a)

	coordinates := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &coordinates[i])
	}

	sort.Ints(coordinates)

	right := abs(coordinates[len(coordinates)-1]-a) + abs(coordinates[len(coordinates)-1]-coordinates[1])
	left := abs(coordinates[0]-a) + abs(coordinates[len(coordinates)-2]-coordinates[0])

	result := min(right, left)
	fmt.Printf("%d\n", result)
}

package main

import (
	"fmt"
	"sort"
)

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

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

func main() {
	var n, a int
	fmt.Scanf("%d %d", &n, &a)

	coordinates := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &coordinates[i])
	}

	sort.Ints(coordinates)

	right := abs(coordinates[len(coordinates)-1]-a) + abs(coordinates[len(coordinates)-1]-coordinates[1])
	right = min(right, abs(coordinates[len(coordinates) - 2] - a) + abs(coordinates[len(coordinates) - 2] - coordinates[0]))
	left := abs(coordinates[0]-a) + abs(coordinates[len(coordinates)-2]-coordinates[0])
	left = min(left, abs(coordinates[1]-a) + abs(coordinates[len(coordinates)-1]-coordinates[1]))

	result := min(right, left)
	fmt.Printf("%d\n", result)
}

package main

import "fmt"
import (
	"sort"
)

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

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

func main() {
	var n, a int
	fmt.Scanf("%d %d", &n, &a)

	coordinates := make([]int, n);
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &coordinates[i])
	}

	sort.Ints(coordinates)

	right := abs(coordinates[len(coordinates) - 1] - a) + abs(coordinates[len(coordinates) - 1] - coordinates[1])
	left := abs(coordinates[0] - a) + abs(coordinates[len(coordinates) - 2] - coordinates[0]);

	result := min(right, left);
	fmt.Printf("%d\n", result)
}

package main

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

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

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

func main() {
	io := bufio.NewReader(os.Stdin)
	var n, a int
	fmt.Fscanf(io, "%d %d\n", &n, &a)

	coordinates := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(io, "%d", &coordinates[i])
	}

	sort.Ints(coordinates)

	if n == 1 {
		fmt.Printf("%d\n", abs(coordinates[0] - a))
		os.Exit(0)
	}

	right := abs(coordinates[len(coordinates)-1]-a) + abs(coordinates[len(coordinates)-1]-coordinates[1])
	right = min(right, abs(coordinates[len(coordinates) - 2] - a) + abs(coordinates[len(coordinates) - 2] - coordinates[0]))
	left := abs(coordinates[0]-a) + abs(coordinates[len(coordinates)-2]-coordinates[0])
	left = min(left, abs(coordinates[1]-a) + abs(coordinates[len(coordinates)-1]-coordinates[1]))

	result := min(right, left)
	fmt.Printf("%d\n", result)
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"strings"
)

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		n*=2
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Ints(a)
		ans := make([]int, n)
		i := 0
		for ;i<n;i+=2 {
			v := a[0]
			a = a[1:]
			ans[i] = v
		}
		i=1
		for ;i<n;i+=2 {
			v := a[0]
			a = a[1:]
			ans[i] = v
		}
		for _, v := range ans {
			Fprint(out, v, " ")
		}
		Fprintln(out)
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

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

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)

		arr := make([]int, 2*n+1)
		ans := make([]int, 2*n+1)

		for i := 1; i <= 2*n; i++ {
			_, _ = fmt.Fscan(in, &arr[i])
		}

		sort.Ints(arr)

		for i := 1; i <= n; i++ {
			ans[2*i] = arr[i]
			ans[2*i-1] = arr[n+i]
		}

		for i := 1; i <= 2*n; i++ {
			fmt.Printf("%d ", ans[i])
		}
		fmt.Println()
	}
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n := 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n)
		o := make([]int, 2*n)
		for j := 0; j < 2*n; j++ {
			fmt.Fscan(f, &o[j])
		}
		sort.Ints(o)
		for j := 0; j < n; j++ {
			fmt.Fprint(w, o[j], " ", o[2*n-j-1], " ")
		}
		fmt.Fprintln(w, "")
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1526A
Date: 17/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1526/A
Problem: CF1526A
**/
func (in *CF1526A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		n := in.NextInt() * 2
		arr := make([]int, n)
		for i := 0; i < n; i++ {
			arr[i] = in.NextInt()
		}
		sort.Ints(arr)
		var sol strings.Builder
		for p, i, j := 0, 0, n-1; p < n; p++ {
			if p%2 != 0 {
				sol.WriteString(fmt.Sprintf("%d ", arr[i]))
				i++
			} else {
				sol.WriteString(fmt.Sprintf("%d ", arr[j]))
				j--
			}
		}
		fmt.Println(sol.String())
	}
}

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

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

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t, n   int
)

func solve(n int, a []int) string {
	var x string
	sort.Ints(a)
	for i := 0; i < n; i++ {
		x += fmt.Sprintf("%d %d ", a[i], a[2*n-1-i])
	}
	return x
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		a := make([]int, 2*n)
		for i := 0; i < 2*n; i++ {
			fmt.Fscan(reader, &a[i])
		}
		fmt.Println(solve(n, a))
	}
}

package main

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

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

func MODULE(x, y int) int {
	if x > y {
		return x - y
	} else {
		return y - x
	}
}

//s stringyn icinde nace sany a bar? s.count(a)
func countInStr(s, a string) int {
	var ans int
	ans = 0
	for _, l := range s {
		if string(l) == a {
			ans = ans + 1
		}
	}
	return ans
}

//stringlan arrayynda s stringi sanaya
func countInArrOfStr(arr []string, s string) int {
	var ans int
	ans = 0
	for _, l := range arr {
		if l == s {
			ans = ans + 1
		}
	}
	return ans
}

// integer arrayda berlen integer nace sapar gelyar, shony sanaya!
func countInArrOfInt(arr []int, n int) int {
	var ans int
	ans = 0
	for _, l := range arr {
		if l == n {
			ans = ans + 1
		}
	}
	return ans
}

//berlen stringy berlen arrayyn icinde barmy yokmy shony barlaya!
func isInArrayString(arr []string, s string) bool {
	var ans bool = false
	for _, l := range arr {
		if l == s {
			ans = true
			break
		}
	}
	return ans
}

// berlen integeryn berlen integerly arrayda barlygyny yada yokluguny kesgitleyar
func isInArrayInt(arr []int, n int) bool {
	var ans bool = false
	for _, l := range arr {
		if l == n {
			ans = true
			break
		}
	}
	return ans
}

//stringly arrayy set edyar... set(arr)
func setArrOfStr(arr []string) []string {
	var ans []string
	for _, l := range arr {
		if isInArrayString(ans, l) == false {
			ans = append(ans, l)
		}
	}
	return ans

}

//integer arrayy set edyar
func setArrOfInt(arr []int) []int {
	var ans []int
	for _, l := range arr {
		if isInArrayInt(ans, l) == false {
			ans = append(ans, l)
		}
	}
	return ans
}

func abs(n int) int {
	if n >= 0 {
		return n
	} else {
		return n * (-1)
	}
}

//bu funksiya ahli elementleri durli bolan int arrayy artyan tertipde yazyar!
func sort(arr []int, n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		var c int
		c = 0
		for _, l := range arr {
			if l < arr[i] {
				c = c + 1
			}
		}
		ans[c] = arr[i]

	}
	return ans

}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var n int
		fmt.Fscan(input, &n)

		arr := make([]int, 2*n)
		for i := 0; i < 2*n; i++ {
			fmt.Fscan(input, &arr[i])
		}
		sortedarr := sort(arr, 2*n)
		for i := 0; i < n; i++ {
			fmt.Println(sortedarr[:n][i])
			fmt.Println(sortedarr[n:][i])
		}

	}
}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

func MIN(x, y int64) int64 {
	if x > y {
		return y
	} else {
		return x
	}
}

func MKO(x, y int64) int64 {
	if x < y {
		return 0
	} else {
		return x - y + 1
	}
}

func MAX(x, y int64) int64 {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func GCD(x, y int64) int64 {
	var l, q int64
	l = MAX(x, y)
	q = MIN(x, y)
	var m int64
	for l*q > 0 {
		a := l % q
		b := l - a
		cc := int64(b / q)
		remain := l - cc*q
		l = MAX(remain, q)
		q = MIN(remain, q)
		if l*q == 0 {
			m = l + q
			break
		}

	}
	return m
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}
}

func PrimeFactorization(n int) (pfs map[int]int) {
	pfs = make(map[int]int)

	// Get the number of 2s that divide n
	for n%2 == 0 {
		if _, ok := pfs[2]; ok {
			pfs[2] += 1
		} else {
			pfs[2] = 1
		}
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			if _, ok := pfs[i]; ok {
				pfs[i] += 1
			} else {
				pfs[i] = 1
			}
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs[n] = 1
	}

	return
}

func NumberOfDivisors(n int) int {
	pfs := PrimeFactorization(n)

	num := 1
	for _, exponents := range pfs {
		num *= (exponents + 1)
	}

	return num
}

func LITTLE(x int) int64 {
	var answer int64
	answer = answer + int64((x*x*x*x-x*x)/4) + int64(x*x*(x-1)*(x-1)/8) - int64(x*(x-1)*(x+x+1)*(x+x-1)/12)
	return answer
}

func KthPrime(x int) (y int) {
	if x == 1 {
		y = 2
	}
	if x == 2 {
		y = 3
	}
	if x > 2 {
		var sum int = 2
		begin := 5
		for sum < x+1 {
			if IsItPrime(begin) == true {
				sum++
			}
			if sum == x {
				y = begin
				break
			} else {
				if begin%6 == 1 {
					begin = begin + 4
				} else {
					begin = begin + 2
				}
			}
		}
	}
	return
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)

	for i := 0; i < t; i++ {

		var n int
		fmt.Fscan(input, &n)

		ARRAY := make([]int64, n*2)
		for j := 0; j < n*2; j++ {
			fmt.Fscan(input, &ARRAY[j])

		}

		sort.Slice(ARRAY, func(i, j int) bool {
			return ARRAY[i] < ARRAY[j]
		})

		for i := 0; i < n; i++ {
			fmt.Println(ARRAY[i])
			fmt.Println(ARRAY[i+n])
		}

	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		if n==1 {
			fmt.Fprintln(out,list[1],list[0])
			continue
		} else {
			for {
				counter:=0
				for j:=1;j<2*n-1;j++{
					if j == 1 {
						if (list[j]+list[2*n-1])/2 == list[j-1] {
							list[2*n-1],list[j-1],list[j] = list[j],list[2*n-1],list[j-1]
							counter++
						}
					}
					if (list[j-1]+list[j+1])/2 == list[j] {
						list[j-1],list[j],list[j+1] = list[j+1],list[j-1],list[j]
						counter++
					}
					if j == 2*n-2 {
						if (list[j]+list[0])/2 == list[j+1] {
							list[j],list[j+1],list[0] = list[j+1],list[j],list[0]
							counter++
						}
					}
				}
				if counter == 0 {
					break
				}
			}
		}
		for j:=0;j<n*2;j++{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out,)
		/*for j:=1;j<2*n-1;j++{
			if j==1 {
				if (list[j]+list[2*n-1])/2 == list[j-1] {
					fmt.Fprintln(out,"false")
					break
				}
			}
			if (list[j-1]+list[j+1])/2 == list[j] {
				fmt.Fprintln(out,"false")
				break
			}
		}*/
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		if n==1 {
			fmt.Fprintln(out,list[1],list[0])
			continue
		} else {
			for {
				counter:=0
				for j:=1;j<2*n-1;j++{
					if j == 1 {
						if (list[j]+list[2*n-1])/2 == list[j-1] {
							list[2*n-1],list[j-1],list[j] = list[j],list[2*n-1],list[j-1]
							counter++
						}
					}
					if (list[j-1]+list[j+1])/2 == list[j] {
						list[j-1],list[j],list[j+1] = list[j+1],list[j-1],list[j]
						counter++
					}
				}
				if counter == 0 {
					break
				}
			}
		}
		for j:=0;j<n*2;j++{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out,)
		/*for j:=1;j<2*n-1;j++{
			if j==1 {
				if (list[j]+list[2*n-1])/2 == list[j-1] {
					fmt.Fprintln(out,"false")
					break
				}
			}
			if (list[j-1]+list[j+1])/2 == list[j] {
				fmt.Fprintln(out,"false")
				break
			}
		}*/
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		if n==1 {
			fmt.Fprintln(out,list[1],list[0])
			continue
		} else {
			for k:=1;k<=n;k++{
				for j:=1;j<2*n-1;j++{
					if j == 1 {
						if (list[j]+list[2*n-1])/2 == list[j-1] {
							list[2*n-1],list[j-1],list[j] = list[j],list[2*n-1],list[j-1]
						}
					}
					if (list[j-1]+list[j+1])/2 == list[j] {
						list[j-1],list[j],list[j+1] = list[j+1],list[j-1],list[j]
					}
				}
			}
		}
		for j:=0;j<n*2;j++{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out,)
		/*for j:=1;j<2*n-1;j++{
			if j==1 {
				if (list[j]+list[2*n-1])/2 == list[j-1] {
					fmt.Fprintln(out,"false")
					break
				}
			}
			if (list[j-1]+list[j+1])/2 == list[j] {
				fmt.Fprintln(out,"false")
				break
			}
		}*/
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		if n==1 {
			fmt.Fprintln(out,list[1],list[0])
			continue
		} else {
			for j:=1;j<2*n-1;j++{
				if j == 1 {
					if (list[j]+list[2*n-1])/2 == list[j-1] {
						list[2*n-1],list[j-1],list[j] = list[j],list[2*n-1],list[j-1]
					}
				}
				if (list[j-1]+list[j+1])/2 == list[j] {
					list[j-1],list[j],list[j+1] = list[j+1],list[j-1],list[j]
				}
			}
		}
		for j:=0;j<n*2;j++{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out,)
		/*for j:=1;j<2*n-1;j++{
			if j==1 {
				if (list[j]+list[2*n-1])/2 == list[j-1] {
					fmt.Fprintln(out,"false")
					break
				}
			}
			if (list[j-1]+list[j+1])/2 == list[j] {
				fmt.Fprintln(out,"false")
				break
			}
		}*/
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		if n==1 {
			fmt.Fprintln(out,list[1],list[0])
			continue
		} else {
			for j:=1;j<2*n-1;j++{
				if (list[j-1]+list[j+1])/2 == list[j] {
					list[j-1],list[j],list[j+1] = list[j+1],list[j-1],list[j]
				}
			}
		}
		for j:=0;j<n*2;j++{
			fmt.Fprintf(out,"%v ",list[j])
		}
		fmt.Fprintln(out,)
		/*fmt.Fprintln(out,list)
		for j:=1;j<2*n-1;j++{
			if j==1 {
				if (list[j]+list[2*n-1])/2 == list[j-1] {
					fmt.Fprintln(out,"false")
					break
				}
			}
			if (list[j-1]+list[j+1])/2 == list[j] {
				fmt.Fprintln(out,"false")
				break
			}
		}*/
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		if n*2 >= 3 {
			for j:=1;j<2*n-1;j+=2{
				fmt.Fprintf(out,"%v %v %v ",list[j+1],list[j-1],list[j])
			}
		} else {
			for j:=1;j<=2*n-1;j+=2{
				fmt.Fprintf(out,"%v %v ",list[j],list[j-1])
			}
		}
		fmt.Fprintln(out,)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		if n*2 >= 3 {
			for j:=1;j<2*n-1;j+=2{
				fmt.Fprintf(out,"%v %v %v ",list[j+1],list[j-1],list[j])
			}
		} else {
			for j:=1;j<2*n-1;j+=2{
				fmt.Fprintf(out,"%v %v ",list[j],list[j-1])
			}
		}
		fmt.Fprintln(out,)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		for j:=1;j<2*n-1;j+=2{
			fmt.Fprintf(out,"%v %v %v ",list[j+1],list[j-1],list[j])
		}
		fmt.Fprintln(out,)
	}
}

package main
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		list:= make([]int,2*n)
		for j:=0;j<n*2;j++{
			fmt.Fscan(in,&list[j])
		}
		for j:=1;j<2*n;j+=2{
			fmt.Fprintf(out,"%v %v ",list[j],list[j-1])
		}
		fmt.Fprintln(out,)
	}
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)

		arr := make([]int, 2*n)

		for i := 0; i < 2*n; i++ {
			_, _ = fmt.Fscan(in, &arr[i])
		}

		sort.Ints(arr)

		for i := 0; i < 2*n; i++ {
			fmt.Printf("%d ", arr[i])
		}
		fmt.Println()
	}
}


package main

import (
	"fmt"
	"os"
)

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
}

func main() {
	var nt, r, b, g int

	fmt.Fscanln(os.Stdin, &nt)

	for t := 0; t < nt; t++ {
		fmt.Fscanln(os.Stdin, &r, &b, &g)

		if r > b {
			b, r = r, b
		}
		if b > g {
			g, b = b, g
		}

		if r > b {
			b, r = r, b
		}

		var res = b + min(r, g - b)

		res += (r - min(r, g - b)) / 2

		fmt.Println(res)
	}

}

// @problemURL https://codeforces.com/problemset/problem/1263/A
package main

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

// var inFile, _ = os.Open("in.txt")
// var outFile, _ = os.OpenFile("out.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
// var in = bufio.NewReader(inFile)
// var out = bufio.NewWriter(outFile)

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

func printf(f string, a ...interface{}) { _, _ = fmt.Fprintf(out, f, a...) }
func scanf(f string, a ...interface{})  { _, _ = fmt.Fscanf(in, f, a...) }

func cleanup() {
	_ = out.Flush()
}

func main() {
	// defer cleanup()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		s := make([]int, 3)
		scanf("%d %d %d\n", &s[0], &s[1], &s[2])
		sort.Slice(s, func(i, j int) bool {
			if s[i] < s[j] {
				return true
			}
			return false
		})
		if s[2] > s[1]+s[0] {
			fmt.Println(s[1] + s[0])
		} else {
			fmt.Println((s[0] + s[1] + s[2]) / 2)
		}
	}
}

func min(i1 int, i2 int) int {
	if i1 > i2 {
		return i2
	}
	return i1
}

// TODO Try without cleanup => Try on codeforces

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var r, g, b int

func main() {
	t = ReadInt()

	PrintDebug("%d %s %f\n", 100, "test", 199.111)
	PrintDebug("デバッグテスト")

	for tc := 0; tc < t; tc++ {
		r, g, b = ReadInt3()

		solve()
	}
}

func solve() {
	A := []int{r, g, b}
	// 降順ソート
	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	sum := A[1] + A[2]
	if sum <= A[0] {
		fmt.Println(sum)
	} else {
		if A[0] > A[1] {
			// fmt.Println(A[0])
			ans := 0

			diff := A[0] - A[1]
			A[0] -= diff
			ans += diff
			A[2] -= diff
			tmp := (A[2] + (2 - 1)) / 2
			ans += A[2] + A[0] - tmp
			fmt.Println(ans)
		} else {
			// 一番大きいものと2番めが同じ
			tmp := (A[2] + (2 - 1)) / 2
			ans := A[2] + A[0] - tmp
			fmt.Println(ans)
		}
	}
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var r, g, b int

func main() {
	t = ReadInt()

	for i := 0; i < 10000; i++ {
		PrintDebug("%d %s %f\n", 100, "test", 199.111)
		PrintDebug("デバッグテスト")
	}

	for tc := 0; tc < t; tc++ {
		r, g, b = ReadInt3()

		solve()
	}
}

func solve() {
	A := []int{r, g, b}
	// 降順ソート
	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	sum := A[1] + A[2]
	if sum <= A[0] {
		fmt.Println(sum)
	} else {
		if A[0] > A[1] {
			// fmt.Println(A[0])
			ans := 0

			diff := A[0] - A[1]
			A[0] -= diff
			ans += diff
			A[2] -= diff
			tmp := (A[2] + (2 - 1)) / 2
			ans += A[2] + A[0] - tmp
			fmt.Println(ans)
		} else {
			// 一番大きいものと2番めが同じ
			tmp := (A[2] + (2 - 1)) / 2
			ans := A[2] + A[0] - tmp
			fmt.Println(ans)
		}
	}
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var r, g, b int

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		r, g, b = ReadInt3()

		solve()
	}
}

func solve() {
	A := []int{r, g, b}
	// 降順ソート
	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	sum := A[1] + A[2]
	if sum <= A[0] {
		fmt.Println(sum)
	} else {
		if A[0] > A[1] {
			// fmt.Println(A[0])
			ans := 0

			diff := A[0] - A[1]
			A[0] -= diff
			ans += diff
			A[2] -= diff
			tmp := (A[2] + (2 - 1)) / 2
			ans += A[2] + A[0] - tmp
			fmt.Println(ans)
		} else {
			// 一番大きいものと2番めが同じ
			tmp := (A[2] + (2 - 1)) / 2
			ans := A[2] + A[0] - tmp
			fmt.Println(ans)
		}
	}
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/

package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var n int
	s := []int{0, 0, 0}
	fmt.Fscanln(os.Stdin, &n)
	for i := 0; i < n; i++ {
		fmt.Fscanln(os.Stdin, &s[0], &s[1], &s[2])
		sort.Ints(s)
		if s[2] >= s[0]+s[1] {
			fmt.Println(s[0] + s[1])
		} else {
			fmt.Println((s[0] + s[1] + s[2]) / 2)
		}
	}
}

package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var n int
	s := []int{0,0,0}
	fmt.Fscanln(os.Stdin,&n)
	for i:=0;i<n;i++{
		fmt.Fscanln(os.Stdin,&s[0],&s[1],&s[2])
		sort.Ints(s)
		if (s[2]>s[0]+s[1]){
			fmt.Fprintln(os.Stdout,s[0]+s[1])
		}else{
			fmt.Fprintln(os.Stdout,(s[1]+s[0]+s[2])/2)
		}

	}
}

package main

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

func solve(reader io.Reader, writer io.Writer) {
	in := bufio.NewReader(reader)
	out := bufio.NewWriter(writer)
	defer out.Flush()

	var t int
	Fscan(in, &t)
	for case_ := 0; case_ < t; case_++ {
		Fprintln(out, solveCase(in, out))
	}
}

func solveCase(in io.Reader, out io.Writer) int {
	sort3 := func(a ...int) (int, int, int) {
		sort.Ints(a)
		return a[0], a[1], a[2]
	}

	var a, b, c int
	Fscan(in, &a, &b, &c)
	a, b, c = sort3(a, b, c)
	if a+b <= c {
		return a + b
	}
	same := a + b - c
	ans := c - same + same/2*3
	if same%2 == 1 {
		ans++
	}
	return ans
}

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

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
}
func ifElseI(cond bool, a, b int) int {
	if cond {
		return a
	}
	return b
}
func ifElseS(cond bool, a, b string) string {
	if cond {
		return a
	}
	return b
}

package main

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

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...)}

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

var a[10] int

func main(){
	defer writer.Flush()
	var T int
	scanf("%d\n",&T)
	for cas:=1;cas<=T;cas++{
		for i:=0; i<3;i++{
			scanf("%d",&a[i])
		}
		scanf("\n")
		sort.Ints(a[:3])
		/*
		for _,ai:=range a[:3]{
			printf("%d ",ai)
		}
		printf("\n")
		 */
		if a[2]>a[1]+a[0] {
			printf("%d\n",a[1]+a[0])
		}else{
			printf("%d\n",(a[2]+a[1]+a[0])/2)
		}
	}
}

package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var rows int

	fmt.Fscanln(os.Stdin, &rows)

	s := make([]int, 3)
	for i := 0; i < rows; i++ {
		fmt.Fscanln(os.Stdin, &s[0], &s[1], &s[2])

		i := 0
		for {
			sort.Slice(s, func(i, j int) bool {
				return s[i] > s[j]
			})

			if s[0] == 0 || s[1] == 0 {
				break
			}

			d := s[1] - s[2]

			if d == 0 {
				d = s[1]/2
			}

			if d == 0 {
				d = 1
			}

			i += d
			s[0] -= d
			s[1] -= d
		}

		fmt.Fprintln(os.Stdout, i)
	}
}

package main

import (
    "fmt"
)

func min3(a, b, c int) int {
	if a <= b && a <= c {
		return a;
	}
	if b <= a && b <= c {
		return b;
	}
	return c
}

func max3(a, b, c int) int {
	if a >= b && a >= c {
		return a;
	}
	if b >= a && b >= c {
		return b;
	}
	return c;
}

func min2(a, b int) int {
	if a <= b {
		return a;
	}
	return b;
}

func main() {

    var a, b, c, t int

    fmt.Scanf("%d\n", &t)
	// fmt.Println(t)

	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d\n", &a, &b, &c);
		if a > b {
			f := a;
			a = b;
			b = f;
		}
		if a > c {
			f := a;
			a = c;
			c = f;
		}
		if b > c {
			f := b;
			b = c;
			c = f;
		}
		ans := a;
		if c - b >= a {
			c -= a;
		} else {
			a -= c - b;
			half := a / 2;
			c -= half;
			b -= a - half;
		}
		ans += min2(b, c);
		fmt.Println(ans);
	}
}

// @problemURL https://codeforces.com/problemset/problem/1263/A
package main

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

// var inFile, _ = os.Open("in.txt")
// var outFile, _ = os.OpenFile("out.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0644)
// var in = bufio.NewReader(inFile)
// var out = bufio.NewWriter(outFile)

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

func printf(f string, a ...interface{}) { _, _ = fmt.Fprintf(out, f, a...) }
func scanf(f string, a ...interface{})  {_, _ = fmt.Fscanf(in, f, a...)}

func cleanup() {
	_ = out.Flush()
}

func main() {
	// defer cleanup()

	var t int
	scanf("%d\n", &t)
	for ; t > 0; t-- {
		s := make([]int, 3)
		scanf("%d %d %d\n", &s[0], &s[1], &s[2])
		sort.Slice(s, func(i, j int) bool {
			if s[i] < s[j] {return true}
			return false
		})
		ans := s[0]
		s[2] -= s[0]
		if s[2] > 0 {
			ans += min(s[1], s[2])
		}
		fmt.Println(ans)
	}
}

func min(i1 int, i2 int) int {
	if i1 > i2 {
		return i2
	}
	return i1
}

// TODO Try without cleanup => Try on codeforces

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"sort"
	"strconv"
)

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var r, g, b int

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		r, g, b = ReadInt3()

		solve()
	}
}

func solve() {
	A := []int{r, g, b}
	// 降順ソート
	sort.Sort(sort.Reverse(sort.IntSlice(A)))

	sum := A[1] + A[2]
	if sum <= A[0] {
		fmt.Println(sum)
	} else {
		if A[0] > A[1] {
			fmt.Println(A[0])
		} else {
			// 一番大きいものと2番めが同じ
			tmp := (A[2] + (2 - 1)) / 2
			ans := A[2] + A[0] - tmp
			fmt.Println(ans)
		}
	}
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
*/

/*******************************************************************/

package main

import (
	"fmt"
	"os"
	"sort"
)

type IntSlice []int

func main() {
	var n int
	s := []int{0, 0, 0}
	fmt.Fscanf(os.Stdin, "%d", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(os.Stdin, "%d %d %d", &s[0], &s[1], &s[2])
		sort.Ints(s)
		if s[2] >= s[0]+s[1] {
			fmt.Println(s[0] + s[1])
		} else {
			fmt.Println((s[0] + s[1] + s[2]) / 2)
		}
	}
}

package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var n int
	s := []int{0, 0, 0}
	fmt.Fscanf(os.Stdin, "%d", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(os.Stdin, "%d %d %d", &s[0], &s[1], &s[2])
		sort.Ints(s)
		if s[2] >= s[0]+s[1] {
			fmt.Println(s[0] + s[1])
		} else {
			fmt.Println((s[0] + s[1] + s[2]) / 2)
		}
	}
}

package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var n int
	s := []int{0,0,0}
	fmt.Fscanln(os.Stdin,&n)
	for i:=0;i<n;i++{
		fmt.Fscanln(os.Stdin,&s[0],&s[1],&s[2])
		sort.Ints(s)
		if (s[2]>s[0]+s[1]){
			fmt.Fprintln(os.Stdout,s[0]+s[1])
		}else{
			fmt.Fprintln(os.Stdout,s[2])
		}

	}
}

package main

import (
	"fmt"
)

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
}

func main() {
	var nt, r, b, g int
	fmt.Scanf("%d", &nt)
	for t := 0; t < nt; t++ {
		fmt.Scanf("%d%d%d", &r, &b, &g)

		if r > b {
			b, r = r, b
		}
		if b > g {
			g, b = b, g
		}

		if r > b {
			b, r = r, b
		}

		var res = b + min(r, g - b)

		res += (r - min(r, g - b)) / 2

		fmt.Println(res)
	}

}

package main

import (
	"fmt"
)

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
}

func main() {
	var nt, r, b, g int
	fmt.Scanf("%d", &nt)
	for t := 0; t < nt; t++ {
		fmt.Scanf("%d%d%d", &r, &b, &g)

		if r > b {
			b, r = r, b
		}
		if b > g {
			g, b = b, g
		}

		if r > b {
			b, r = r, b
		}

		var res = b + min(r, g - b)

		res += (r - min(r, g - b)) / 2

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

}

package main

import (
	"fmt"
	"os"
	"sort"
)

func main() {
	var rows int

	fmt.Fscanln(os.Stdin, &rows)

	s := make([]int, 3)
	for i := 0; i < rows; i++ {
		fmt.Fscanln(os.Stdin, &s[0], &s[1], &s[2])

		i := 0
		for {
			sort.Slice(s, func(i, j int) bool {
				return s[i] > s[j]
			})

			if s[0] == 0 || s[1] == 0 {
				break
			}

			d := s[1]

			if d > 1 {
				d -= 1
			}

			i += d
			s[0] -= d
			s[1] -= d
		}
		fmt.Fprintln(os.Stdout, i)
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var rows int
	fmt.Scanln(&rows)

	s := make([]int, 3)
	for i := 0; i < rows; i++ {
		fmt.Scanf("%d %d %d", &s[0], &s[1], &s[2])

		i := 0
		for {
			sort.Slice(s, func(i, j int) bool {
				return s[i] > s[j]
			})

			if s[0] == 0 || s[1] == 0 {
				break
			}

			s[0]--
			s[1]--
			i++
		}
		fmt.Println(i)
	}
}