package main
// github.com/jamesgrimard/codeforces
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 a,b,c int
		fmt.Fscan(in,&a,&b,&c)
		if (a > b && a < c) || (a > c && a < b) {
			fmt.Fprintln(out,a)
		} else if (b > a && b < c) || (b < a && b > c) {
			fmt.Fprintln(out,b)
		} else {
			fmt.Fprintln(out,c)
		}
	}
}

package main

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

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

// source: _
func solve() {
	_, a := _readArr(3)
	sort.Ints(a)
	_print(a[1])
}

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

// ====
func _readInt() int {
	var x int
	fmt.Fscan(in, &x)
	return x
}
func _readStr() string {
	var x string
	fmt.Fscan(in, &x)
	return x
}
func _readArr(x ...int) (int, []int) {
	var n int
	if len(x) == 0 {
		fmt.Fscan(in, &n)
	} else {
		n = x[0]
	}
	var v = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &v[i])
	}
	return n, v
}
func _print(x ...any) {
	fmt.Fprintln(out, x...)
}
func _max(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] > x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _min(x ...int) int {
	mi := 0
	for i := 1; i < len(x); i++ {
		if x[i] < x[mi] {
			mi = i
		}
	}
	return x[mi]
}
func _sum(x ...int) int {
	res := 0
	for _, i := range x {
		res += i
	}
	return res
}
func _abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func _sortStr(x string) string {
	r := []rune(x)
	sort.Slice(r, func(i, j int) bool {
		return r[i] < r[j]
	})
	return string(r)
}
func _reverseInts(x []int) {
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
}
func _reverseStr(s string) string {
	x := []rune(s)
	n := len(x)
	for i := 0; i < n/2; i++ {
		x[i], x[n-1-i] = x[n-1-i], x[i]
	}
	return string(x)
}
func _makeMatrix(n, m int) [][]int {
	x := make([][]int, n)
	for i := range x {
		x[i] = make([]int, m)
	}
	return x
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		a := make([]int, 3)
		fmt.Fscan(in, &a[0], &a[1], &a[2])
		sort.Ints(a)
		fmt.Println(a[1])
	}
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

const mod int = 998244353
const N int = 5e5 + 5

func main() {
	sc.Buffer(make([]byte, 500000*1+1), 500000)
	sc.Split(bufio.ScanWords)

	T := nextInt()
	for T > 0 {
		T--
		a := make([]int, 3)
		a[0], a[1], a[2] = nextInt(), nextInt(), nextInt()
		sort.Ints(a)
		fmt.Println(a[1])
	}
}

func max(args ...int) int {
	res := args[0]
	for _, v := range args {
		if v > res {
			res = v
		}
	}
	return res
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	//输入t
	var t int
	fmt.Fscan(in, &t)
	nums := make([]int, 3)
	for i := 0; i < t; i++ {
		for j := 0; j < 3; j++ {
			fmt.Fscan(in, &nums[j])
		}
		sort.Ints(nums)
		// 输出res
		fmt.Fprintln(out, nums[1])
	}
}

package main

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

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		a := make([]int, 3)
		for i := range a {
			fmt.Fscan(r, &a[i])
		}

		sort.Ints(a)
		fmt.Fprintln(w, a[1])
	}

}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		a := make([]int, 3)
		for i := range a {
			Fscan(in, &a[i])
		}
		sort.Ints(a)
		Fprintln(out, a[1])
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

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

}

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

package main

import "fmt"

func main() {
	var (
		t int
		a int
		b int
		c int
	)
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		if (b < a && a < c) || (c < a && a < b) {
			fmt.Println(a)
		} else if (a < b && b < c) || (c < b && b < a) {
			fmt.Println(b)
		} else {
			fmt.Println(c)
		}
	}
}

package main
import ("fmt")

func main() {
    var a,b,c,T int

    fmt.Scan(&T)

    for T>0 {
        fmt.Scan(&a)
        fmt.Scan(&b)
        fmt.Scan(&c)

        if a>b {
          a, b = b, a
        }
        if b>c {
          b, c = c, b
        }
        if a>b {
          a, b = b, a
        }

        fmt.Printf("%d\n", b)

        T--
    }

}

package main

import (
	"fmt"
	"sort"
)

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

	for i := 0; i < t; i++ {
		execute()
	}
}

func execute() {
	var s []int
	for i := 0; i < 3; i++ {
		var x int
		fmt.Scan(&x)
		s = append(s, x)
	}

	sort.Ints(s)
	fmt.Println(s[1])
}

/*
	A template for Go on codeforces.com
	Author: Yakov, frvr.ru
*/

package main

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

func main() {
	n := readInt()
	for i := 0; i < n; i++ {
		arr := readInts()
		sort.Ints(arr)
		writeLine(arr[1])
	}
}

/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */
/* ~~~~~~~~~~ */

var in = bufio.NewReader(os.Stdin)

type float = float32
type double = float64
type long = int64
type ulong = uint64

func typeOf(arg interface{}) string {
	switch reflect.TypeOf(arg).Kind() {
	case reflect.Int:
		return "int"
	case reflect.Int8:
		return "int8"
	case reflect.Int16:
		return "int16"
	case reflect.Int32:
		return "int32"
	case reflect.Int64:
		return "int64"
	case reflect.Uint:
		return "uint"
	case reflect.Uint8:
		return "uint8"
	case reflect.Uint16:
		return "uint16"
	case reflect.Uint32:
		return "uint32"
	case reflect.Uint64:
		return "uint64"
	case reflect.Float32:
		return "float32"
	case reflect.Float64:
		return "float64"
	case reflect.Complex64:
		return "complex64"
	case reflect.Complex128:
		return "complex128"
	case reflect.Bool:
		return "bool"
	case reflect.String:
		return "string"
	case reflect.Chan:
		return "chan"
	case reflect.Ptr:
		return "ptr"
	case reflect.Uintptr:
		return "uintptr"
	case reflect.UnsafePointer:
		return "unsafeptr"
	case reflect.Interface:
		return "interface"
	case reflect.Array:
		return "array"
	case reflect.Slice:
		return "slice"
	case reflect.Map:
		return "map"
	case reflect.Struct:
		return "struct"
	case reflect.Func:
		return "func"
	case reflect.Invalid:
		return "invalid"
	default:
		return "nil"
	}
}

/* ~~~~~~~~~~ */

func _scln() string {
	ln, _ := in.ReadString('\n')
	return strings.Trim(ln, " \r\n")
}
func _sc(s []string) string {
	if len(s) == 0 {
		return _scln()
	}
	return s[0]
}

func readLine() string              { return _scln() }
func readString() string            { return _scln() }
func readStrings() []string         { return strings.Split(_scln(), " ") }
func readBool(s ...string) bool     { t, _ := strconv.ParseBool(_sc(s)); return t }
func readByte(s ...string) byte     { t, _ := strconv.ParseUint(_sc(s), 10, 8); return byte(t) }
func readDouble(s ...string) double { t, _ := strconv.ParseFloat(_sc(s), 64); return t }
func readFloat(s ...string) float   { t, _ := strconv.ParseFloat(_sc(s), 32); return float32(t) }
func readInt(s ...string) int       { t, _ := strconv.Atoi(_sc(s)); return t }
func readLong(s ...string) long     { t, _ := strconv.ParseInt(_sc(s), 10, 64); return t }
func readULong(s ...string) ulong   { t, _ := strconv.ParseUint(_sc(s), 10, 64); return t }

/* ~~~~~~~~~~ */

// Too much overhead with universal method using interface{}, wait for the generics,
// but for now — just don't look at the redundancy of the code after that commentary :)

func readBools() []bool {
	strs := readStrings()
	arr := make([]bool, len(strs))
	for i, s := range strs {
		arr[i] = readBool(s)
	}
	return arr
}
func readBytes() []byte {
	strs := readStrings()
	arr := make([]byte, len(strs))
	for i, s := range strs {
		arr[i] = readByte(s)
	}
	return arr
}
func readDoubles() []double {
	strs := readStrings()
	arr := make([]double, len(strs))
	for i, s := range strs {
		arr[i] = readDouble(s)
	}
	return arr
}
func readFloats() []float {
	strs := readStrings()
	arr := make([]float, len(strs))
	for i, s := range strs {
		arr[i] = readFloat(s)
	}
	return arr
}
func readInts() []int {
	strs := readStrings()
	arr := make([]int, len(strs))
	for i, s := range strs {
		arr[i] = readInt(s)
	}
	return arr
}
func readLongs() []long {
	strs := readStrings()
	arr := make([]long, len(strs))
	for i, s := range strs {
		arr[i] = readLong(s)
	}
	return arr
}
func readULongs() []ulong {
	strs := readStrings()
	arr := make([]ulong, len(strs))
	for i, s := range strs {
		arr[i] = readULong(s)
	}
	return arr
}

/* ~~~~~~~~~~ */

func write(arg ...interface{})                 { fmt.Print(arg...) }
func writeLine(arg ...interface{})             { fmt.Println(arg...) }
func writeFormat(f string, arg ...interface{}) { fmt.Printf(f, arg...) }

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"index/suffixarray"
	"log"
	"math"
	"net"
	"os"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"
)

// For Codeforces
func main() {
	io := newStdIO()
	defer io.Flush()
	for T := io.ScanUInt16(); T > 0; T-- {
		solve(&io)
	}
}
func solve(io *IO) {
	a := io.ScanInt32()
	b := io.ScanInt32()
	c := io.ScanInt32()
	io.PrintLn(a+b+c-Min(c, Min(a,b))-Max(a, Max(b,c)))
}

// #region INTERFACES

// From https://pkg.go.dev/golang.org/x/exp/constraints
type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}
type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Integer interface {
	Signed | Unsigned
}
type Float interface {
	~float32 | ~float64
}
type Complex interface {
	~complex64 | ~complex128
}
type Ordered interface {
	Integer | Float | ~string
}

type Prioritizable[T any] interface {
	PriorTo(x T) bool // If you take this as a relation: if (a,b) in R => (b,a) not in R
}

// #endregion
// #region TYPES WITH METHODS
// #region SingleLinkedList
type singleLinkedListNode[T comparable] struct {
	Value T
	Next  *singleLinkedListNode[T]
}

type SingleLinkedList[T comparable, IndexType Unsigned] struct {
	first  *singleLinkedListNode[T]
	last   *singleLinkedListNode[T]
	length IndexType
}

func NewSingleLinkedList[T comparable, IndexType Unsigned]() *SingleLinkedList[T, IndexType] {
	return &SingleLinkedList[T, IndexType]{
		first:  nil,
		last:   nil,
		length: 0,
	}
}
func (l *SingleLinkedList[T, I]) Len() I { return l.length }

// length > 0
func (l *SingleLinkedList[T, I]) First() T { return l.first.Value }

// length > 0
func (l *SingleLinkedList[T, I]) Last() T { return l.last.Value }

func (l *SingleLinkedList[T, I]) InsertFirst(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.first = &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) InsertLast(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.last.Next = &singleLinkedListNode[T]{
			Value: value,
			Next:  nil,
		}
		l.last = l.last.Next
	}
	l.length++
}

// index <= length
func (l *SingleLinkedList[T, I]) InsertAt(index I, value T) {
	if index == 0 {
		l.InsertFirst(value)
		return
	}
	if index == l.length {
		l.InsertLast(value)
		return
	}

	n := l.first
	for index > 1 {
		n = n.Next
		index--
	}
	n.Next = &singleLinkedListNode[T]{
		Value: value,
		Next:  n.Next,
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) Contains(value T) bool {
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		if tmp.Value == value {
			return true
		}
		tmp = tmp.Next
	}
	return false
}
func (l *SingleLinkedList[T, I]) Clear() {
	l.first = nil
	l.last = nil
	l.length = 0
}

// index < length
func (l *SingleLinkedList[T, I]) GetElementAt(index I) T {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	return n.Value
}

// index < length
func (l *SingleLinkedList[T, I]) SetElementAt(index I, value T) {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	n.Value = value
}

func (l *SingleLinkedList[T, I]) RemoveFirst() T {
	tmp := l.first
	l.first = l.first.Next
	l.length--
	if l.length == 0 {
		l.last = nil
	}
	return tmp.Value
}
func (l *SingleLinkedList[T, I]) RemoveLast() (value T) {
	value = l.last.Value
	if l.length == 1 {
		l.first = nil
		l.last = nil
		l.length = 0
		return
	}

	tmp := l.first
	for i := I(2); i < l.length; i++ {
		tmp = tmp.Next
	}
	l.last = tmp
	return
}

func (l *SingleLinkedList[T, I]) RemoveAt(index I) T {
	if index == 0 {
		return l.RemoveFirst()
	}
	if index == l.length-1 {
		return l.RemoveLast()
	}

	tmp := l.first
	for i := I(1); i < index; i++ {
		tmp = tmp.Next
	}
	res := tmp.Next.Value
	tmp.Next = tmp.Next.Next
	return res
}

func (l *SingleLinkedList[T, I]) ToSlice() (res []T) {
	res = make([]T, 0, l.length)
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		res = append(res, tmp.Value)
		tmp = tmp.Next
	}
	return
}
func (it *SingleLinkedList[T, I]) String() string {
	return "Qua:: " + fmt.Sprint(it.ToSlice())
}

// #endregion
// #region Queue

type Queue[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewQueue[T comparable, I Unsigned]() *Queue[T, I] {
	return &Queue[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (q *Queue[T, I]) Len() I          { return q.l.length }
func (q *Queue[T, I]) Enqueue(value T) { q.l.InsertLast(value) }
func (q *Queue[T, I]) Dequeue(T) T     { return q.l.RemoveFirst() }
func (q *Queue[T, I]) Preview() T      { return q.l.First() }
func (q *Queue[T, I]) String() string  { return q.l.String() }

// #endregion
// #region Stack

type Stack[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewStack[T comparable, I Unsigned]() *Stack[T, I] {
	return &Stack[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (s *Stack[T, I]) Len() I         { return s.l.length }
func (s *Stack[T, I]) Push(value T)   { s.l.InsertFirst(value) }
func (s *Stack[T, I]) Pop(T) T        { return s.l.RemoveFirst() }
func (s *Stack[T, I]) Preview() T     { return s.l.First() }
func (s *Stack[T, I]) String() string { return s.l.String() }

// #endregion
// #region Heap
type BinaryHeap[T Prioritizable[T], I Signed] struct {
	s []T
}

func NewBinaryHeap[T Prioritizable[T], I Signed](s []T) (h *BinaryHeap[T, I]) {
	h = &BinaryHeap[T, I]{
		s: s,
	}

	for i := (h.Len() - 2) / 2; i >= 0; i-- {
		h.heapifyDown(i)
	}
	return
}
func (h *BinaryHeap[T, I]) Len() I {
	return I(len(h.s))
}
func (h *BinaryHeap[T, I]) Push(value T) {
	h.s = append(h.s, value)
	h.heapifyUp(h.Len() - 1)
}
func (h *BinaryHeap[T, I]) Pop() (res T) {
	res = h.s[0]
	h.s[0] = h.s[h.Len()-1]
	h.s = h.s[:h.Len()-1]
	h.heapifyDown(0)
	return
}

func (h *BinaryHeap[T, I]) heapifyDown(index I) bool {
	origin := index
	for {
		j := index*2 + 2
		if j < h.Len() {
			if h.s[j-1].PriorTo(h.s[j]) {
				j--
			}
		} else {
			if j <= h.Len() && !h.s[j].PriorTo(h.s[index]) {
				h.s[j], h.s[index] = h.s[index], h.s[j]
			}
			break
		}
		if h.s[j].PriorTo(h.s[index]) {
			h.s[j], h.s[index] = h.s[index], h.s[j]
			index = j
		} else {
			break
		}
	}
	return origin != index
}
func (h *BinaryHeap[T, I]) heapifyUp(index I) {
	for {
		parent := (index - 1) / 2
		if parent == index || h.s[parent].PriorTo(h.s[index]) {
			break
		}
		h.s[index], h.s[parent] = h.s[parent], h.s[index]
		index = parent
	}
}

// #endregion

// #endregion

// #region FUNCTIONS
func Max[T Ordered](a, b T) T {
	if a >= b {
		return a
	}
	return b
}
func Min[T Ordered](a, b T) T {
	if a <= b {
		return a
	}
	return b
}
func Abs[T Integer | Float](a T) T {
	if a < 0 {
		return -a
	}
	return a
}
func Swap[T any](a, b *T) {
	*a, *b = *b, *a
}

// At least one != 0
func GCD[T Unsigned](a, b T) T {
	if b < a {
		Swap(&a, &b)
	}
	for {
		if a == 0 {
			return b
		}
		r := (b % a)
		b = a
		a = r
	}
}

// At least one != 0
func LCM[T Unsigned](a, b T) T {
	return (a * b) / GCD(a, b)
}

func First[T any](a T, _ any) T { return a }

// #endregion

// #region IO STUFF
type IO struct {
	r *bufio.Reader
	w *bufio.Writer
}

func newStdIO() IO {
	return IO{
		r: bufio.NewReader(os.Stdin),
		w: bufio.NewWriter(os.Stdout),
	}
}

// Is assumed that input.txt file exists
func newFileIO() IO {
	return IO{
		r: bufio.NewReader(First(os.Open("input.txt"))),
		w: bufio.NewWriter(First(os.OpenFile("output.txt", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm))),
	}
}

func (io *IO) ScanInt8() (x int8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt16() (x int16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt32() (x int32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt64() (x int64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanUInt8() (x uint8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt16() (x uint16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt32() (x uint32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt64() (x uint64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanFloat32() (x float32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanFloat64() (x float64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanString() (x string) { fmt.Fscan(io.r, &x); return }

func (io *IO) Print(x ...any)   { fmt.Fprint(io.w, x...) }
func (io *IO) PrintLn(x ...any) { fmt.Fprintln(io.w, x...) }

func (io *IO) Flush() { io.w.Flush() }

// #endregion

// #region KEEP IMPORTS
func D() {
	_ = bufio.Reader{}
	_ = bytes.Buffer{}
	_ = suffixarray.Index{}
	_ = log.Default()
	_ = math.Abs(0)
	_ = net.Dialer{}
	_ = path.ErrBadPattern
	_ = sort.Float64sAreSorted(nil)
	_ = strconv.ErrRange
	_ = strings.Builder{}
	_ = time.ANSIC
	_ = newStdIO()
	_ = newFileIO()
}

// #endregion

package main

import (
	"fmt"
	"sort"
)

var t int

func solve() {
	vecs := [3]int{}
	fmt.Scanln(&vecs[0], &vecs[1], &vecs[2])
	sort.Ints(vecs[:])
	fmt.Println(vecs[1])
}

func main() {
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

func solve() {
	arr := []int{}
	for i := 0; i < 3; i++ {
		a := 0
		fmt.Scan(&a)
		arr = append(arr, a)
	}
	sort.Ints(arr)
	fmt.Println(arr[1])
}

package main

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

const cf = true

func solve() {
	arr := []int{0, 0, 0}
	fmt.Fscan(in, &arr[0], &arr[1], &arr[2])
	sort.Ints(arr)
	fmt.Fprintln(out, arr[1])
}

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

func LCM(a, b int) int {
	return a * b / GCD(a, b)
}

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

	return a
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

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

func (in *CF1760A) 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 *CF1760A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1760A
Date: 11/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1760/A
Problem: CF1760A
**/
func (in *CF1760A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		arr := []int{ in.NextInt(), in.NextInt(), in.NextInt()}
        sort.Ints(arr)
        fmt.Println(arr[1])
	}
}

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

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

package main

import "fmt"

func solveMax(a, b, c int) int {
	if a > b && a > c {
		return a
	}

	if b > a && b > c {
		return b
	}

	return c
}

func solveMin(a, b, c int) int {
	if a < b && a < c {
		return a
	}

	if b < a && b < c {
		return b
	}

	return c
}

func solve(max, min, a, b, c int) int {
	if a == max {
		if b == min {
			return c
		} else {
			return b
		}
	}
	if b == max {
		if a == min {
			return c
		} else {
			return a
		}
	}
	if c == max {
		if a == min {
			return b
		} else {
			return a
		}

	}
	return b
}

func main() {
	var t int

	fmt.Scan(&t)
	for t > 0 {
		t--
		var a, b, c, max, min int
		fmt.Scan(&a, &b, &c)
		max = solveMax(a, b, c)
		min = solveMin(a, b, c)
		r := solve(max, min, a, b, c)
		fmt.Println(r)
	}
}

package main

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

func solve(reader *bufio.Reader, writer *bufio.Writer) {
	a, b, c := readThreeInt(reader)

	if a <= b && b <= c || c <= b && b <= a {
		fmt.Fprintln(writer, b)
	} else if b <= a && a <= c || c <= a && a <= b {
		fmt.Fprintln(writer, a)
	} else {
		fmt.Fprintln(writer, c)
	}
}

func main() {
	reader := bReader(os.Stdin)
	writer := bWriter(os.Stdout)

	t := readInt(reader)

	for t > 0 {
		solve(reader, writer)
		t--
	}

	writer.Flush()
}

func min[T int | int64](a, b T) T {
	if a < b {
		return a
	}

	return b
}

func max[T int | int64](a, b T) T {
	if a > b {
		return a
	}

	return b
}

func abs[T int | int64](a T) T {
	if a < 0 {
		return a * -1
	} else {
		return a
	}
}

func gcd[T int | int64](x, y T) T {
	for y > 0 {
		x, y = y, x%y
	}

	return x
}

func lcm[T int | int64](x, y T) T {
	return x * y / gcd(x, y)
}

func bReader(stdin *os.File) *bufio.Reader {
	return bufio.NewReaderSize(stdin, 16*1024*1024)
}

func bWriter(stdout *os.File) *bufio.Writer {
	return bufio.NewWriterSize(stdout, 16*1024*1024)
}

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

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

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func readInt(reader *bufio.Reader) int {
	return int(readInt64(reader))
}

func readInt64(reader *bufio.Reader) int64 {
	value, err := strconv.ParseInt(readLine(reader), 10, 64)
	checkError(err)

	return value
}

func readString(reader *bufio.Reader) string {
	return readLine(reader)
}

func readArrayString(reader *bufio.Reader) []string {
	return strings.Split(strings.TrimSpace(readLine(reader)), " ")
}

func readArrayInt(reader *bufio.Reader) []int {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 32)
		checkError(err)
		arItem := int(arItemTemp)
		ar = append(ar, arItem)
	}

	return ar
}

func readArrayInt64(reader *bufio.Reader) []int64 {
	arTemp := strings.Split(strings.TrimSpace(readLine(reader)), " ")
	n := len(arTemp)

	var ar []int64

	for i := 0; i < n; i++ {
		arItemTemp, err := strconv.ParseInt(arTemp[i], 10, 64)
		checkError(err)
		arItem := arItemTemp
		ar = append(ar, arItem)
	}

	return ar
}

func readTwoInt(reader *bufio.Reader) (int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1]
}

func readTwoInt64(reader *bufio.Reader) (int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1]
}

func readThreeInt(reader *bufio.Reader) (int, int, int) {
	ar := readArrayInt(reader)
	return ar[0], ar[1], ar[2]
}

func readThreeInt64(reader *bufio.Reader) (int64, int64, int64) {
	ar := readArrayInt64(reader)
	return ar[0], ar[1], ar[2]
}

package main

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

func main() {
	var testCases int

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

	defer writer.Flush()
	fmt.Fscan(reader, &testCases)

	for testCase := 1; testCase <= testCases; testCase++ {

		arr := make([]int, 3)
		fmt.Fscan(reader, &arr[0], &arr[1], &arr[2])

		output := solve(arr)

		fmt.Fprintln(writer, output)
	}
}

func solve(arr []int) int {

	sort.Ints(arr)

	return arr[1]

}

package main

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

func readArray(sc *bufio.Scanner) (arr []int) {
	sc.Scan()
	for _, value := range strings.Split(sc.Text(), " ") {
		number, _ := strconv.Atoi(value)
		arr = append(arr, number)
	}
	return
}

func readData(sc *bufio.Scanner) (a int, b int, c int) {
	sc.Scan()
	arr := strings.Split(sc.Text(), " ")
	a, _ = strconv.Atoi(arr[0])
	b, _ = strconv.Atoi(arr[1])
	c, _ = strconv.Atoi(arr[2])
	return
}

func Sum(x, y int, arr []int) int {
	left, right := len(arr)-x, len(arr)-x+y
	l := 0
	if left != 0 {
		l = arr[left-1]
	}
	r := len(arr)
	if right <= len(arr) {
		r = arr[right-1]
	}
	return r - l
}

// 001   1
// 1010100101

func solve(a, b, c int) int {
	arr := []int{a, b, c}
	sort.Ints(arr)
	return arr[1]
}

func main() {
	var n int
	fmt.Scanln(&n)
	sc := bufio.NewScanner(os.Stdin)
	for ; n > 0; n-- {
		a, b, c := readData(sc)
		fmt.Println(solve(a, b, c))
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		var sli []int
		scanner.Scan()
		tsl := strings.Split(scanner.Text(), " ")
		for j := 0; j < len(tsl); j++ {
			tn, _ := strconv.Atoi(tsl[j])
			sli = append(sli, tn)
		}
		sort.Ints(sli)
		fmt.Println(sli[1])
	}
}

package main

import "fmt"

func main() {
	var (
		t int
		a int
		b int
		c int
	)
	fmt.Scanln(&t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d", &a, &b, &c)
		if (b < a && a < c) || (c < a && a < b) {
			fmt.Println(a)
		} else if (a < b && b < c) || (c < b && b < a) {
			fmt.Println(b)
		} else {
			fmt.Println(c)
		}
	}
}

package main

import "fmt"

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

	for i := 0; i < t; i++ {
		fmt.Scanln(&a)
		fmt.Scanln(&b)
		fmt.Scanln(&c)
		if (b < a && a < c) || (c < a && a < b) {
			fmt.Println(a)
		} else if (a < b && b < c) || (c < b && b < a) {
			fmt.Println(b)
		} else {
			fmt.Println(c)
		}
	}
}

package main

import "fmt"

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

	for i := 0; i < t; i++ {
		fmt.Scanln(&a)
		fmt.Scanln(&b)
		fmt.Scanln(&c)
		if ((a < b && a > c) || (a < c && a > b)) {
			fmt.Println(a)
		} else if ((b < a && b > c) || (b < c && b > a)) {
			fmt.Println(b)
		} else {
			fmt.Println(c)
		}
	}
}

package main

import "fmt"

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

	for i := 0; i < t; i++ {
		fmt.Scanln(&a)
		fmt.Scanln(&b)
		fmt.Scanln(&c)
		if (a < b && a > c) || (a < c && a > b) {
			fmt.Println(a)
		} else if (b < a && b > c) || (b < c && b > a) {
			fmt.Println(b)
		} else {
			fmt.Println(c)
		}
	}
}

package main

import "fmt"

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

	for i := 0; i < t; i++ {
		fmt.Scanf("%d %d %d", a, b, c)
		if (a < b && a > c) || (a < c && a > b) {
			fmt.Println(a)
		} else if (b < a && b > c) || (b < c && b > a) {
			fmt.Println(b)
		} else {
			fmt.Println(c)
		}
	}
}

package main
import ("fmt")

func main() {
    var a,b,c,T int

    fmt.Scan(&T)

    for T>0 {
        fmt.Scan(&a)
        fmt.Scan(&b)
        fmt.Scan(&c)

        if a>b {
          a, b = b, a
        }
        if b>c {
          b, c = c, b
        }
        if a>b {
          a, b = b, a
        }

        fmt.Println("%d\n", b)

        T--
    }

}

package main
import ("fmt")

func main() {
  var a,b,c int

  fmt.Scan(&a)
  fmt.Scan(&b)
  fmt.Scan(&c)

  if a>b {
      a, b = b, a
  }
  if b>c {
      b, c = c, b
  }
  if a>b {
      a, b = b, a
  }

  fmt.Println("%d\n", b)
}

package main

import (
	"bufio"
	"bytes"
	"fmt"
	"index/suffixarray"
	"log"
	"math"
	"net"
	"os"
	"path"
	"sort"
	"strconv"
	"strings"
	"time"
)

// For Codeforces
func main() {
	io := newFileIO()
	defer io.Flush()
	for T := io.ScanUInt16(); T > 0; T-- {
		solve(&io)
	}
}
func solve(io *IO) {
	a := io.ScanInt32()
	b := io.ScanInt32()
	c := io.ScanInt32()
	io.PrintLn(a+b+c-Min(c, Min(a,b))-Max(a, Max(b,c)))
}

// #region INTERFACES

// From https://pkg.go.dev/golang.org/x/exp/constraints
type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}
type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Integer interface {
	Signed | Unsigned
}
type Float interface {
	~float32 | ~float64
}
type Complex interface {
	~complex64 | ~complex128
}
type Ordered interface {
	Integer | Float | ~string
}

type Prioritizable[T any] interface {
	PriorTo(x T) bool // If you take this as a relation: if (a,b) in R => (b,a) not in R
}

// #endregion
// #region TYPES WITH METHODS
// #region SingleLinkedList
type singleLinkedListNode[T comparable] struct {
	Value T
	Next  *singleLinkedListNode[T]
}

type SingleLinkedList[T comparable, IndexType Unsigned] struct {
	first  *singleLinkedListNode[T]
	last   *singleLinkedListNode[T]
	length IndexType
}

func NewSingleLinkedList[T comparable, IndexType Unsigned]() *SingleLinkedList[T, IndexType] {
	return &SingleLinkedList[T, IndexType]{
		first:  nil,
		last:   nil,
		length: 0,
	}
}
func (l *SingleLinkedList[T, I]) Len() I { return l.length }

// length > 0
func (l *SingleLinkedList[T, I]) First() T { return l.first.Value }

// length > 0
func (l *SingleLinkedList[T, I]) Last() T { return l.last.Value }

func (l *SingleLinkedList[T, I]) InsertFirst(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.first = &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) InsertLast(value T) {
	if l.length == 0 {
		nodeToInsert := &singleLinkedListNode[T]{
			Value: value,
			Next:  l.first,
		}
		l.first = nodeToInsert
		l.last = nodeToInsert
	} else {
		l.last.Next = &singleLinkedListNode[T]{
			Value: value,
			Next:  nil,
		}
		l.last = l.last.Next
	}
	l.length++
}

// index <= length
func (l *SingleLinkedList[T, I]) InsertAt(index I, value T) {
	if index == 0 {
		l.InsertFirst(value)
		return
	}
	if index == l.length {
		l.InsertLast(value)
		return
	}

	n := l.first
	for index > 1 {
		n = n.Next
		index--
	}
	n.Next = &singleLinkedListNode[T]{
		Value: value,
		Next:  n.Next,
	}
	l.length++
}

func (l *SingleLinkedList[T, I]) Contains(value T) bool {
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		if tmp.Value == value {
			return true
		}
		tmp = tmp.Next
	}
	return false
}
func (l *SingleLinkedList[T, I]) Clear() {
	l.first = nil
	l.last = nil
	l.length = 0
}

// index < length
func (l *SingleLinkedList[T, I]) GetElementAt(index I) T {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	return n.Value
}

// index < length
func (l *SingleLinkedList[T, I]) SetElementAt(index I, value T) {
	n := l.first
	for index > 0 {
		n = n.Next
		index--
	}
	n.Value = value
}

func (l *SingleLinkedList[T, I]) RemoveFirst() T {
	tmp := l.first
	l.first = l.first.Next
	l.length--
	if l.length == 0 {
		l.last = nil
	}
	return tmp.Value
}
func (l *SingleLinkedList[T, I]) RemoveLast() (value T) {
	value = l.last.Value
	if l.length == 1 {
		l.first = nil
		l.last = nil
		l.length = 0
		return
	}

	tmp := l.first
	for i := I(2); i < l.length; i++ {
		tmp = tmp.Next
	}
	l.last = tmp
	return
}

func (l *SingleLinkedList[T, I]) RemoveAt(index I) T {
	if index == 0 {
		return l.RemoveFirst()
	}
	if index == l.length-1 {
		return l.RemoveLast()
	}

	tmp := l.first
	for i := I(1); i < index; i++ {
		tmp = tmp.Next
	}
	res := tmp.Next.Value
	tmp.Next = tmp.Next.Next
	return res
}

func (l *SingleLinkedList[T, I]) ToSlice() (res []T) {
	res = make([]T, 0, l.length)
	tmp := l.first
	for i := I(0); i < l.length; i++ {
		res = append(res, tmp.Value)
		tmp = tmp.Next
	}
	return
}
func (it *SingleLinkedList[T, I]) String() string {
	return "Qua:: " + fmt.Sprint(it.ToSlice())
}

// #endregion
// #region Queue

type Queue[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewQueue[T comparable, I Unsigned]() *Queue[T, I] {
	return &Queue[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (q *Queue[T, I]) Len() I          { return q.l.length }
func (q *Queue[T, I]) Enqueue(value T) { q.l.InsertLast(value) }
func (q *Queue[T, I]) Dequeue(T) T     { return q.l.RemoveFirst() }
func (q *Queue[T, I]) Preview() T      { return q.l.First() }
func (q *Queue[T, I]) String() string  { return q.l.String() }

// #endregion
// #region Stack

type Stack[T comparable, I Unsigned] struct {
	l SingleLinkedList[T, I]
}

func NewStack[T comparable, I Unsigned]() *Stack[T, I] {
	return &Stack[T, I]{
		l: SingleLinkedList[T, I]{
			first:  nil,
			last:   nil,
			length: 0,
		},
	}
}
func (s *Stack[T, I]) Len() I         { return s.l.length }
func (s *Stack[T, I]) Push(value T)   { s.l.InsertFirst(value) }
func (s *Stack[T, I]) Pop(T) T        { return s.l.RemoveFirst() }
func (s *Stack[T, I]) Preview() T     { return s.l.First() }
func (s *Stack[T, I]) String() string { return s.l.String() }

// #endregion
// #region Heap
type BinaryHeap[T Prioritizable[T], I Signed] struct {
	s []T
}

func NewBinaryHeap[T Prioritizable[T], I Signed](s []T) (h *BinaryHeap[T, I]) {
	h = &BinaryHeap[T, I]{
		s: s,
	}

	for i := (h.Len() - 2) / 2; i >= 0; i-- {
		h.heapifyDown(i)
	}
	return
}
func (h *BinaryHeap[T, I]) Len() I {
	return I(len(h.s))
}
func (h *BinaryHeap[T, I]) Push(value T) {
	h.s = append(h.s, value)
	h.heapifyUp(h.Len() - 1)
}
func (h *BinaryHeap[T, I]) Pop() (res T) {
	res = h.s[0]
	h.s[0] = h.s[h.Len()-1]
	h.s = h.s[:h.Len()-1]
	h.heapifyDown(0)
	return
}

func (h *BinaryHeap[T, I]) heapifyDown(index I) bool {
	origin := index
	for {
		j := index*2 + 2
		if j < h.Len() {
			if h.s[j-1].PriorTo(h.s[j]) {
				j--
			}
		} else {
			if j <= h.Len() && !h.s[j].PriorTo(h.s[index]) {
				h.s[j], h.s[index] = h.s[index], h.s[j]
			}
			break
		}
		if h.s[j].PriorTo(h.s[index]) {
			h.s[j], h.s[index] = h.s[index], h.s[j]
			index = j
		} else {
			break
		}
	}
	return origin != index
}
func (h *BinaryHeap[T, I]) heapifyUp(index I) {
	for {
		parent := (index - 1) / 2
		if parent == index || h.s[parent].PriorTo(h.s[index]) {
			break
		}
		h.s[index], h.s[parent] = h.s[parent], h.s[index]
		index = parent
	}
}

// #endregion

// #endregion

// #region FUNCTIONS
func Max[T Ordered](a, b T) T {
	if a >= b {
		return a
	}
	return b
}
func Min[T Ordered](a, b T) T {
	if a <= b {
		return a
	}
	return b
}
func Abs[T Integer | Float](a T) T {
	if a < 0 {
		return -a
	}
	return a
}
func Swap[T any](a, b *T) {
	*a, *b = *b, *a
}

// At least one != 0
func GCD[T Unsigned](a, b T) T {
	if b < a {
		Swap(&a, &b)
	}
	for {
		if a == 0 {
			return b
		}
		r := (b % a)
		b = a
		a = r
	}
}

// At least one != 0
func LCM[T Unsigned](a, b T) T {
	return (a * b) / GCD(a, b)
}

func First[T any](a T, _ any) T { return a }

// #endregion

// #region IO STUFF
type IO struct {
	r *bufio.Reader
	w *bufio.Writer
}

func newStdIO() IO {
	return IO{
		r: bufio.NewReader(os.Stdin),
		w: bufio.NewWriter(os.Stdout),
	}
}

// Is assumed that input.txt file exists
func newFileIO() IO {
	return IO{
		r: bufio.NewReader(First(os.Open("input.txt"))),
		w: bufio.NewWriter(First(os.OpenFile("output.txt", os.O_CREATE|os.O_RDWR|os.O_TRUNC, os.ModePerm))),
	}
}

func (io *IO) ScanInt8() (x int8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt16() (x int16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt32() (x int32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanInt64() (x int64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanUInt8() (x uint8)   { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt16() (x uint16) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt32() (x uint32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanUInt64() (x uint64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanFloat32() (x float32) { fmt.Fscan(io.r, &x); return }
func (io *IO) ScanFloat64() (x float64) { fmt.Fscan(io.r, &x); return }

func (io *IO) ScanString() (x string) { fmt.Fscan(io.r, &x); return }

func (io *IO) Print(x ...any)   { fmt.Fprint(io.w, x...) }
func (io *IO) PrintLn(x ...any) { fmt.Fprintln(io.w, x...) }

func (io *IO) Flush() { io.w.Flush() }

// #endregion

// #region KEEP IMPORTS
func D() {
	_ = bufio.Reader{}
	_ = bytes.Buffer{}
	_ = suffixarray.Index{}
	_ = log.Default()
	_ = math.Abs(0)
	_ = net.Dialer{}
	_ = path.ErrBadPattern
	_ = sort.Float64sAreSorted(nil)
	_ = strconv.ErrRange
	_ = strings.Builder{}
	_ = time.ANSIC
	_ = newStdIO()
	_ = newFileIO()
}

// #endregion


package main

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

const (
	MOD int64 = 1e9+7
	NL byte = byte('\n')
	SP byte = byte(' ')
)

var (
	in *bufio.Scanner
	out *bufio.Writer

	n, k int
	a [100000]int64
	res int64
)

func main() {
	initBuffer()
	var t int = 1
	t = getInt()
	for i := 0; i < t; i++ {
		solve()
	}
	// test()
	out.Flush()
}

func solve() {
	initialize()
	input()
	count()
	output()
}

func initialize() {
	res = -1e18
}

func input() {
	n = getInt()
	k = getInt()
	for i := 0; i < n; i++ {
		a[i] = getInt64()
	}
}

func count() {
	for i := max(0, n - 1 - 2 * k); i < n; i++ {
		for j := i + 1; j < n; j++ {
			res = max64(res, int64(i + 1) * int64(j + 1) - int64(k) * int64(a[i]|a[j]))
		}
	}
}

func output() {
	out.Write(int64ToBytes(res))
	out.WriteByte(NL)
}

func test() {
	fmt.Print()
}

func initBuffer() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer([]byte{}, 4 * 1024 * 1024)
	in.Split(scanWords)
	out = bufio.NewWriter(os.Stdout)
}

func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	i := bytes.IndexByte(data, '\n')
	j := bytes.IndexByte(data, ' ')
	ind := min(i, j)
	if ind < 0 {
		ind = max(i, j)
	}
	if ind >= 0 {
		return ind + 1, dropCR(data[0:ind]), nil
	}
	if atEOF {
		return len(data), dropCR(data), nil
	}
	return 0, nil, nil
}

func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data)-1] == '\r' {
		return data[:len(data)-1]
	}
	return data
}

func getFloat() float64 {
	in.Scan()
	b := in.Bytes()
	var isNeg bool
	if b[0] == '-' {
		isNeg = true
		b = b[1:]
	}
	var res1 int64
	for i := 0; i < len(b); i++ {
		if b[i] == '.' {
			b = b[i+1:]
			break
		}
		res1 *= 10
		res1 += int64(b[i]) - 48
		if i == len(b) - 1 {
			b = b[:0]
		}
	}
	var res2 float64
	for i := len(b); i > 0; i-- {
		res2 += float64(b[i-1]) - 48
		res2 /= 10
	}
	if isNeg {
		res1 *= -1
		res2 *= -1
	}
	return float64(res1) + res2
}

func getInt() int {
	in.Scan()
	b := in.Bytes()
	var isNeg bool
	if b[0] == '-' {
		isNeg = true
		b = b[1:]
	}
	var res int
	for i := 0; i < len(b); i++ {
		res *= 10
		res += int(b[i]) - 48
	}
	if isNeg {
		res *= -1
	}
	return res
}

func getInt64() int64 {
	in.Scan()
	b := in.Bytes()
	var isNeg bool
	if b[0] == '-' {
		isNeg = true
		b = b[1:]
	}
	var res int64
	for i := 0; i < len(b); i++ {
		res *= 10
		res += int64(b[i]) - 48
	}
	if isNeg {
		res *= -1
	}
	return res
}

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

func intToBytes(n int) []byte {
	var res [33]byte
	var isNeg bool
	if n < 0 {
		isNeg = true
		n = -n
	}
	var l int = 33
	for n > 0 {
		l--
		res[l] = byte(n % 10 + 48)
		n /= 10
	}
	if l == 33 {
		l--
		res[l] = byte(48)
	}
	if isNeg {
		l--
		res[l] = byte(45)
	}
	return res[l:]
}

func int64ToBytes(n int64) []byte {
	var res [65]byte
	var isNeg bool
	if n < 0 {
		isNeg = true
		n = -n
	}
	var l int = 65
	for n > 0 {
		l--
		res[l] = byte(n % 10 + 48)
		n /= 10
	}
	if l == 65 {
		l--
		res[l] = byte(48)
	}
	if isNeg {
		l--
		res[l] = byte(45)
	}
	return res[l:]
}

func bsLower(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] < n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] >= n {
		return minN
	}
	return maxN
}

func bsLower64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] < n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] >= n {
		return minN
	}
	return maxN
}

func bsUpper(arr []int, n int) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func bsUpper64(arr []int64, n int64) int {
	var minN, midN, maxN int
	maxN = len(arr)
	for maxN - 1 > minN {
		midN = (minN + maxN) / 2
		if arr[midN] <= n {
			minN = midN
		} else {
			maxN = midN
		}
	}
	if arr[minN] > n {
		return minN
	}
	return maxN
}

func max(n1, n2 int) int {
	if n1 > n2 {
		return n1
	}
	return n2
}

func max64(n1, n2 int64) int64 {
	if n1 > n2 {
		return n1
	}
	return n2
}

func min(n1, n2 int) int {
	if n1 < n2 {
		return n1
	}
	return n2
}

func min64(n1, n2 int64) int64 {
	if n1 < n2 {
		return n1
	}
	return n2
}

func yes(res, isUpperCase bool) bool {
	var arr [4]string = [4]string{"No", "Yes", "NO", "YES"}
	var ind int
	if res == true {
		ind = 1
	}
	if isUpperCase == true {
		ind += 2
	}
	out.WriteString(arr[ind])
	out.WriteByte(NL)
	return res
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"math/bits"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1554B(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	type pair struct{ fi, se int }

	var T, n, k, v int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &k)
		mx := bits.Len(uint(n))
		dp := make([]pair, 1<<mx)
		for i := 1; i <= n; i++ {
			Fscan(in, &v)
			dp[v] = pair{i, dp[v].fi}
		}
		for i := 0; i < mx; i++ {
			for s := 0; s < 1<<mx; s++ {
				s |= 1 << i
				p, q := dp[s], dp[s^1<<i]
				if q.se > p.fi {
					dp[s] = q
				} else if q.fi > p.fi {
					dp[s] = pair{q.fi, p.fi}
				} else if q.fi > p.se {
					dp[s].se = q.fi
				}
			}
		}
		ans := int64(-1e18)
		for s, p := range dp {
			if p.se > 0 {
				if v := int64(p.fi)*int64(p.se) - int64(k*s); v > ans {
					ans = v
				}
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

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

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

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

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

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

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

func solve() {
	var n, k int64
	scan(&n, &k)
	var a = make([][2]int64, n)
	for i := range a {
		scan(&a[i][0])
		a[i][1] = int64(i + 1)
	}
	if len(a) > 500 {
		a = a[len(a)-500:]
	}
	var ans int64 = -(1 << 60)
	for i := range a {
		for j := i + 1; j < len(a); j++ {
			r := a[i][1]*a[j][1] - k*(a[i][0]|a[j][0])
			if ans < r {
				ans = r
			}
		}
	}
	printf("%v\n", ans)
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64) int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64) int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int64
		var k int64
		fmt.Fscan(in,&n,&k)
		var a [100005]int64
		var i int64
		for i=1;i<=n;i++ {
			fmt.Fscan(in, &a[i])
		}
		st := max(n-2*k,1)
		var ans int64
		ans = -99999999
		for i=st;i<=n;i++{
			for j:=i+1;j<=n;j++{
				ans = max(ans, i*j-(a[i]|a[j])*k)
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

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

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	solve := func() {
		var n int
		var k int
		var ans int64
		Fscan(in, &n, &k)
		a := make([]int64, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans = -1000000000
		for i := n - 205; i < n; i++ {
			if i < 0 {
				continue
			}
			for j := i + 1; j < n; j++ {
				ans = max(ans, int64(i+1)*int64(j+1)-int64(k)*(a[i]|a[j]))
			}
		}
		Fprintln(out, ans)
	}
	var T int
	Fscan(in, &T)
	for i := 0; i < T; i++ {
		solve()
	}
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int64) int64{
	if x>y{
		return x
	}
	return y
}
func min(x, y int64) int64{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n int64
		var k int64
		fmt.Fscan(in,&n,&k)
		var a [300005]int64
		var i int64
		for i=1;i<=n;i++ {
			fmt.Fscan(in, &a[i])
		}
		st := max(n-2*k,1)
		var ans int64
		ans = -99999999
		for i=st;i<=n;i++{
			for j:=i+1;j<=n;j++{
				ans = max(ans, i*j-(a[i]|a[j])*k)
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
func max(x, y int) int{
	if x>y{
		return x
	}
	return y
}
func min(x, y int) int{
	if x<y{
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var n, k int
		fmt.Fscan(in,&n,&k)
		var a [300005]int
		for i:=1;i<=n;i++ {
			fmt.Fscan(in, &a[i])
		}
		st := max(n-2*k,1)
		ans := -99999999
		for i:=st;i<=n;i++{
			for j:=i+1;j<=n;j++{
				ans = max(ans, i*j-(a[i]|a[j])*k)
			}
		}
		fmt.Fprintln(out,ans)
	}
}

package main

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

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

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

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

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

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

func solve() {
	var n, k int64
	scan(&n, &k)
	var a = make([]int64, n)
	for i := range a {
		scan(&a[i])
	}
	var ans int64 = -(1 << 60)
	for b := 0; b < 20; b++ {
		res := [][2]int64{}
		var mask int64 = ^(1<<b - 1)
		for i := n - 1; len(res) < 2 && i >= 0; i-- {
			if mask&a[i] == 0 {
				res = append(res, [2]int64{i + 1, a[i]})
			}
		}
		if len(res) == 2 {
			r := res[0][0]*res[1][0] - k*(res[0][1]|res[1][1])
			if ans < r {
				ans = r
			}
		}
	}
	printf("%v\n", ans)
}

package main

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

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

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

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

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

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

func solve() {
	var n, k int
	scan(&n, &k)
	var a = make([]int, n)
	for i := range a {
		scan(&a[i])
	}
	var ans = -(1 << 30)
	for b := 0; b < 20; b++ {
		res := [][2]int{}
		mask := ^(1<<b - 1)
		for i := n - 1; len(res) < 2 && i >= 0; i-- {
			if mask&a[i] == 0 {
				res = append(res, [2]int{i + 1, a[i]})
			}
		}
		if len(res) == 2 {
			r := res[0][0]*res[1][0] - k*(res[0][1]|res[1][1])
			if ans < r {
				ans = r
			}
		}
	}
	printf("%v\n", ans)
}

package main

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

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	solve := func() {
		var n int
		var k int
		var ans int64
		Fscan(in, &n, &k)
		a := make([]int64, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans = -1000000000
		for i := n/2 - 105; i < n/2+105; i++ {
			if i < 0 || i >= n {
				continue
			}
			for j := i + 1; j < n/2+105; j++ {
				if j >= n {
					break
				}
				ans = max(ans, int64(i+1)*int64(j+1)-int64(k)*(a[i]|a[j]))
			}
		}
		Fprintln(out, ans)
	}
	var T int
	Fscan(in, &T)
	for i := 0; i < T; i++ {
		solve()
	}
}

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


package main

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

//N _
const (
	N = 2*1e5 + 5
)

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func min(values []int64) int64{
	mn := values[0]
	for _, v := range values {
			if (v < mn) {
				mn = v
			}
	}
	return mn
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	n , _ := strconv.ParseInt(*<-strs, 10, 64)
	m , _ := strconv.ParseInt(*<-strs, 10, 64)

	mx := int64(0)
	for i := int64(0); i < n; i++ {
		a := make([]int64, m)
		for j := int64(0); j < m; j++ {
			x, _ := strconv.ParseInt(*<-strs, 10, 64)
			a[j] = x
		}

		y := min(a)

		if y > mx {
			mx = y
		}
	}

	ws.WriteString(fmt.Sprint(mx))

	ws.Flush()
}

package main

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

//N _
const (
	N = 2*1e5 + 5
)

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func min(values []int64, ch chan int64) {
	mn := values[0]
	for _, v := range values {
			if (v < mn) {
				mn = v
			}
	}
	ch <- mn
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	n , _ := strconv.ParseInt(*<-strs, 10, 64)
	m , _ := strconv.ParseInt(*<-strs, 10, 64)

	ch := make(chan int64, n)

	for i := int64(0); i < n; i++ {
		a := make([]int64, m)
		for j := int64(0); j < m; j++ {
			x, _ := strconv.ParseInt(*<-strs, 10, 64)
			a[j] = x
		}
		go min(a, ch)
	}

	mx := int64(0)
	for i:=int64(0); i < n; i++{
		x := <-ch
		if x > mx {
			mx = x
		}
	}

	ws.WriteString(fmt.Sprint(mx))

	ws.Flush()
}

package main

import "fmt"

func main() {
	var n, m int
	var ans uint32 = 0
	fmt.Scan(&n, &m)
	for i := 0; i < n; i++ {
		var x uint32
		var t uint32 = ^(uint32(0))
		for j := 0; j < m; j++ {
			fmt.Scan(&x)
			if x < t {
				t = x
			}
		}
		if t > ans {
			ans = t
		}
	}
	fmt.Println(ans)
}

package main

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

func main() {
    var n,m int
    var c [100][100]int
    var mins [100]int
    for i := 0; i < 100; i++ {
        mins[i] = 1000000000
    }

    fmt.Scanf("%d %d\n", &n, &m)
    //fmt.Printf("%d %d\n", n, m)

    scanner := bufio.NewScanner(os.Stdin)
    for i := 0; i < n; i++ {
        scanner.Scan()
        s := scanner.Text()
        ss := strings.Fields(s)
        for j := 0; j < m; j++ {
            c[i][j], _ = strconv.Atoi(ss[j])
            if c[i][j] < mins[i] {
                mins[i] = c[i][j]
            }
        }
    }
//    for i := 0; i < n; i++ {
//        fmt.Printf("%d -> %d\n", i, mins[i])
//    }
    var s int = 0
    for i := 0; i < n; i++ {
        if mins[i] > s {
            s = mins[i]
        }
    }
    fmt.Printf("%d", s)
}

package main

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

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

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

func main() {
    stdin := bufio.NewReader(os.Stdin)
    var n, m int
    fmt.Fscan(stdin, &n, &m)

    r := int64(0)
    for i := 0; i < n; i++ {
      c := int64(1000000001)
      for j := 0; j < m; j++ {
        var t int64
        fmt.Fscan(stdin, &t)
        c = min(c, t)
      }
      r = max(r, c)
    }
    fmt.Println(r)
}

package main
import "fmt"
func main () {
    var n,m,t int
    fmt.Scan(&n,&m)
    r:=make([]int,n)
    for i:=0;i<n;i++ {
        fmt.Scan(&r[i])
        for j:=1;j<m;j++ {
            fmt.Scan(&t)
            if t<r[i] {
                r[i]=t
            }
        }
    }
    t=r[0]
    for i:=0;i<n;i++ {
        if r[i]>t {
            t=r[i]
        }
    }
    fmt.Println(t)
}

package main

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

func Min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

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

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

	var st, av int64
	fmt.Fscanln(in, &st, &av)

	min_arr := make([]int64, st)
	for index, _ := range min_arr {
		min_arr[index] = 1<<40
	}

	for i:=0; int64(i)<st; i++ {
		for j:=0; int64(j)<av; j++ {
			var ij int64
			fmt.Fscan(in, &ij)
			min_arr[i] = Min(min_arr[i], ij)
		}
	}

	var max int64
	max = 0
	for i:=0; int64(i)<st;i++ {
		max = Max(max, min_arr[i])
	}

	fmt.Fprintln(out, max)
	out.Flush()
}

package main

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

//N _
const (
	N = 2*1e5 + 5
)

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func min(values []int64) int64{
	mn := values[0]
	for _, v := range values {
			if (v < mn) {
				mn = v
			}
	}
	return mn
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	n , _ := strconv.ParseInt(*<-strs, 10, 64)
	m , _ := strconv.ParseInt(*<-strs, 10, 64)

	a := make([]int64, m)

	mx := int64(0)
	for i := int64(0); i < n; i++ {

		for j := int64(0); j < m; j++ {
			x, _ := strconv.ParseInt(*<-strs, 10, 64)
			a[j] = x
		}

		y := min(a)

		if y > mx {
			mx = y
		}
	}

	ws.WriteString(fmt.Sprint(mx))

	ws.Flush()
}

package main

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

func Min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}

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

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

	var st, av int64
	fmt.Fscanln(in, &st, &av)

	min_arr := make([]int64, av)
	for index, _ := range min_arr {
		min_arr[index] = 1<<40
	}

	for i:=0; int64(i)<st; i++ {
		for j:=0; int64(j)<av; j++ {
			var ij int64
			fmt.Fscan(in, &ij)
			min_arr[j] = Min(min_arr[j], ij)
		}
	}

	var max int64
	max = 0
	for i:=0; int64(i)<av;i++ {
		max = Max(max, min_arr[i])
	}

	fmt.Fprintln(out, max)
	out.Flush()
}


package main

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

func sum(vals ...int) int {
	x := 0
	for _, u := range vals {
		x += u
	}
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	nrTests, _ := strconv.Atoi(scanner.Text())
	for i := 0; i < nrTests; i++ {
		dict := make(map[string][]int)
		for j := 0; j < 4; j++ {
			scanner.Scan()
			if j == 0 {
				continue
			}
			for _, x := range strings.Split(scanner.Text(), " ") {
				if arr, ok := dict[x]; ok {
					arr[j-1] = 1
				} else {
					dict[x] = make([]int, 3)
					dict[x][j-1] = 1
				}
			}
		}
		var points [3]int
		for _, persons := range dict {
			nrPoints := 0
			switch sum(persons...) {
			case 1:
				nrPoints = 3
			case 2:
				nrPoints = 1
			}
			for idx, v := range persons {
				points[idx] += v * nrPoints
			}
		}
		fmt.Println(points[0], points[1], points[2])
	}
}

package main

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

type words map[string]struct{}

func (w words) add(word string) {
	w[word] = struct{}{}
}

func (w words) exists(word string) bool {
	_, ok := w[word]
	return ok
}

func getPoint(w string, a, b words) int {
	switch {
	case a.exists(w) && b.exists(w):
		return 0
	case a.exists(w) || b.exists(w):
		return 1
	default:
		return 3
	}
}

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

	for t > 0 {
		t--
		n := readInt(in)
		w1 := make(words, n)
		w2 := make(words, n)
		w3 := make(words, n)
		var p1, p2, p3 int

		for _, v := range readLineNumbs(in) {
			w1.add(v)
		}
		for _, v := range readLineNumbs(in) {
			w2.add(v)
		}
		for _, v := range readLineNumbs(in) {
			w3.add(v)
		}

		for k := range w1 {
			p := getPoint(k, w2, w3)
			p1 += p
		}
		for k := range w2 {
			p := getPoint(k, w1, w3)
			p2 += p
		}
		for k := range w3 {
			p3 += getPoint(k, w1, w2)
		}

		fmt.Printf("%d %d %d\n", p1, p2, p3)
	}
}

// ================================
// NO EDIT

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 readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

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 n int
		fmt.Fscan(in, &n)

		aa := make([][]string, 3)
		for i := 0; i < 3; i++ {
			aa[i] = make([]string, n)
		}
		mm := make(map[string]int, n*3)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				fmt.Fscan(in, &aa[i][j])
				mm[aa[i][j]]++
			}
		}

		bb := make([]int, 3)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				if mm[aa[i][j]] == 1 {
					bb[i] += 3
				} else if mm[aa[i][j]] == 2 {
					bb[i] += 1
				}
			}
		}
		fmt.Fprintln(out, bb[0], bb[1], bb[2])
	}
}

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 n int
		fmt.Fscan(in, &n)

		aa := make([][]string, 3)
		for i := 0; i < 3; i++ {
			aa[i] = make([]string, n)
		}
		mm := make(map[string]int, n*3)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[0][i])
			mm[aa[0][i]]++
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[1][i])
			mm[aa[1][i]]++
		}
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[2][i])
			mm[aa[2][i]]++
		}

		var a, b, c int
		for i := 0; i < n; i++ {
			if mm[aa[0][i]] == 1 {
				a += 3
			} else if mm[aa[0][i]] == 2 {
				a += 1
			}
		}
		for i := 0; i < n; i++ {
			if mm[aa[1][i]] == 1 {
				b += 3
			} else if mm[aa[1][i]] == 2 {
				b += 1
			}
		}
		for i := 0; i < n; i++ {
			if mm[aa[2][i]] == 1 {
				c += 3
			} else if mm[aa[2][i]] == 2 {
				c += 1
			}
		}
		fmt.Fprintln(out, a, b, c)
	}
}

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)
		mapper:= make(map[string]int)
		var list [][]string
		for j:=0;j<3;j++{
			innerlist:= make([]string,n)
			for k:=0;k<n;k++{
				fmt.Fscan(in,&innerlist[k])
				if mapper[string(innerlist[k])] >= 1 {
					mapper[string(innerlist[k])]+=1
					continue
				}
				mapper[string(innerlist[k])] = 1
			}
			list = append(list,innerlist)
		}
		var output []int
		for j:=0;j<3;j++{
			for k:=0;k<n;k++{
				if mapper[string(list[j][k])] == 3 {
					output = append(output, 0)
				} else if mapper[string(list[j][k])] == 2 {
					output = append(output, 1)
				} else if mapper[string(list[j][k])] == 1 {
					output = append(output, 3)
				}
			}
		}
		tally:=0
		for j:=0;j<len(output);j++{
			tally+=output[j]
			if (j+1)%n == 0 {
				fmt.Fprintf(out,"%v ",tally)
				tally=0
			}
		}
		fmt.Fprintln(out,)
	}
}

package main

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

func main() {
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(cin, &n)
		wordOccuranceGlobal := map[string]int{}
		person := map[int]map[string]bool{}
		for j := 0; j < 3; j++ {
			person[j] = make(map[string]bool)
			for k := 0; k < n; k++ {
				var word string
				fmt.Fscan(cin, &word)
				wordOccuranceGlobal[word]++
				person[j][word] = true
			}
		}
		scoreboard := make([]int, 3)
		for j := 0; j < 3; j++ {
			for k, v := range wordOccuranceGlobal {
				if _, ok := person[j][k]; ok {
					switch {
					case v == 1:
						scoreboard[j] += 3
					case v == 2:
						scoreboard[j] += 1
					}
				}
			}
		}

		fmt.Printf("%d %d %d\n", scoreboard[0], scoreboard[1], scoreboard[2])
	}
}

package main

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

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

func solve(arr map[string][]int) string {
	var p [3]int
	for _, x := range arr {
		l := len(x)
		var q int
		if l == 1 {
			q = 3
		} else if l == 2 {
			q = 1
		}
		for _, y := range x {
			p[y] += q
		}
	}
	return strings.Trim(fmt.Sprint(p), "[]")
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		arr := make(map[string][]int)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				fmt.Fscan(reader, &s)
				arr[s] = append(arr[s], i)
			}
		}
		fmt.Println(solve(arr))
	}
}

package main

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

func main() {
	r := readerStdin()
	cases := readInt(r)

	for cases != 0 {
		_ = readInt(r)

		var allWords = make([][]string, 0, 3)
		for i := 0; i < 3; i++ {
			allWords = append(allWords, readSliceString(r))
		}

		var hash = make(map[string]int)
		for _, words := range allWords {
			for _, word := range words {
				hash[word]++
			}
		}

		var persons [3]int
		for i, words := range allWords {
			for _, word := range words {
				quantity := hash[word]
				switch quantity {
				case 1:
					persons[i] += 3
				case 2:
					persons[i] += 1
				}
			}
		}

		fmt.Printf("%d %d %d\n", persons[0], persons[1], persons[2])
		cases--
	}
}

func readerStdin() *bufio.Reader {
	return bufio.NewReader(os.Stdin)
}

func readString(r *bufio.Reader) (s string) {
	s, _ = r.ReadString('\n')
	s = strings.ReplaceAll(s, "\n", "")
	s = strings.ReplaceAll(s, "\r", "")
	return
}

func readInt(r *bufio.Reader) (i int) {
	str := readString(r)
	i, _ = strconv.Atoi(str)
	return
}

func readSliceString(r *bufio.Reader) []string {
	str := readString(r)

	return strings.Split(str, " ")
}

package main

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

type float = float32
type double = float64
type long = int64
type ulong = uint64

type Readable interface {
	bool | int | uint64 | int64 | double | float | byte
}

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

func print(arg ...interface{})            { fmt.Fprint(out, arg...) }
func println(arg ...interface{})          { fmt.Fprintln(out, arg...) }
func printf(f string, arg ...interface{}) { fmt.Fprintf(out, f, arg...) }
func scanf(f string, arg ...interface{})  { fmt.Fscanf(in, f, arg...) }

func readLn() string {
	ln, err := in.ReadString('\n')
	if err != nil {
		panic(err)
	}

	return strings.Trim(ln, " \n\r")
}

func readString() string {
	return readLn()
}

func readStrings() []string {
	return strings.Split(readLn(), " ")
}

func read[T Readable](f func(string) (T, error), input ...string) T {
	if len(input) == 0 {
		input = []string{readLn()}
	}

	res, err := f(input[0])
	if err != nil {
		panic(err)
	}

	return res
}

func readMany[T Readable](f func(...string) T) []T {
	input := readStrings()
	arr := make([]T, len(input))
	for i := 0; i < len(arr); i++ {
		arr[i] = f(input[i])
	}

	return arr
}

func readBool(input ...string) bool {
	return read(strconv.ParseBool, input...)
}

func readInt(input ...string) int {
	return read(strconv.Atoi, input...)
}

func readByte(input ...string) byte {
	return byte(read(func(s string) (uint64, error) {
		return strconv.ParseUint(s, 10, 8)
	}, input...))
}

func readDouble(input ...string) double {
	return read(func(s string) (float64, error) {
		return strconv.ParseFloat(s, 64)
	}, input...)
}

func readFloat(input ...string) float {
	return float32(read(func(s string) (float64, error) {
		return strconv.ParseFloat(s, 32)
	}, input...))
}

func readLong(input ...string) long {
	return read(func(s string) (int64, error) {
		return strconv.ParseInt(s, 10, 64)
	}, input...)
}

func readULong(input ...string) ulong {
	return read(func(s string) (uint64, error) {
		return strconv.ParseUint(s, 10, 64)
	}, input...)
}

func readBinary(input ...string) long {
	return read(func(s string) (int64, error) {
		return strconv.ParseInt(s, 2, 64)
	}, input...)
}

func readBools() []bool {
	return readMany(readBool)
}

func readInts() []int {
	return readMany(readInt)
}

func readBytes() []byte {
	return readMany(readByte)
}

func readDoubles() []double {
	return readMany(readDouble)
}

func readFloats() []float {
	return readMany(readFloat)
}

func readLongs() []long {
	return readMany(readLong)
}

func readULongs() []ulong {
	return readMany(readULong)
}

func main() {
	defer out.Flush()

	// solution
	t := readInt()
	ans := make([][3]int, t)
	for i := 0; i < t; i++ {
		n := readInt()
		s1 := readString()
		arr1 := strings.Split(s1, " ")
		s2 := readString()
		arr2 := strings.Split(s2, " ")
		s3 := readString()
		arr3 := strings.Split(s3, " ")
		m1 := make(map[string]struct{}, n)
		m2 := make(map[string]struct{}, n)
		m3 := make(map[string]struct{}, n)
		for j := 0; j < n; j++ {
			m1[arr1[j]] = struct{}{}
			m2[arr2[j]] = struct{}{}
			m3[arr3[j]] = struct{}{}
		}
		c1 := 0
		c2 := 0
		c3 := 0
		for k := range m1 {
			_, ok2 := m2[k]
			_, ok3 := m3[k]
			if ok2 && ok3 {
				continue
			}
			if !ok2 && !ok3 {
				c1 += 3
				continue
			}
			c1 += 1
		}
		for k := range m2 {
			_, ok1 := m1[k]
			_, ok3 := m3[k]
			if ok1 && ok3 {
				continue
			}
			if !ok1 && !ok3 {
				c2 += 3
				continue
			}
			c2 += 1
		}
		for k := range m3 {
			_, ok1 := m1[k]
			_, ok2 := m2[k]
			if ok1 && ok2 {
				continue
			}
			if !ok1 && !ok2 {
				c3 += 3
				continue
			}
			c3 += 1
		}
		ans[i][0] = c1
		ans[i][1] = c2
		ans[i][2] = c3
	}
	for i := 0; i < t; i++ {
		println(ans[i][0], ans[i][1], ans[i][2])
	}
}

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

	return x
}

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

	return y
}

func min(x, y long) long {
	if x > y {
		return y
	}

	return x
}

package main

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

var (
	in    *bufio.Reader = bufio.NewReader(os.Stdin)
	t, n  int
	s     [3][2000]string
	mp    map[string]int
	score map[int]int = map[int]int{
		1: 3,
		2: 3,
		4: 3,
		3: 1,
		5: 1,
		6: 1,
		7: 0,
	}
)

func main() {
	fmt.Fscan(in, &t)
	for t > 0 {
		fmt.Fscan(in, &n)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				fmt.Fscan(in, &s[i][j])
			}
		}
		solve()
		t--
	}
}

func solve() {
	mp = map[string]int{}
	for i := 0; i < 3; i++ {
		for j := 0; j < n; j++ {
			mp[s[i][j]] = mp[s[i][j]] | (1 << i)
		}
	}
	var buf bytes.Buffer
	for i := 0; i < 3; i++ {
		ans := 0
		for j := 0; j < n; j++ {
			ans += score[mp[s[i][j]]]
		}
		buf.WriteString(strconv.Itoa(ans))
		if i != 2 {
			buf.WriteByte(' ')
		}
	}
	fmt.Println(buf.String())
}

package main

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

func Solve_1722C() {
	var t, n int
	br := bufio.NewReaderSize(os.Stdin, 4)
	bw := bufio.NewWriterSize(os.Stdout, 4)
	fmt.Fscan(br, &t)
	words := make([][]string, 3)
	for i := 0; i < 3; i++ {
		words[i] = make([]string, 1000)
	}
	for t > 0 {
		t--
		fmt.Fscan(br, &n)
		word2cnt := make(map[string]int, 0)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				fmt.Fscan(br, &words[i][j])
				word2cnt[words[i][j]]++
			}
		}
		score := make([]int, 3)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				switch word2cnt[words[i][j]] {
				case 1:
					{
						score[i] += 3
					}
				case 2:
					{
						score[i] += 1
					}
				}
			}
		}
		fmt.Fprintf(bw, "%d %d %d\n", score[0], score[1], score[2])
	}
	bw.Flush()
}

func main() {
  Solve_1722C()
}

package main

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

func Solve_1722C() {
	var t, n int
	br := bufio.NewReaderSize(os.Stdin, 4)
	bw := bufio.NewWriterSize(os.Stdout, 4)
	defer bw.Flush()
	fmt.Fscan(br, &t)
	words := make([][]string, 3)
	for i := 0; i < 3; i++ {
		words[i] = make([]string, 1000)
	}
	for t > 0 {
		t--
		fmt.Fscan(br, &n)
		word2cnt := make(map[string]int, 0)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				fmt.Fscan(br, &words[i][j])
				word2cnt[words[i][j]]++
			}
		}
		score := make([]int, 3)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				switch word2cnt[words[i][j]] {
				case 1:
					{
						score[i] += 3
					}
				case 2:
					{
						score[i] += 1
					}
				}
			}
		}
		fmt.Fprintf(bw, "%d %d %d\n", score[0], score[1], score[2])
	}
}

func main() {
  Solve_1722C()
}

package main

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

func Solve_1722C() {
	var t, n int
	br := bufio.NewReader(os.Stdin)
	bw := bufio.NewWriter(os.Stdout)
	defer bw.Flush()
	fmt.Fscan(br, &t)
	words := make([][]string, 3)
	for i := 0; i < 3; i++ {
		words[i] = make([]string, 1000)
	}
	for t > 0 {
		t--
		fmt.Fscan(br, &n)
		word2cnt := make(map[string]int, 0)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				fmt.Fscan(br, &words[i][j])
				word2cnt[words[i][j]]++
			}
		}
		score := make([]int, 3)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				switch word2cnt[words[i][j]] {
				case 1:
					{
						score[i] += 3
					}
				case 2:
					{
						score[i] += 1
					}
				}
			}
		}
		fmt.Fprintf(bw, "%d %d %d\n", score[0], score[1], score[2])
	}
}

func main() {
  Solve_1722C()
}

package main

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

func Solve_1722C() {
	var t, n int
	br := bufio.NewReader(os.Stdin)
	fmt.Fscan(br, &t)
	words := make([][]string, 3)
	for i := 0; i < 3; i++ {
		words[i] = make([]string, 1000)
	}
	for t > 0 {
		t--
		fmt.Fscan(br, &n)
		word2cnt := make(map[string]int, 0)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				fmt.Fscan(br, &words[i][j])
				word2cnt[words[i][j]]++
			}
		}
		score := make([]int, 3)
		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				switch word2cnt[words[i][j]] {
				case 1:
					{
						score[i] += 3
					}
				case 2:
					{
						score[i] += 1
					}
				}
			}
		}
		fmt.Printf("%d %d %d\n", score[0], score[1], score[2])
	}
}

func main() {
  Solve_1722C()
}

package main

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

func main() {
	var T int
	var N int
	var S string
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &T)
	for T > 0 {
		fmt.Fscan(in, &N)
		playersWords := make([][]string, 3)
		m := make(map[string]int)
		for i := 0; i < 3; i++ {
			playersWords[i] = make([]string, N)
			for j := 0; j < N; j++ {
				fmt.Fscan(in, &S)
				m[S]++
				playersWords[i][j] = S
			}
		}
		for i := 0; i < 3; i++ {
			resOfPlayer := 0
			for j := 0; j < N; j++ {
				word := playersWords[i][j]
				countOfWords := m[word]
				switch countOfWords {
				case 1:
					resOfPlayer += 3
				case 2:
					resOfPlayer += 1
				case 3:
					resOfPlayer += 0
				}
			}
			fmt.Print(resOfPlayer, " ")
		}
		fmt.Println()
		T--
	}
}

package main

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

func run(r_ io.Reader, w_ io.Writer) {
	in := bufio.NewReader(r_)
	out := bufio.NewWriter(w_)
	defer out.Flush()

	var t, n int
	fmt.Fscan(in, &t)
	for t > 0 {
		t--
		var words1, words2, words3 [1005]string
		cnt := make(map[string]int)
		fmt.Fscan(in, &n)
		input := func(ws *[1005]string) {
			for i := 0; i < n; i++ {
				fmt.Fscan(in, &ws[i])
				cnt[ws[i]]++
			}
		}
		output := func(ws [1005]string) {
			res := 0
			for i := 0; i < n; i++ {
				switch cnt[ws[i]] {
				case 1:
					res += 3
				case 2:
					res += 1
				}
			}
			fmt.Fprint(out, res)
		}
		input(&words1)
		input(&words2)
		input(&words3)
		output(words1)
		fmt.Fprint(out, " ")
		output(words2)
		fmt.Fprint(out, " ")
		output(words3)
		fmt.Fprintln(out)
	}
}

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

package main

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

func solve(n int, mat [][]string) (int, int, int) {
	// solution here
	sol := make([]int, 3)

	maps := make(map[string]int)
	for i := 0; i < 3; i++ {
		for j := 0; j < n; j++ {
			maps[mat[i][j]]++
		}
	}

	for i := 0; i < 3; i++ {
		for j := 0; j < n; j++ {
			val, _ := maps[mat[i][j]]
			if val == 2 {
				sol[i] += 1
			} else if val == 1 {
				sol[i] += 3
			}
		}
	}

	return sol[0], sol[1], sol[2]
}

func f(mat [][]string, j, p int) int {
	r := 0
	total := 0
	for i := 0; i < 3; i++ {
		if mat[p][j] == mat[i][j] {
			total++
		}
	}
	if total == 2 {
		r += 1
	} else if total == 1 {
		r += 3
	}
	return r
}

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

func (in *CF1722C) 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 *CF1722C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

func (in *CF1722C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mat := make([][]string, 3)

		for i := 0; i < 3; i++ {
			mat[i] = make([]string, n)
			for j := 0; j < n; j++ {
				mat[i][j] = in.NextString()
			}
		}

		a, b, c := solve(n, mat)
		fmt.Println(a, b, c)
	}
}

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

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

package main

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

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

func (in *CF1722C) 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 *CF1722C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1722C
Date: 9/3/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1722/C
Problem: CF1722C
**/
func (in *CF1722C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n := in.NextInt()
		mapas := make([]map[string]bool, 3)

		for i := 0; i < 3; i++ {
			mapas[i] = make(map[string]bool)
		}

		sol := make([]int, 3)

		for i := 0; i < 3; i++ {
			for j := 0; j < n; j++ {
				str := in.NextString()
				mapas[i][str] = true
			}
		}

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

			for str := range mapas[i] {
				points := 3
				count := 0
				for j := 0; j < 3; j++ {
					if j != i {
						_, e := mapas[j][str]
						if e {
							count++
						}
					}
				}
				if count == 2 {
					points = 0
				} else if count == 1 {
					points = 1
				}
				sol[i] += points
			}
		}

		fmt.Println(sol[0], sol[1], sol[2])

	}
}

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

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

package main

import (
	"fmt"
)

type words map[string]struct{}

func (w words) add(word string) {
	w[word] = struct{}{}
}

func (w words) exists(word string) bool {
	_, ok := w[word]
	return ok
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	var getPoint = func(w string, a, b words) int {
		switch {
		case a.exists(w) && b.exists(w):
			return 0
		case a.exists(w) || b.exists(w):
			return 1
		default:
			return 3
		}
	}
	for t > 0 {
		t--
		var n int
		fmt.Scanf("%d\n", &n)
		w1 := make(words, n)
		w2 := make(words, n)
		w3 := make(words, n)
		var p1, p2, p3 int
		for i := 0; i < n; i++ {
			var tmp string
			fmt.Scanf("%s", &tmp)
			w1.add(tmp)
		}
		for i := 0; i < n; i++ {
			var tmp string
			fmt.Scanf("%s", &tmp)
			w2.add(tmp)
		}
		for i := 0; i < n; i++ {
			var tmp string
			fmt.Scanf("%s", &tmp)
			w3.add(tmp)
		}

		for k := range w1 {
			p := getPoint(k, w2, w3)
			p1 += p
		}
		for k := range w2 {
			p := getPoint(k, w1, w3)
			p2 += p
		}
		for k := range w3 {
			p3 += getPoint(k, w1, w2)
		}

		fmt.Printf("%d %d %d\n", p1, p2, p3)
	}
}