package main

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

type IOP struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}
var iost *IOP

func NewIOP() *IOP {
	fp := os.Stdin
	wfp := os.Stdout
	//fmt.Println("adsfa",os.Getenv("inLocalEnv"))
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &IOP{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *IOP) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *IOP) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *IOP) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *IOP) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *IOP) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *IOP) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *IOP) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *IOP) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *IOP) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *IOP) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("inLocalEnv") == "indeed" }

func main() {

	iost = NewIOP()
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			a := iost.GetNextInt()
			b := iost.GetNextInt()
			c := iost.GetNextInt()
			if a > b {
				a, b = b, a
			}
			ret := -1
			if c <= (b-a)*2 && b <= (b-a)*2 {
				if c <= (b - a) {
					ret = c + (b - a)
				} else {
					ret = c - (b - a)
				}
			}
			iost.Println(ret)
		}()
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.ParseInt(s, 10, 32); return int(x) }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                              { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &iop{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

var rw *iop

func main() {
	rw = newIop()
	defer func() {
		if isLocal() {
			rw.Println("Recovering ", recover())
		}
		rw.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		rw.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	test := rw.GetNextInt()
	for test > 0 {
		test--
		func() {
			a := rw.GetNextInt()
			b := rw.GetNextInt()
			c := rw.GetNextInt()

			if a > b {
				a, b = b, a
			}
			var maxNumber int
			maxNumber = b - a
			if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
				rw.Println(-1)
			} else {
				if c > maxNumber {
					c -= maxNumber
				} else {
					c += maxNumber
				}
				rw.Println(c)
			}
		}()
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.ParseInt(s, 10, 32); return int(x) }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                              { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &iop{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

var rw *iop

func main() {
	rw=newIop()
	defer func() {
		if isLocal() {
			rw.Println("Recovering ", recover())
		}
		rw.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		rw.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	test := rw.GetNextInt()
	for test > 0 {
		test--
		func(){
				a := rw.GetNextInt()
				b := rw.GetNextInt()
				c := rw.GetNextInt()

			if a > b {
				a, b = b, a
			}
			//rw.Print(" test",test)
			if c > (b - a)*2 || a > (b - a)*2 || b > (b - a)*2 {
				rw.Println(-1)
			} else {
				if c > (b - a) {
					c -= (b - a)
				} else {
					c += (b - a)
				}
				rw.Println(c)
			}
		}()
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.ParseInt(s, 10, 32); return int(x) }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                              { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &iop{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

var rw *iop

func main() {
	rw=newIop()
	defer func() {
		if isLocal() {
			rw.Println("Recovering ", recover())
		}
		rw.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		rw.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	test := rw.GetNextInt()
	for test > 0 {
		test--
		func(){
				a := rw.GetNextInt()
				b := rw.GetNextInt()
				c := rw.GetNextInt()

			if a > b {
				a, b = b, a
			}
			ret := -1
			if c <= (b-a)*2 && b <= (b-a)*2 {
				if c <= (b - a) {
					ret = c + (b - a)
				} else {
					ret = c - (b - a)
				}
			}
			rw.Println(ret)
		}()
	}
}

package main

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

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}
var iost *Iost

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("inLocalEnv") == "indeed" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	//fmt.Println("adsfa",os.Getenv("inLocalEnv"))
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			a := iost.GetNextInt()
			b := iost.GetNextInt()
			c := iost.GetNextInt()
			if a > b {
				a, b = b, a
			}
			ret := -1
			if c <= (b-a)*2 && b <= (b-a)*2 {
				if c <= (b - a) {
					ret = c + (b - a)
				} else {
					ret = c - (b - a)
				}
			}
			iost.Println(ret)
		}()
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.ParseInt(s, 10, 32); return int(x) }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                              { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &iop{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

var rw *iop = newIop()

func main() {
	defer func() {
		if isLocal() {
			rw.Println("Recovering ", recover())
		}
		rw.Writer.Flush()
	}()
	solve()
}

func solve() {
	test := rw.GetNextInt()
	for test > 0 {
		test--
		func(){
			var (
				a = rw.GetNextInt()
				b = rw.GetNextInt()
				c = rw.GetNextInt()
			)
			if a > b {
				a, b = b, a
			}
			var maxNumber int
			maxNumber = b - a
			if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
				fmt.Println(-1)

			} else {
				if c > maxNumber {
					c -= maxNumber
				} else {
					c += maxNumber
				}
				fmt.Println(c)
			}
		}()
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &iop{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

var rw *iop= newIop()
func main() {
	defer func() {
		if isLocal() {
			rw.Println("Recovering ",recover())
		}
		rw.Writer.Flush()
	}()
solve()
}

func solve()  {
	test:=rw.GetNextInt()
	for test>0{
		test--
		var (
			a=rw.GetNextInt()
			b=rw.GetNextInt()
			c=rw.GetNextInt()
		)
		if a > b {
			a, b = b, a
		}
		var maxNumber int
		maxNumber = b - a
		if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
			fmt.Println(-1)

		} else {
			if c > maxNumber {
				c -= maxNumber
			} else {
				c += maxNumber
			}
			fmt.Println(c)
		}
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(wfp)
	return &iop{Scanner: scanner, Writer: writer}
}

var rw *iop= newIop()
func main() {
	defer func() {
		if isLocal() {
			rw.Println("Recovering ",recover())
		}
		rw.Writer.Flush()
	}()
solve()
}

func solve()  {
	test:=rw.GetNextInt()
	for test>0{
		test--
		var (
			a=rw.GetNextInt()
			b=rw.GetNextInt()
			c=rw.GetNextInt()
		)
		if a > b {
			a, b = b, a
		}
		var maxNumber int
		maxNumber = b - a
		if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
			fmt.Println(-1)

		} else {
			if c > maxNumber {
				c -= maxNumber
			} else {
				c += maxNumber
			}
			fmt.Println(c)
		}
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

const BufSize = 1000000

//type iop struct {
//	scanner *bufio.Scanner
//	writer  *bufio.Writer
//}
//
//func newIop(fp *io.Reader,wfp *io.Writer) *iop   {
//	const BufSize = 1000000
//	scanner:=bufio.NewScanner(fp)
//	scanner.Buffer(make([]byte,BufSize),BufSize)
//}

//func (i iop) newIop()  {
//
//}
func main() {

	fp := os.Stdin
	scanner := bufio.NewScanner(fp)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	scanner.Split(bufio.ScanLines)
		if !scanner.Scan() {
			panic("NOOOOOO!")
			//fmt.Println(scanner.Text())
		}
	test ,_:= strconv.Atoi(scanner.Text())
	//fmt.Println(test)
	var (
		a, b, c, maxNumber int
	)
	for idx := 0; idx < test; idx++ {
		if !scanner.Scan() {
			fmt.Println(scanner.Text())
			break
		}
		x := scanner.Text()
		INTS := strings.Split(x, " ")
		a, _ = strconv.Atoi(INTS[0])
		b, _ = strconv.Atoi(INTS[1])
		c, _ = strconv.Atoi(INTS[2])
		if a > b {
			a, b = b, a
		}
		maxNumber = b - a
		if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
			fmt.Println(-1)

		} else {
			if c > maxNumber {
				c -= maxNumber
			} else {
				c += maxNumber
			}
			fmt.Println(c)
		}
	}
}

package main

import (
	"fmt"
)

//// IntSlice Sorted
//type IntSlice []int
//func (x IntSlice) Sort() {
//	sort.Sort(x)
//}
//func (x IntSlice) Len() int           { return len(x) }
//func (x IntSlice) Less(i, j int) bool { return x[i] < x[j] }
//func (x IntSlice) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	var (
		a, b, c,maxNumber int
	)
	for idx := 0; idx < n; idx++ {
		fmt.Scan(&a, &b, &c)
		if a > b {
			a, b = b, a
		}
		maxNumber= b - a
		if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
			fmt.Println(-1)

		} else {
			if c > maxNumber {
				c -= maxNumber
			} else {
				c += maxNumber
			}
			fmt.Println(c)
		}
	}

}

// Main Implementation
//
//func Cases() {
//}
//
//func TestCase() {
//
//}

package main

import (
	"fmt"
)

//// IntSlice Sorted
//type IntSlice []int
//func (x IntSlice) Sort() {
//	sort.Sort(x)
//}
//func (x IntSlice) Len() int           { return len(x) }
//func (x IntSlice) Less(i, j int) bool { return x[i] < x[j] }
//func (x IntSlice) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	var (
		a, b, c int
	)
	for idx := 0; idx < n; idx++ {
		fmt.Scan(&a, &b, &c)
		if a > b {
			a, b = b, a
		}
		maxNumber := b - a
		if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
			fmt.Println(-1)

		} else {
			if c > maxNumber {
				c -= maxNumber
			} else {
				c += maxNumber
			}
			fmt.Println(c)
		}
	}

}

// Main Implementation
//
//func Cases() {
//}
//
//func TestCase() {
//
//}

package main

import (
	"fmt"
)

//// IntSlice Sorted
//type IntSlice []int
//func (x IntSlice) Sort() {
//	sort.Sort(x)
//}
//func (x IntSlice) Len() int           { return len(x) }
//func (x IntSlice) Less(i, j int) bool { return x[i] < x[j] }
//func (x IntSlice) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	var n int
	_, _ = fmt.Scan(&n)
	for idx := 0; idx < n; idx++ {
		var (
			a, b, c int
		)
		fmt.Scan(&a, &b, &c)
		if a > b {
			a, b = b, a
		}
		maxNumber := (b - a)
		if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
			fmt.Println(-1)

		} else {
			if c > maxNumber {
				c -= maxNumber
			} else {
				c += maxNumber
			}
			fmt.Println(c)
		}
	}

}

// Main Implementation
//
//func Cases() {
//}
//
//func TestCase() {
//
//}

package main

import "C"
import (
	"fmt"
)

//// IntSlice Sorted
//type IntSlice []int
//func (x IntSlice) Sort() {
//	sort.Sort(x)
//}
//func (x IntSlice) Len() int           { return len(x) }
//func (x IntSlice) Less(i, j int) bool { return x[i] < x[j] }
//func (x IntSlice) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	Cases()
	//TestCase()
}

// Main Implementation

func Cases() {
	var n int
	_, _ = fmt.Scan(&n)
	for idx := 0; idx < n; idx++ {
		TestCase()
	}
}

func TestCase() {
	var (
		a, b, c int
	)
	fmt.Scan(&a, &b, &c)
	if a > b {
		a, b = b, a
	}
	maxNumber:=(b-a)
	//answer:=b+c-a
	if c>maxNumber*2||a>maxNumber*2||b>maxNumber*2{
		fmt.Println(-1)
		return
	}
	if c>maxNumber{
		c-=maxNumber
	}else{
		c+=maxNumber
	}
	fmt.Println(c)
}

package main

import "C"
import (
	"fmt"
)

//// IntSlice Sorted
//type IntSlice []int
//func (x IntSlice) Sort() {
//	sort.Sort(x)
//}
//func (x IntSlice) Len() int           { return len(x) }
//func (x IntSlice) Less(i, j int) bool { return x[i] < x[j] }
//func (x IntSlice) Swap(i, j int)      { x[i], x[j] = x[j], x[i] }

func main() {
	Cases()
	//TestCase()
}

// Main Implementation

func Cases() {
	var n int
	_, _ = fmt.Scan(&n)
	for idx := 0; idx < n; idx++ {
		TestCase()
	}
}

func TestCase() {
	var (
		a, b, c int
	)
	fmt.Scan(&a, &b, &c)
	if a > b {
		a, b = b, a
	}
	maxNumber:=2*(b-a)
	answer:=(b+(c-a)+maxNumber)%maxNumber
	//answer:=b+c-a
	if c>maxNumber||a>maxNumber||b>maxNumber{
		fmt.Println(-1)
		return
	}
	if answer==0{
		answer=maxNumber
	}
	fmt.Println(answer)
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		dd := abs(a - b)
		if a > 2*dd || b > 2*dd || c > 2*dd {
			fmt.Println("-1")
		} else {
			if c <= dd {
				c += dd
			} else {
				c -= dd
			}
			fmt.Println(c)
		}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var a, b, c int
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		fmt.Fscan(in, &c)
		a--; b--; c--
		if a > b {
		    a, b = b, a
		}
		tmp := 2 * (b - a)
		var ans int
		if b >= tmp || c >= tmp || a * 2 >= b {
		    ans = -1
		} else {
		    ans = (c + b - a) % tmp + 1
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	var t int64
	r := bufio.NewReader(os.Stdin)
	fmt.Fscan(r, &t)
	for i := int64(0); i < t; i++ {
		var a, b, c int64
		fmt.Fscan(r, &a, &b, &c)
		maxNum,minNum := abs(a, b)
		abs:=maxNum-minNum
		if 2*abs<maxNum||2*abs<c{
			fmt.Println(-1)
		}else {
			if c>abs{
				fmt.Println(c-abs)
			}else {
				fmt.Println(c+abs)
			}
		}
	}
}

func abs(a int64, b int64) (int64, int64) {
	var max, min int64
	if a >= b {
		max = a
		min = b
	} else {
		max = b
		min = a

	}

	return max, min
}

package main

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

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

	scan := func(a ...interface{}) (int, error)             { return fmt.Fscan(ins, a...) }
	printf := func(s string, a ...interface{}) (int, error) { return fmt.Fprintf(out, s, a...) }
	var n int
	scan(&n)

	for i:=0; i<n;i++{
		var a,b,c int
		scan(&a, &b, &c)
		res := fn(a, b, c)

		printf("%d\n",res)
	}

}
func fn(a ,b, c int) int{
	ln := (b-a) *2

	if ln < 0{
		ln = (a-b)*2
	}
	max := a
	if b>max{
		max = b
	}
	if c>max{
		max = c
	}
	if ln < max{
		return -1
	}

	cgetted := getop(c, ln)
	if cgetted != a && cgetted != b{
		return cgetted
	}
	return -1

}

func getop(a, mle int) int{
	res := a + ((mle-2)/2) + 1
	if res > mle{
		res = res - mle
	}
	return res
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t, a, b, c int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &a, &b, &c)
		w1 := do(a, b, c)
		fmt.Fprint(w, w1)
		fmt.Fprintln(w)
	}
}

func do(a, b, c int) int {
	n := a - b
	if n < 0 {
		n = -n
	}
	if a > n+n || b > n+n || c > n+n {
		return -1
	}
	if v := n + c; 1 <= v && v <= n+n {
		return v
	}
	if v := -n + c; 1 <= v && v <= n+n {
		return v
	}
	return -1
}

package main
import(
    "fmt"
)
func main(){
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var a,b,c int
		fmt.Scan(&a,&b,&c)
		if (abs(a-b)*2) < c || (abs(a-b)*2) < b || (abs(a-b)*2) < a {
			fmt.Println(-1)
		}else{
			if abs(a-b)*2 < c+abs(a-b) {
				fmt.Println(abs((abs(a-b)*2)-(c+abs(a-b))))
			} else {
				fmt.Println(c+abs(a-b))
			}
		}
	}
}

func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main

import (
	"fmt"
	"math"
)

func main() {

	var a, b, c, t int

	fmt.Scan(&t)

	res := make([]int, t)

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

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

		sub := math.Abs(float64(a - b))

		if a > (int(sub)*2) || b > (int(sub)*2) || c > (int(sub)*2) {

			res[i] = -1

		} else if int(sub) >= c {

			res[i] = c + int(sub)

		} else {
			res[i] = c - int(sub)
		}

	}

	for _, nums := range res {

		fmt.Println(nums)
	}

}

package main

import (
	"fmt"
	"math"
)

func main() {

	var a, b, c, t int

	fmt.Scan(&t)
	var d float64 = 0

	res := make([]int, t)

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

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

		 sub := math.Abs(float64(a - b))
		 eq := math.Abs(float64(a - b))

		if sub >= 2 {

			if sub >= float64(c) {

				d = float64(c) + sub

			} else {

				d = float64(c) - sub
			}

			if a > (int(eq)*2) || b > (int(eq)*2) || c > (int(eq)*2) {

				res[i] = -1

			} else {
				res[i] = int(d)

			}

		} else {

			res[i] = -1

		}

	}

	for _, nums := range res {

		fmt.Println(nums)
	}

}

package main

import (
	"fmt"
	"math"
)

func fun(a, b, c int32) int32 {
	max := int32(math.Abs(float64(a)-float64(b))) * 2
	if c < 0 || c > max || a < 0 || a > max || b < 0 || b > max {
		return -1
	}
	diff := max / 2
	if c <= diff {
		return c + diff
	} else {
		return c - diff
	}
}

func main() {
	var n int32
	fmt.Scanf("%v\n", &n)
	var a, b, c int32
	for i := int32(0); i < n; i++ {
		fmt.Scanf("%v %v %v\n", &a, &b, &c)
		fmt.Println(fun(a, b, c))
	}
}

package main

import (
	"fmt"
	"math"

)

func maxOfThree(a,b,c int) int{
	max := 0
	var g []int = []int{a,b,c}

	for _, i:=range g {
		if i > max {
			max = i
		}
	}

	return max
}

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

	for i:= 0; i<t; i++ {
		fmt.Scanln(&a,&b,&c)
		var val int = int(math.Abs(float64(a - b)))
		if 2 * val < maxOfThree(a,b,c){
			fmt.Println(-1)
			continue
		}
		if c <= val{
			fmt.Println(c + val)
		}else{
			fmt.Println(c - val)
		}

	}
}

package main

import (

	"fmt"
	"math"

)

func maxOfThree(a,b,c int) int{
	max := 0
	var g []int = []int{a,b,c}

	for _, i:=range g {
		if i > max {
			max = i
		}
	}

	return max
}

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

	for i:= 0; i<t; i++ {
		fmt.Scanln(&a,&b,&c)
		if 2 * int(math.Abs(float64(a - b))) < maxOfThree(a,b,c){
			sol = -1

		}else if 2 * int(math.Abs(float64(a - b))) >= c{

			sol = int(math.Abs(float64(a - b))) + c
			if sol > 2 * int(math.Abs(float64(a - b))){
				sol -= 2 * int(math.Abs(float64(a - b)))
			}

			if sol == a ||  sol == b || sol == c {
				sol = -1
			}

		}else{

			sol = -1
		}
		fmt.Println(sol)
	}
}

package main

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

func main() {
	var (
		t int
		a int
		b int
		c int
	)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	t, _ = strconv.Atoi(scanner.Text())
	for i := 0; i < t; i++ {
		scanner.Scan()
		sl := strings.Split(scanner.Text(), " ")
		a, _ = strconv.Atoi(sl[0])
		b, _ = strconv.Atoi(sl[1])
		c, _ = strconv.Atoi(sl[2])
		d := 0
		if a > b {
			d = a - b
		} else {
			d = b - a
		}
		if a > d*2 || b > d*2 || c > d*2 {
			fmt.Println(-1)
		} else {
			if c > d {
				fmt.Println(c - d)
			} else {
				fmt.Println(c + d)
			}
		}
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	test := parseInt(getString(reader))
	for ; test > 0; test-- {
		abc := getIntln(reader)
		a, b, c := abc[0], abc[1], abc[2]
		var n int
		if a > b {
			n = 2 * (a - b)
		} else {
			n = 2 * (b - a)
		}
		if n < a || n < b {
			writer.WriteString("-1\n")
		} else if c <= n/2 {
			writer.WriteString(fmt.Sprintln(c + n/2))
		} else if c <= n {
			writer.WriteString(fmt.Sprintln(c - n/2))
		} else {
			writer.WriteString("-1\n")
		}
	}
	writer.Flush()
}

func getString(in *bufio.Reader) string {
	res, _ := in.ReadString('\n')
	res = strings.ReplaceAll(res, "\n", "")
	res = strings.ReplaceAll(res, "\r", "")
	res = strings.TrimSpace(res)
	return res
}

func parseInt(str string) int {
	var res int
	size := len(str)
	for i := 0; i < size; i++ {
		digit := int(str[i] - '0')
		for j := (i + 1); j < size; j++ {
			digit = digit<<3 + digit<<1
		}
		res += digit
	}
	return res
}

func getIntln(in *bufio.Reader) []int {
	b := strings.Split(getString(in), " ")
	res := make([]int, len(b))
	for k, v := range b {
		res[k] = parseInt(v)
	}
	return res
}

package main

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

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		a, b, c := 0, 0, 0
		fmt.Fscan(f, &a, &b, &c)
		del := Abs(a - b)
		if a > del*2 || b > del*2 || c > del*2 || c-del == a || c-del == b || c+del == a || c+del == b {
			fmt.Fprintln(w, -1)
			continue
		}
		if c < 1+del {
			fmt.Fprintln(w, c+del)
		} else {
			fmt.Fprintln(w, c-del)
		}
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func abs(n int) int {
	if n < 0 {
		return n * -1
	}
	return n
}

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

		size := abs(b-a) * 2

		cf := (size / 2) + c
		cb := c - (size / 2)

		pos := -1
		if cf <= size && (cf != a && cf != b) {
			pos = cf
		}

		if cb > 0 && (cb != a && cb != b) {
			pos = cb
		}

		if a > size || b > size || c > size {
			pos = -1
		}

		if pos > 0 {
			fmt.Fprintln(out, pos)
		} else {
			fmt.Fprintln(out, -1)
		}
	}
}

package main

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

var (
	reader     = bufio.NewReader(os.Stdin)
	t, a, b, c int
)

func solve(a, b, c int) int {
	if b < a {
		a, b = b, a
	}
	half := b - a
	if c > 2*half || b > 2*half {
		return -1
	}
	if c > half {
		return c - half
	}
	return c + half
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &a, &b, &c)
		fmt.Println(solve(a, b, c))
	}
}

package main

import (
	"fmt"
)

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

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

	a, b = sort(a, b)
	m := b - a
	if a > m || a+m != b || m == 1 || c > 2*m {
		fmt.Println(-1)
		return
	}
	if c <= m {
		fmt.Println(c + m)
	} else {
		fmt.Println(c - m)
	}
}

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

	for ; test > 0; test-- {
		b()
	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1560B
Date: 16/09/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1560/B
Problem: CF1560B
**/
func (in *CF1560B) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		a, b, c := in.NextInt64(), in.NextInt64(), in.NextInt64()

		max := Max(a, b) - Min(a, b)

		ans := int64(-1)

		if c <= max*2 && max > 1 && a <= max*2 && b <= max*2 {
			if c+max <= max*2 {
				ans = c + max
			} else if c-max >= 1 {
				ans = c - max
			}
		}
		fmt.Println(ans)
	}
}
func Min(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

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

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

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

package main

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

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

	var T, a, b, c int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b, &c)
		m := abs(a - b)
		n := m * 2
		if a > n || b > n || c > n {
			Fprintln(out, -1)
		} else {
			Fprintln(out, (c-1+m)%n+1)
		}
	}
}

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

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

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 int
	for Fscan(in, &t); t > 0; t-- {
		var a, b, c int
		Fscan(in, &a, &b, &c)

		total := abs(a-b) << 1
		if c > total || a > total || b > total {
			Fprintln(out, -1)
			continue
		}
		Fprintln(out, (c + total/2 - 1) % total + 1 )
	}
}

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

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

package main

import "fmt"

func main() {
	var a,b,c,T int
	fmt.Scan(&T)
	for i:=0;i<T;i++ {
		fmt.Scan(&a, &b, &c)
		dis := a-b
		if dis <0{
			dis = b-a
		}
		if false {

		} else {
			total := 2 * dis
			if c <1 || c> total || a<1 ||a>total ||
			 b<1 || b>total {
				fmt.Println(-1)
			} else {
				ans := c + dis
				if ans > total {
					ans -= total
				}
				fmt.Println(ans)
			}
		}

	}
}

package main

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

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

func main() {
	var test int
	fmt.Fscan(in, &test)
	for i := 0; i < test; i++ {
		solve()
	}

}

func solve() {
	var a, b, c int64
	fmt.Fscan(in, &a)
	fmt.Fscan(in, &b)
	fmt.Fscan(in, &c)
	var diffToOne int64
	var oneisAt int64
	var maxTime int64
	if a > b {
		diffToOne = b - 1
		oneisAt = a - diffToOne
		if oneisAt > a || oneisAt <= b {
			fmt.Println(-1)
			return
		}
	} else {
		diffToOne = a - 1
		oneisAt = b - diffToOne
		if oneisAt > b || oneisAt <= a {
			fmt.Println(-1)
			return
		}
	}
	maxTime = 2*oneisAt - 2
	if c > maxTime {
		fmt.Println(-1)
		return
	}
	var ans int64
	if c >= oneisAt {
		c = c - oneisAt + 1
		ans = oneisAt + c - 1
		ans -= oneisAt
		ans += 1
	} else {
		ans = oneisAt + c - 1
	}
	fmt.Println(ans)

}

func printArray(arr []int) {
	for i := 1; i < len(arr); i++ {
		fmt.Print(arr[i], " ")
	}
	fmt.Println()
}

type runeSort []rune

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

package main

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

func Abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

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

	var t int16
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		var a, b, c int64
		fmt.Fscan(in, &a, &b, &c)
		half_n := Abs(a - b)
		if a > half_n*2 || b > half_n*2 || c > half_n*2 {
			fmt.Fprintln(out, -1)
		} else {
			if c-half_n > 0 {
				fmt.Fprintln(out, c-half_n)
			} else {
				fmt.Fprintln(out, c+half_n)
			}
		}
	}
}

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

package main

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

var iost *Iost

type Iost struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func NewIost(fp io.Reader, wfp io.Writer) *Iost {
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &Iost{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

func (i *Iost) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}

func (i *Iost) Atoi(s string) int                 { x, _ := strconv.Atoi(s); return x }
func (i *Iost) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *Iost) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *Iost) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *Iost) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *Iost) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *Iost) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *Iost) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *Iost) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                               { return os.Getenv("I") == "IronMan" }

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("END_GAME"))
	}
	iost = NewIost(fp, wfp)
	defer func() {
		if isLocal() {
			iost.Println(recover())
		}
		iost.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		iost.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	t := iost.GetNextInt()
	for t > 0 {
		t--
		func() {
			a := iost.GetNextInt()
			b := iost.GetNextInt()
			c := iost.GetNextInt()
			if a > b {
				a, b = b, a
			}
			ret := -1
			if c <= (b-a)*2 && b <= (b-a)*2 {
				if c <= (b - a) {
					ret = c + (b - a)
				} else {
					ret = c - (b - a)
				}
			}
			iost.Println(ret)
		}()
	}
}

package main

import (
	"fmt"
)

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

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

func main() {
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		a--
		b--
		c--
		diff := Abs(a - b)
		if diff > 0 && (c >= 2*diff || a >= 2*diff || b >= 2*diff) {
			fmt.Println("-1")
			continue
		}
		if diff == 0 {
			mx := Max(a, c)
			mx += mx % 2
			diff = mx / 2
		}
		fmt.Println((c+diff)%(2*diff) + 1)
	}
}

package main

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

func main() {
	var T, a, b, c int
	in := bufio.NewReader(os.Stdin)
	Fscan(in, &T)
	for t := 0; t < T; t++ {
		Fscan(in, &a, &b, &c)
		d, ok := D(a, b, c)
		if !ok {
			Println(-1)
			continue
		}
		Println(Det(c-1, d) + 1)
	}
}

func D(a, b, c int) (int, bool) {
	d := dist(a, b)
	s := 2 * d
	i, j, k := a-1, b-1, c-1
	if i >= s || j >= s || k >= s {
		return -1, false
	}
	if Det(i, d) != j {
		return -1, false
	}

	return d, true
}

func Det(a, d int) int {
	return (a + d) % (2 * d)
}

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

package main

import (
	"fmt"
  // "log"
)

func solve(a,b,c int) int{
  // pre operation.
  if a > b{
    a,b = b,a
  }

  // validate the input
  diff := b - a
  total := diff * 2
  // log.Println(total)
  if total < b ||  total < a || total < c || total % 2 != 0{
    return -1
  }
  // calculate the circle dimensions
  var ret int
  if c > diff {
    ret = c - diff
  }else{
    ret = c + diff
  }

  return ret
}
func main() {
  // how to find a correlation between A, B, and C.

  var testcases int
  fmt.Scanf("%d\n", &testcases)

  for ; testcases > 0; testcases-- {
	  var a,b,c int
	  fmt.Scanf("%d %d %d\n", &a,&b,&c)
    fmt.Println(solve(a,b,c))
  }
}

package main

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

// 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 MINN(x, y int) int {
	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 MAXX(x, y int) int {
	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 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		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 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
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	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 a, b, c int
		fmt.Fscan(input, &a, &b, &c)

		// ARR := make([]int, n)
		// for i := 0; i < n; i++ {
		// 	fmt.Fscan(input, &ARR[i])

		// }
		m := MODULE(a, b)
		length := m * 2

		if a > length || b > length || c > length {
			fmt.Println(-1)
		} else {
			var q int
			if c > m {
				q = c - m
			} else {
				q = c + m
			}
			fmt.Println(q)
		}

	}

}

package main

import "fmt"

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

    for i := 0; i < testCases; i++ {
        var (
            a int
            b int
            c int
        )
        fmt.Scanf("%d %d %d\n", &a, &b, &c)
        if a == b {
            fmt.Println(-1)
            continue
        }
        diff := a - b
        if diff <= 0 {
            diff = b - a
        }
        n := 2*diff
        if c > n {
            fmt.Println(-1)
            continue
        }
        if a > n {
            fmt.Println(-1)
            continue
        }
        if b > n {
            fmt.Println(-1)
            continue
        }
        cPair := c - diff
        if cPair <= 0 {
            cPair = c + diff
        }
        if cPair > n {
            fmt.Println(-1)
            continue
        }
        if cPair == a || cPair == b {
            fmt.Println(-1)
            continue
        }
        fmt.Println(cPair)

    }
}

package main

import "fmt"

func main() {
	var n int
	var number int
	fmt.Scan(&n)
	var input = make([][]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&number)
		input[i] = make([]int, 3)
		input[i][0] = number
		fmt.Scan(&number)
		input[i][1] = number
		fmt.Scan(&number)
		input[i][2] = number
	}
	for i := 0; i < n; i++ {
		pair := tru(input[i][0], input[i][1])
		if pair*2 < input[i][0] || pair*2 < input[i][1] || pair*2 < input[i][2] {
			fmt.Println(-1)
		} else if input[i][2] > pair {
			fmt.Println(input[i][2] - pair)
		} else {
			fmt.Println(input[i][2] + pair)
		}
	}
}

func tru(a, b int) int {
	if a > b {
		return a - b
	} else {
		return b - a
	}
}

package main

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

func main() {
	in := NewIn()
	out := NewOut()
	defer out.flush()

	run(in, out)
}

/* --- Solution B --- */
func solve(in *In, out *Out) {
	a := in.nextInt()
	b := in.nextInt()
	c := in.nextInt()

	var k int
	if a > b {
		k = a - b
	} else {
		k = b - a
	}

	var d int
	if 2*k < a || 2*k < b || 2*k < c {
		d = -1
	} else if c-k > 0 {
		d = c - k
	} else if c+k > 0 {
		d = c + k
	} else {
		d = -1
	}

	out.println(d)
}

func run(in *In, out *Out) {
	cases(in, out)
	// solve(in, out)
}

func cases(in *In, out *Out) {
	t := in.nextInt()
	for ; t > 0; t-- {
		solve(in, out)
	}
}

/* --- I/O --- */
const BUF_MAX_CAP int = 1e7

type In struct {
	scanner *bufio.Scanner
}

func NewIn() *In {
	scn := bufio.NewScanner(os.Stdin)

	buf := make([]byte, BUF_MAX_CAP)
	scn.Buffer(buf, BUF_MAX_CAP)
	scn.Split(bufio.ScanWords)

	return &In{scn}
}

func (in *In) nextInt() int {
	in.scanner.Scan()
	i, _ := strconv.Atoi(in.scanner.Text())
	return i
}

func (in *In) nextLong() int64 {
	in.scanner.Scan()
	i, _ := strconv.ParseInt(in.scanner.Text(), 10, 64)
	return i
}

func (in *In) nextDouble() float64 {
	in.scanner.Scan()
	i, _ := strconv.ParseFloat(in.scanner.Text(), 64)
	return i
}

func (in *In) next() string {
	in.scanner.Scan()
	return in.scanner.Text()
}

type Out struct {
	writer *bufio.Writer
}

func NewOut() *Out {
	out := Out{bufio.NewWriter(os.Stdout)}
	return &out
}

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

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

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

func (out *Out) flush() {
	out.writer.Flush()
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for c:=1;c<=t;c++{
		var a, b, c int
		fmt.Fscan(in,&a,&b,&c)
		var numa,numb int
		if a<b{
			numa=a
			numb=b
		}else{
			numa = b
			numb = a
		}
		ans:=0
	//	fmt.Println(numb+1-numa,numa)
		if numb+1-numa<=numa {
			ans = -1
		}
		mid := numb-numa+1
		if c > mid+(mid-2){
			ans = -1
		}else if c<mid && ans!=-1{
			ans = mid + (c-1)
		}else if c== mid && ans !=-1{
			ans = 1
		}else if c>mid && ans!=-1{
			ans = 1 + (c-mid)
		}
		fmt.Fprintln(out,ans)
	}
}

package main

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

func main() {
	defer wr.Flush()
	t := scanInt()
	for i := 0; i < t; i++ {
		fmt.Fprintln(wr, solve())
	}
}

func solve() int {
	a, b, c := scanInt(), scanInt(), scanInt()
	if a > b {
		a, b = b, a
	}

	// a < b
	n := (b - a) * 2
	if a > n || b > n || c > n {
		return -1
	} else if a <= n/2 && b <= n/2 {
		return -1
	} else if a > n/2 && b > n/2 {
		return -1
	}

	if c <= n/2 {
		return c + n/2
	}
	return c - n/2
}

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

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

package main
//this code is written by likely
//do not distribute it freely

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

func main(){
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t,a,b,c,i,n int32
	fmt.Fscan(in,&t)
	for i=1;i<=t;i++{
		fmt.Fscan(in,&a);fmt.Fscan(in,&b);fmt.Fscan(in,&c)
		if a==b {
			fmt.Fprintln(out, -1)
			continue
		}else{
			if a>b{
				n=(a-b)*2
			}else{
				n=(b-a)*2
			}
			if a>n{
				fmt.Fprintln(out,-1)
				continue
			}
			if(b>n){
				fmt.Fprintln(out,-1)
				continue
			}
			if c<=n {
				if c > n/2 {
					fmt.Fprintln(out,c-n/2)
				} else {
					fmt.Fprintln(out,c+n/2)
				}
			}else{
				fmt.Fprintln(out,-1)
			}
		}
	}
}

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

                            Online Go Lang Compiler.
                Code, Compile, Run and Debug Go Lang program online.
Write your code in this editor and press "Run" button to execute it.

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

package main

import "fmt"
import "bufio"
import "os"
//import "sort"

func main() {
    in := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscan(in, &n)
    for ; n > 0; n--{
        var a, b, c int
        fmt.Fscan(in, &a, &b, &c)
        if (b > a) {
            a,b = b,a
        }
        var sz = (a - b) * 2

        if (c > sz || a > sz || b > sz) {
            fmt.Println(-1)
        } else {
            sz /= 2
            if (c > sz) {
                fmt.Println(c - sz)
            } else {
                fmt.Println(c + sz)
            }
        }
    }

}

package main

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

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int
	fmt.Fscan(r, &t)

	for i := 0; i < t; i++ {
		var a, b, c int
		fmt.Fscan(r, &a, &b, &c)

		solve(a, b, c)
	}
}

func solve(a, b , c int) {
	diff := abs(a - b)

	all := 2 * diff

	if c > all || a > all || b > all{
		fmt.Println(-1)
		return
	}

	if c <= diff {
		fmt.Println(c + diff)
	} else {
		fmt.Println(c - diff)
	}

}

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

package main

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

func main() {
	r := bufio.NewReaderSize(os.Stdin, 1024*1024)

	var T, a, b, c int

	fmt.Fscanf(r, "%d\n", &T)

	for t := 0; t < T; t++ {
		fmt.Fscanf(r, "%d %d %d\n", &a, &b, &c)

		if a > b {
			a, b = b, a
		}
		d := b - a

		x := 1
		y := 2 * d

		if a >= x && a <= y && b >= x && b <= y && c >= x && c <= y {
			if c >= 1+d {
				fmt.Println(c - d)
			} else {
				fmt.Println(c + d)
			}
		} else {
			fmt.Println(-1)
		}
	}
}

package main

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

func toInt(buf []byte) (n int) {
    for _, v := range buf {
        n = n*10 + int(v-'0')
    }
    return
}

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

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

func main() {
	var a, b, c int
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
  var t int
  scanner.Scan()
  t = toInt(scanner.Bytes())
  for g := 0; g < t; g++{
    scanner.Scan()
    a = toInt(scanner.Bytes())
    scanner.Scan()
    b = toInt(scanner.Bytes())
    scanner.Scan()
    c = toInt(scanner.Bytes())
    sz := (max(a, b) - min(a, b)) * 2
    if (a <= sz) && (b <= sz) && (c <= sz){
      fmt.Println((c + (sz / 2) - 1) % sz + 1)
    }else{
      fmt.Println(-1)
    }
  }
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.ParseInt(s, 10, 32); return int(x) }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                              { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &iop{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

var rw *iop

func main() {
	rw=newIop()
	defer func() {
		if isLocal() {
			rw.Println("Recovering ", recover())
		}
		rw.Writer.Flush()
	}()
	solve()
	for i := 0; isLocal() && i < 100; i++ {
		rw.Println("-----------------------------------")
		solve()
	}
}

func solve() {
	test := rw.GetNextInt()
	for test > 0 {
		test--
		func(){
				a := rw.GetNextInt()
				b := rw.GetNextInt()
				c := rw.GetNextInt()

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

			if c > (b - a)*2 || a > (b - a)*2 || b > (b - a)*2 {
				fmt.Println(-1)
			} else {
				if c > (b - a) {
					c -= b - a
				} else {
					c += b - a
				}
				rw.Println(c)
			}
		}()
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

type iop struct {
	Scanner *bufio.Scanner
	Writer  *bufio.Writer
}

func (i *iop) Text() string {
	if !i.Scanner.Scan() {
		panic("scan failed")
	}
	return i.Scanner.Text()
}
func (i *iop) Atoi(s string) int                 { x, _ := strconv.ParseInt(s, 10, 32); return int(x) }
func (i *iop) GetNextInt() int                   { return i.Atoi(i.Text()) }
func (i *iop) Atoi64(s string) int64             { x, _ := strconv.ParseInt(s, 10, 64); return x }
func (i *iop) GetNextInt64() int64               { return i.Atoi64(i.Text()) }
func (i *iop) Atof64(s string) float64           { x, _ := strconv.ParseFloat(s, 64); return x }
func (i *iop) GetNextFloat64() float64           { return i.Atof64(i.Text()) }
func (i *iop) Print(x ...interface{})            { fmt.Fprint(i.Writer, x...) }
func (i *iop) Printf(s string, x ...interface{}) { fmt.Fprintf(i.Writer, s, x...) }
func (i *iop) Println(x ...interface{})          { fmt.Fprintln(i.Writer, x...) }
func isLocal() bool                              { return os.Getenv("inLocalEnv") == "indeed" }
func newIop() *iop {
	fp := os.Stdin
	wfp := os.Stdout
	if isLocal() {
		fp, _ = os.Open(os.Getenv("input"))
	}
	const BufSize = 1000000
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	return &iop{Scanner: scanner, Writer: bufio.NewWriter(wfp)}
}

var rw *iop = newIop()

func main() {
	defer func() {
		if isLocal() {
			rw.Println("Recovering ", recover())
		}
		rw.Writer.Flush()
	}()
	solve()
}

func solve() {
	test := rw.GetNextInt()
	for test > 0 {
		test--
		func(){
				a := rw.GetNextInt()
				b := rw.GetNextInt()
				c := rw.GetNextInt()

			if a > b {
				a, b = b, a
			}
			var maxNumber int
			maxNumber = b - a
			if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
				fmt.Println(-1)

			} else {
				if c > maxNumber {
					c -= maxNumber
				} else {
					c += maxNumber
				}
				rw.Println(c)
			}
		}()
	}
}

package main

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

func checkErr(e error) {
	if e != nil {
		log.Fatal("Error occurred ", e)
	}
}

const BufSize = 1000000

//type iop struct {
//	scanner *bufio.Scanner
//	writer  *bufio.Writer
//}
//
//func newIop(fp *io.Reader,wfp *io.Writer) *iop   {
//	const BufSize = 1000000
//	scanner:=bufio.NewScanner(fp)
//	scanner.Buffer(make([]byte,BufSize),BufSize)
//}

//func (i iop) newIop()  {
//
//}
func main() {

	fp := os.Stdin
	scanner := bufio.NewScanner(fp)
	scanner.Buffer(make([]byte, BufSize), BufSize)
	scanner.Split(bufio.ScanLines)
		if !scanner.Scan() {
			panic("NOOOOOO!")
			//fmt.Println(scanner.Text())
		}
	test ,_:= strconv.Atoi(scanner.Text())
	fmt.Println(test)
	var (
		a, b, c, maxNumber int
	)
	for idx := 0; idx < test; idx++ {
		if !scanner.Scan() {
			fmt.Println(scanner.Text())
			break
		}
		x := scanner.Text()
		INTS := strings.Split(x, " ")
		a, _ = strconv.Atoi(INTS[0])
		b, _ = strconv.Atoi(INTS[1])
		c, _ = strconv.Atoi(INTS[2])
		if a > b {
			a, b = b, a
		}
		maxNumber = b - a
		if c > maxNumber*2 || a > maxNumber*2 || b > maxNumber*2 {
			fmt.Println(-1)

		} else {
			if c > maxNumber {
				c -= maxNumber
			} else {
				c += maxNumber
			}
			fmt.Println(c)
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		dd := abs(a - b)
		if a > 2*dd || b > 2*dd || c > 2*dd {
			fmt.Println("-1")
		} else {
			if c <= dd {
				c += dd
			} else {
				c -= dd
			}

		}
		fmt.Println(c)
	}
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		dd := abs(a - b)
		if a > 2*dd || b > 2*dd || c > 2*dd {
			fmt.Println("-1")
		} else {
			if c <= dd {
				c += n
			} else {
				c -= n
			}

		}
		fmt.Println(c)
	}
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(dd(a, b, c))
	}
}

func dd(a, b, c int) int {
	d := abs(a - b)
	if d*2 < a || d*2 < b || d*2 < c {
		return -1
	}
	if c > d {
		return d*2 - c - 1
	} else {
		return d + c
	}

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

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(dd(a, b, c))
	}
}

func dd(a, b, c int) int {
	d := abs(a - b)
	if d*2 < a || d*2 < b || d*2 < c {
		return -1
	}
	if c > d {
		return d*2 - c - 1
	} else if c == d {
		return 2 * c
	} else {
		return d + c
	}

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

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(dd(a, b, c))
	}
}

func dd(a, b, c int) int {
	if abs(a-b)*2 < a || abs(a-b)*2 < b || abs(a-b)*2 < c {
		return -1
	}
	if c > abs(a-b) {
		return abs(a-b)*2 - c - 1
	} else if c == abs(a-b) {
		return 2 * c
	} else {
		return abs(a-b) + c
	}

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

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(dd(a, b, c))
	}
}

func dd(a, b, c int) int {
	if abs(a-b)*2 < a || abs(a-b)*2 < b || abs(a-b)*2 < c {
		return -1
	}
	if c < abs(a-b) {
		return c + abs(a-b)
	} else {
		return abs(a-b)*2 - c + 1
	}
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(dd(a, b, c))
	}
}

func dd(a, b, c int) int {
	if abs(a-b)*2 < a || abs(a-b)*2 < b || abs(a-b)*2 < c {
		return -1
	}
	if c < abs(a-b) {
		return c + abs(a-b)
	} else {
		return c - abs(a-b)
	}
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Scan(&a, &b, &c)
		fmt.Println(dd(a, b, c))
	}
}

func dd(a, b, c int) int {
	if abs(a-b) < a || abs(a-b) < b || abs(a-b) < c {
		return -1
	}
	if c < abs(a-b) {
		return c + abs(a-b)
	} else {
		return c - abs(a-b)
	}
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var a, b, c int
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		fmt.Fscan(in, &c)
		a--; b--; c--
		if a > b {
		    a, b = b, a
		}
		tmp := 2 * (b - a)
		var ans int
		if b > tmp || c > tmp || a * 2 >= b {
		    ans = -1
		} else {
		    ans = (c + b - a) % tmp + 1
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var a, b, c int
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		fmt.Fscan(in, &c)
		a--; b--; c--
		if a > b {
		    a, b = b, a
		}
		tmp := 2 * (b - a)
		var ans int
		if b > tmp || c > tmp {
		    ans = -1
		} else {
		    ans = (c + b - a) % tmp + 1
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var a int
		var b int
		var c int
		fmt.Fscan(in, &a)
		fmt.Fscan(in, &b)
		fmt.Fscan(in, &c)
		if a > b {
		    a, b = b, a
		}
		tmp := 2 * (b - a)
		var ans int
		if b > tmp || c > tmp {
		    ans = -1
		} else {
		    ans = (c + b - a) % tmp
		}
		fmt.Fprintln(out, ans)
	}
}

package main

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

func main() {
	var t int64
	r := bufio.NewReader(os.Stdin)
	fmt.Fscan(r, &t)
	for i := int64(0); i < t; i++ {
		var a, b, c int64
		fmt.Fscan(r, &a, &b, &c)
		maxNum,minNum := abs(a, b)
		abs:=maxNum-minNum
		if 2*abs<maxNum&&2*abs<c{
			fmt.Println(-1)
		}else {
			if c>abs{
				fmt.Println(c-abs)
			}else {
				fmt.Println(c+abs)
			}
		}
	}
}

func abs(a int64, b int64) (int64, int64) {
	var max, min int64
	if a >= b {
		max = a
		min = b
	} else {
		max = b
		min = a

	}

	return max, min
}

package main

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

func main() {
	var t int64
	r := bufio.NewReader(os.Stdin)
	fmt.Fscan(r, &t)
	for i := int64(0); i < t; i++ {
		var a, b, c int64
		fmt.Fscan(r, &a, &b, &c)
		maxNum,minNum := abs(a, b)
		abs:=maxNum-minNum
		if 2*abs<maxNum&&2*abs<c{
			fmt.Println(-1)
		}else {
			if c>=abs{
				fmt.Println(c-abs)
			}else {
				fmt.Println(c+abs)
			}
		}
	}
}

func abs(a int64, b int64) (int64, int64) {
	var max, min int64
	if a >= b {
		max = a
		min = b
	} else {
		max = b
		min = a

	}

	return max, min
}

package main

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

func main() {
	var t int64
	r := bufio.NewReader(os.Stdin)
	w:=bufio.NewWriter(os.Stdout)
	fmt.Fscan(r, &t)
	for i := int64(0); i < t; i++ {
		var a, b, c int64
		fmt.Fscan(r, &a, &b, &c)
		maxNum,minNum := abs(a, b)
		abs:=maxNum-minNum
		if 2*abs<maxNum&&2*abs<c{
			fmt.Fprintln(w,-1)
		}else {
			if c>=abs{
				fmt.Fprintln(w,c+abs)
			}else {
				fmt.Fprintln(w,c-abs)
			}
		}
	}
}

func abs(a int64, b int64) (int64, int64) {
	var max, min int64
	if a >= b {
		max = a
		min = b
	} else {
		max = b
		min = a

	}

	return max, min
}

package main

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

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

	scan := func(a ...interface{}) (int, error)             { return fmt.Fscan(ins, a...) }
	printf := func(s string, a ...interface{}) (int, error) { return fmt.Fprintf(out, s, a...) }
	var n int
	scan(&n)

	for i:=0; i<n;i++{
		var a,b,c int
		scan(&a, &b, &c)
		res := fn(a, b, c)

		printf("%d\n",res)
	}

}
func fn(a ,b, c int) int{
	minlen := a
	if b>a {
		minlen = b
	}
	if c>a && c>b{
		minlen=c
	}
	if minlen %2 != 0{
		minlen++
	}
	maxlen := minlen+4

	for minlen<maxlen{
		cgetted := getop(c, minlen)
		if getop(a, minlen) == b && cgetted != a && cgetted != b{
			return cgetted
		}
		minlen += 2
	}
	return -1

}

func getop(a, mle int) int{
	res := a + ((mle-2)/2) + 1
	if res > mle{
		res = res - mle
	}
	return res
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t, a, b, c int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &a, &b, &c)
		w1 := do(a, b, c)
		fmt.Fprint(w, w1)
		fmt.Fprintln(w)
	}
}

func do(a, b, c int) int {
	n := a - b
	if n < 0 {
		n = -n
	}
	if a > n+n || b > n+n {
		return -1
	}
	if v := n + c; 1 <= v && v <= n+n {
		return v
	}
	if v := -n + c; 1 <= v && v <= n+n {
		return v
	}
	return -1
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t, a, b, c int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &a, &b, &c)
		w1 := do(a, b, c)
		fmt.Fprint(w, w1)
		fmt.Fprintln(w)
	}
}

func do(a, b, c int) int {
	n := a - b
	if n < 0 {
		n = -n
	}
	if a >= n+n || b >= n+n {
		return -1
	}
	if v := n + c; 1 <= v && v <= n+n {
		return v
	}
	if v := -n + c; 1 <= v && v <= n+n {
		return v
	}
	return -1
}

package main
import(
    "fmt"
)
func main(){
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var a,b,c int
		fmt.Scan(&a,&b,&c)
		if (abs(a-b)*2) < c || (abs(a-b)*2) < b || (abs(a-b)*2) < a {
			fmt.Println(-1)
		}else{
			if abs((abs(a-b)*2)-(c+abs(a-b))) == 0 {
				fmt.Println(abs(a-b)*2)
			}else {
				fmt.Println(abs((abs(a-b)*2)-(c+abs(a-b))))
			}
		}
	}
}

func abs(x int) int {
	var result int
	if x > 0 {
		result = x
	} else {
		if x < 0 {
			result = x*-1
		}
	}
	return result
}

package main;

import (
    "fmt"
)

func main() {
    fmt.Println("hi")
}


package main
import (
	"fmt"
)
func main() {
	var n,m,t int
	s,a:=0,0
	fmt.Scan(&n,&m)
	for i:=0; i<n;i++ {
		fmt.Scan(&t)
		s += t
	}
	if s<0 {
		s= s*(-1)
	}
	if s%m==0 {
		a = s/m
	} else {a = s/m+1}
	fmt.Println(a)
}

package main

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

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

//Wrong
func main() {
	// defer func(start time.Time) {
	// 	fmt.Println(time.Since(start))
	// }(time.Now())

	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, x := nextInt(), nextInt()
	sum := 0
	count := 0

	for i:=0; i<n; i++ {
		sum += nextInt()
	}

	count += abs(sum/x)

	if sum%x!=0 {
		count++
	}

	println(count)
}

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

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

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

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

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

package main

import "fmt"

func main() {
    var n,x,a int
    fmt.Scan(&n,&x)
    total := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        total += a
    }
    if total < 0 { total = -total }
    if total == 0 {
        fmt.Println(0)
    } else if total <= x {
        fmt.Println(1)
    } else if total%x == 0 {
        fmt.Println(total/x)
    } else {
        fmt.Println((total/x) + 1)
    }
}

package main
import (
	"fmt"
)
func main() {
	var n,m,t int // membuat variabel n,m,dan t bertipe int
	s,a:=0,0   // membuat variabel s dan a yang kemudian diisi masing-masing nilai 0
	fmt.Scan(&n,&m)  // mengambil input
	for i:=0; i<n;i++ {  // looping sebanyak n kali
		fmt.Scan(&t)  // mengambil input ke 2
		s += t    // s ditambah dengan t
	}
	if s<0 {
		s= s*(-1)    // jika s kurang dari 0 maka s dikali dengan -1
	}
	if s%m==0 {
		a = s/m    // jika s dimodulo m sama dengan 0 maka a sama dengan s dibagi m
	} else {a = s/m+1}  // lainnya a sama dengan s dibagi m ditambah 1
	fmt.Println(a)   // mencetak output
}

/*********************************************************************************
*     File Name           :     A.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-10 23:29]
*     Last Modified       :     [2014-03-10 23:37]
*     Description         :
**********************************************************************************/

package main

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

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

    n, x := scanner.NextInt(), scanner.NextInt()
    sum := 0
    for i := 0; i < n; i++ {
        y := scanner.NextInt()
        sum += y
    }
    if sum < 0 {
        sum = -sum
    }
    ans := sum / x
    if sum%x != 0 {
        ans++
    }
    fmt.Println(ans)
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var n, x, tmp int

	fmt.Scan(&n, &x)

	sum := 0
	for i:=0; i<n; i++ {
		fmt.Scan(&tmp)
		sum += tmp
	}

	res := math.Ceil(math.Abs(float64(sum))/float64(x))

	fmt.Printf("%d", int(res))
}

package main

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

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

func main() {
    scanner.Split(bufio.ScanWords)
    n := scanner.NextInt()
    x := scanner.NextInt()
    total := 0
    for ; n > 0; n-- {
        t := scanner.NextInt()
        total += t
    }
    fmt.Printf("%d\n", (Abs(total)+x-1)/x)
}

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) Next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) NextInt() int {
    x, err := strconv.Atoi(self.Next())
    if err != nil {
        panic(err)
    }
    return x
}

func (self *Scanner) NextDouble() float64 {
    x, err := strconv.ParseFloat(self.Next(), 64)
    if err != nil {
        panic(err)
    }
    return x
}

package main

import "fmt"

func main() {
    var n,x,a int
    fmt.Scan(&n,&x)
    total := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        total += a
    }
    if total < 0 { total = -total }
    if total <= x {
        fmt.Println(1)
    } else if total%x == 0 {
        fmt.Println(total/x)
    } else {
        fmt.Println((total/x) + 1)
    }
}


package main

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

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

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

	var c int
	Fscan(in, &c)
	for ; c > 0; c-- {
		var x uint64
		var y uint64
		Fscan(in, &x, &y)
		if x > y {
			Fprintln(out, x+y)
		} else {
			k := (y - y/x*x) / 2
			Fprintln(out, y/x*x+k)
		}
	}
}

package main

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

// 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 MINN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

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

func MAXX(x, y int) int {
	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 {
	if x*y == 0 {
		return MAX(x, y)
	} else {
		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 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
	}
}

func BITAND(x, y int64) int64 {
	var ans int64
	begin := x
	sec := y
	var count int64 = 1
	for 1 == 1 {
		if (begin%2)*(sec%2) == 1 {
			ans = ans + count
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}

		} else {
			count = count * 2
			begin = int64(begin / 2)
			sec = int64(sec / 2)
			if begin*sec == 0 {
				break
			}
		}
	}
	return ans
}

func Sum(n, m int) int {
	var ans int

	if n == 1 {
		return 0
	} else {
		for i := 2; i < n; i++ {
			ans = (ans + Sum(i, m)) % m
		}
		for j := 2; j < n+1; j++ {
			ans = (ans + Sum(n/j, m)) % m
		}
		return ans
	}
}

func ChangeStringToDate(x string) (t time.Time, err error) {
	t, err = time.Parse("2006-01-02", x)
	return
}

func DiffrenceBetweenTwoDates(first, second time.Time) int64 {
	date := first
	date2 := second
	k := date.Unix() - date2.Unix()
	return k
}

func Union(a, b []int) []int {
	m := make(map[int]bool)

	for _, item := range a {
		m[item] = true
	}

	for _, item := range b {
		if _, ok := m[item]; !ok {
			a = append(a, item)
		}
	}
	return a
}

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

func DIVI(x []int) string {
	if len(x) == 1 {
		if x[0]%2 == 0 {
			return "NO"
		} else {
			return "YES"

		}
	} else {
		q := len(x)
		if DIVI(x[:q-1]) == "YES" {
			b := 0
			for j := 2; j < q+2; j++ {
				if x[q-1]%j != 0 {
					b = 1
					break
				}
			}
			if b == 1 {
				return "YES"
			} else {
				return "NO"

			}
		} else {
			return "NO"
		}
	}
}

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {

		var x, y int64
		fmt.Fscan(input, &x, &y)

		if x > y {
			fmt.Println(x + y)
		}
		if x == y {
			fmt.Println(x)
		}
		if x < y {
			remain := (y % x) / 2
			fmt.Println(y - remain)

		}

	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1603B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var T, x, y int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x, &y)
		if x > y {
			Fprintln(out, x+y)
		} else {
			Fprintln(out, y-y%x/2)
		}
	}
}

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

package main

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

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

	var T, x, y int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x, &y)
		if x > y {
			Fprintln(out, x+y)
		} else {
			Fprintln(out, y-y%x/2)
		}
	}
}

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

package main

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

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

func main() {
	defer w.Flush()
	var t, x, y int64
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		fmt.Fscan(r, &x, &y)
		ans := (x + y) / 2
		ans = ans % x
		ans = y - ans
		if x > y {
			ans = x + y
		}
		fmt.Fprintln(w, ans)
	}
}

package main

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

func CF1603B(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var T, x, y int64
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &x, &y)
		if x > y {
			Fprintln(out, x+y)
		} else {
			Fprintln(out, y-y%x/2)
		}
	}
}

func main() { CF1603B(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++ {
		Д()
	}
}

func Д() {
	var x, y int64
	scan(&x, &y)
	var ans int64
	if x > y {
		ans = x + y
	} else if x == y {
		ans = x
	} else {
		ans = (y/x)*x + (y%x)/2
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

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

	t := readInt(reader)

	for t > 0 {
		x, y := readTwoInt64(reader)
		if x > y {
			fmt.Fprintln(writer, x+y)
		} else {
			fmt.Fprintln(writer, y - y%x/2)
		}

		t--
	}

	writer.Flush()
}

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, 64)
		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]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

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 u:=1;u<=t;u++{
		var x, y int64
		fmt.Fscan(in,&x,&y)
		if x>y{
			var ans int64
			ans = x + y
			fmt.Fprintln(out,ans)
		}else{
			var ans int64
			ans = y-(y%x)/2
			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++ {
		Д()
	}
}

func Д() {
	var a, b int64
	scan(&a, &b)
	var ans int64
	if a > b {
		ans = a + b
	} else if a == b {
		ans = a
	} else {
		ans = (a + b) / 2
	}
	printf("%v\n", ans)
}

func solve() {
	var n int
	scan(&n)
	var g = make([][]int, n)
	for i := 0; i < n-1; i++ {
		var u, v int
		scan(&u, &v)
		u--
		v--
		g[u] = append(g[u], v)
		g[v] = append(g[v], u)
	}

	var (
		color     = make([]int, n)
		colorSize = [2]int{}
		bicolor   func(u, c int)
	)
	for i := range color {
		color[i] = -1
	}
	bicolor = func(u, c int) {
		if color[u] != -1 {
			return
		}
		color[u] = c
		colorSize[c]++
		for _, v := range g[u] {
			bicolor(v, c^1)
		}
	}
	bicolor(0, 0)

}

package main

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

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

	t := readInt(reader)

	for t > 0 {
		x, y := readTwoInt64(reader)
		if x > y {
			fmt.Fprintln(writer, x+y)
		} else if (x+y) % 2 == 0 {
			fmt.Fprintln(writer, (x+y)/2)
		} else {
			fmt.Fprintln(writer, (x+3*y)/4)
		}

		t--
	}

	writer.Flush()
}

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, 64)
		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]
}

func gcd(x int64, y int64) int64 {
	for y > 0 {
		x, y = y, x % y
	}

	return x
}

func lcm(x int64, y int64) int64 {
	return x*y/gcd(x,y)
}

package main

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

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

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

	var c int
	Fscan(in, &c)
	for ; c > 0; c-- {
		var x uint64
		var y uint64
		Fscan(in, &x, &y)
		if 2*x == y {
			Fprintln(out, y)
		} else if 2*y == x {
			Fprintln(out, x*y)
		} else if x == y {
			Fprintln(out, x)
		} else if x > y {
			Fprintln(out, x+y)
		} else if 2*x > y {
			Fprintln(out, (x+y)/2)
		} else {
			for i := x + 1; i <= (x+y)/2; i++ {
				if i%x == y%i {
					Fprintln(out, i)
					break
				}
			}
		}
	}
}

package main

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

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

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

	var c int
	Fscan(in, &c)
	for ; c > 0; c-- {
		var x uint64
		var y uint64
		Fscan(in, &x, &y)
		if 2*x == y {
			Fprintln(out, y)
		} else if 2*y == x {
			Fprintln(out, y)
		} else if x == y {
			Fprintln(out, x)
		} else if x > y {
			Fprintln(out, x+y)
		} else if 2*x > y {
			Fprintln(out, (x+y)/2)
		} else {
			for i := x + 1; i <= (x+y)/2; i++ {
				if i%x == y%i {
					Fprintln(out, i)
					break
				}
			}
		}
	}
}

package main

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

func main() {
	A(os.Stdin, os.Stdout)
}
//
func A(_r io.Reader, _w io.Writer) {
	in, out := bufio.NewReader(_r), bufio.NewWriter(_w)
	defer out.Flush()

	var c int
	Fscan(in, &c)
	for ; c > 0; c-- {
		var x uint64
		var y uint64
		Fscan(in, &x, &y)
		if 2*x == y {
			Fprintln(out, y)
		} else if 2*y == x {
			Fprintln(out, x)
		} else if x == y {
			Fprintln(out, x)
		} else if x > y {
			Fprintln(out, x+y)
		} else if 2*x > y {
			Fprintln(out, (x+y)/2)
		} else {
			for i := x + 1; i <= (x+y)/2; i++ {
				if i%x == y%i {
					Fprintln(out, i)
					break
				}
			}
		}
	}
}

package main

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

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

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

	var c int
	Fscan(in, &c)
	for ; c > 0; c-- {
		var x uint64
		var y uint64
		Fscan(in, &x, &y)
		if 2*x == y {
			Fprintln(out, y)
		} else if 2*y == x {
			Fprintln(out, x)
		} else if x == y {
			Fprintln(out, x)
		} else if x > y {
			Fprintln(out, x+y)
		} else if 2*x > y {
			Fprintln(out, (x+y)/2)
		} else {
			for i := x + 1; i <= (x+y)/2; i++ {
				if i%x == y%i {
					Fprintln(out, i)
					break
				}
			}
		}
	}
}

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 u:=1;u<=t;u++{
		var x, y int
		fmt.Fscan(in,&x,&y)
		if x>y{
			var ans int
			ans = x + y
			fmt.Fprintln(out,ans)
		}else{
			var ans int
			ans = (x+y)/2
			fmt.Fprintln(out,ans)
		}
	}
}

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 u:=1;u<=t;u++{
		var x, y int64
		fmt.Fscan(in,&x,&y)
		if x>y{
			var ans int64
			ans = x + y
			fmt.Fprintln(out,ans)
		}else{
			var ans int64
			ans = (x+y)/2
			fmt.Fprintln(out,ans)
		}
	}
}

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 u:=1;u<=t;u++{
		var x, y int64
		fmt.Fscan(in,&x,&y)
		if x>y{
			fmt.Fprintln(out,x+y)
		}else{
			fmt.Fprintln(out,(x+y)/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 u:=1;u<=t;u++{
		var x, y int64
		fmt.Fscan(in,&x,&y)
		if x<y{
			fmt.Fprintln(out,x+y)
		}else{
			fmt.Fprintln(out,(x+y)/2)
		}
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriterSize(os.Stdout, 1024*1024)
	defer out.Flush()

	for i := 0; i < 1e6; i++ {
		Fprintln(out, int(1e9))
	}
}

package main

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

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

	for i := 0; i < 1e6; i++ {
		Fprintln(out, 0)
	}
}

package main

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

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

func main() {
	defer w.Flush()
	var t, x, y int64
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		fmt.Fscan(r, &x, &y)
		ans := (x + y) / 2
		if x > y {
			ans = y
		}
		fmt.Fprintln(w, ans)
	}
}

package main

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

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

func main() {
	defer w.Flush()
	var t, x, y int64
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		fmt.Fscan(r, x, y)
		ans := (x + y) / 2
		if x > y {
			ans = y
		}
		fmt.Fprintln(w, ans)
	}
}