package main

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

// github.com/EndlessCheng/codeforces-go
func CF1593A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprintln(out, 0)
				} else {
					Fprintln(out, 1)
				}
			} else {
				Fprintln(out, mx-v+1)
			}
		}
	}
}

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

package main

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

func solve(a, b, c float64) int {
	return int(math.Max(0, math.Max(c, b)+1-a))
}
func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]float64, 3)
		for i := 0; i < len(arr); i++ {
			arr[i], _ = strconv.ParseFloat(sc.nextString(), 64)
		}
		fmt.Printf("%d %d %d\n", solve(arr[0], arr[1], arr[2]), solve(arr[1], arr[0], arr[2]), solve(arr[2], arr[0], arr[1]))
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

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

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

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

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

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

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

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)
		ma, mb, mc := Max(0, Max(b, c)-a+1), Max(0, Max(a, c)-b+1), Max(0, Max(a, b)-c+1)
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1593A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprintln(out, 0)
				} else {
					Fprintln(out, 1)
				}
			} else {
				Fprintln(out, mx-v+1)
			}
		}
		Fprintln(out)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1593A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprint(out, "0 ")
				} else {
					Fprint(out, "1 ")
				}
			} else {
				Fprint(out, mx-v+1, " ")
			}
		}
		Fprintln(out)
	}
}

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

package main

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

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

	var T int
	a := [3]int{}
	for Fscan(in, &T); T > 0; T-- {
		mx, c := -1, 0
		for i := range a {
			Fscan(in, &a[i])
			if a[i] > mx {
				mx, c = a[i], 1
			} else if a[i] == mx {
				c++
			}
		}
		for _, v := range a {
			if v == mx {
				if c == 1 {
					Fprint(out, "0 ")
				} else {
					Fprint(out, "1 ")
				}
			} else {
				Fprint(out, mx-v+1, " ")
			}
		}
		Fprintln(out)
	}
}

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

package main

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

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		flag := 0
		max := 0
		if sl[0] >= sl[1] && sl[0] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		if sl[0] == max {flag++}
		if sl[1] == max {flag++}
		if sl[2] == max {flag++}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				if flag == 1 {
					ans[i][j] = 0
				} else {
					ans[i][j] = 1
				}
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

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)
		fmt.Println(ddd(a, b, c), ddd(b, a, c), ddd(c, a, b))
	}

}

func ddd(a, b, c int) int {
	if a > max(b, c) {
		return 0
	}
	return max(b, c) - a + 1
}

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

package main

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

func main() {
	var (
		t   int
		a   int
		b   int
		c   int
		max 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])
		if a > b {
			max = a
		} else {
			max = b
		}
		if c > max {
			max = c
		}
		mc := 0
		if a == max {
			mc++
		}
		if b == max {
			mc++
		}
		if c == max {
			mc++
		}
		an, bn, cn := 0, 0, 0
		if max != a {
			an = max - a + 1
		}
		if max != b {
			bn = max - b + 1
		}
		if max != c {
			cn = max - c + 1
		}
		if max == a && mc > 1 {
			an++
		}
		if max == b && mc > 1 {
			bn++
		}
		if max == c && mc > 1 {
			cn++
		}
		fmt.Println(an, bn, cn)
	}
}

package main

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

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

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

  var t int
  fmt.Fscan(reader, &t)
  for ; t > 0; t-- {
    var a, b, c int
    fmt.Fscan(reader, &a, &b, &c)
    fmt.Fprintf(writer, "%d %d %d\n", max(0, max(b+1, c+1)-a), max(0, max(c+1, a+1)-b), max(0, max(a+1, b+1)-c))
  }
}

package main

import "fmt"

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

func main() {
  var t int
  fmt.Scanf("%d\n", &t)
  for ; t > 0; t-- {
    var a, b, c int
    fmt.Scanf("%d %d %d\n", &a, &b, &c)
    fmt.Printf("%d %d %d\n", max(0, max(b+1, c+1)-a), max(0, max(c+1, a+1)-b), max(0, max(a+1, b+1)-c))
  }
}

package main

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

func max(a int, rest ...int) int {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

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++ {
		a := make([]int, 3)
		fmt.Fscan(in, &a[0], &a[1], &a[2])

		m := max(a[0], a[1], a[2])
		m++

		winner := -1
		if a[0] > a[1] && a[0] > a[2] {
			winner = 0
		} else if a[1] > a[0] && a[1] > a[2] {
			winner = 1
		} else if a[2] > a[0] && a[2] > a[1] {
			winner = 2
		}

		for i := 0; i < len(a); i++ {
			d := m - a[i]
			if i == winner {
				d = 0
			}
			fmt.Fprintf(out, "%d ", d)
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

	T int
)

func main() {
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var a [3]int
		fmt.Fscan(r, &a[0], &a[1], &a[2])
		max, mul := 0, 0
		for i := 1; i < 3; i++ {
			if a[max] == a[i] {
				mul = 1
			} else if a[max] < a[i] {
				max = i
				mul = 0
			}
		}
		for i := range a {
			if mul == 0 && max == i {
				fmt.Fprintf(w, "%d ", 0)
			} else {
				fmt.Fprintf(w, "%d ", a[max] + 1 - a[i])
			}
		}
		fmt.Fprintln(w)
	}
	_ = w.Flush()
}

package main // ignore

import "fmt"

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

func solve () {
    var a, b, c int
    fmt.Scan(&a, &b, &c)

    ansa := max(max(b, c) - a, 0)
    ansb := max(max(a, c) - b, 0)
    ansc := max(max(a, b) - c, 0)

    if a + ansa == max(b, c) {ansa++}
    if b + ansb == max(a, c) {ansb++}
    if c + ansc == max(a, b) {ansc++}

    fmt.Println(ansa, ansb, ansc)
}

func main () {
    var t int
    fmt.Scan(&t)
    for ; t > 0; t-- {solve()}
}

package main

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

var a, b, c int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

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

		solve()

		fmt.Println()
	}
}

func solve() {
	var d1, d2 int
	if a - b <= 0 {
		d1 = b - a + 1
	}
	if a - c <= 0 {
		d2 = c - a + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if b - a <= 0 {
		d1 = a - b + 1
	}
	if b - c <= 0 {
		d2 = c - b + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if c - a <= 0 {
		d1 = a - c + 1
	}
	if c - b <= 0 {
		d2 = b - c + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

}

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

package main
import(
    "fmt"
)
func main(){
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var a,b,c,largest int
		fmt.Scan(&a,&b,&c)
		if a >= b {
			largest= a
		} else {
			largest= b
		}
		if c >= a && c>= b {
			largest= c
		}
		if a > b && a > c {
			fmt.Printf("%v ",0)
			b= (largest-b)+1
			fmt.Printf("%v ",b)
			c= (largest-c)+1
			fmt.Printf("%v",c)
		} else if b > a && b > c {
			a= (largest-a)+1
			fmt.Printf("%v ",a)
			fmt.Printf("%v ",0)
			c= (largest-c)+1
			fmt.Printf("%v",c)
		} else if c > a && c > b {
			a= (largest-a)+1
			fmt.Printf("%v ",a)
			b= (largest-b)+1
			fmt.Printf("%v ",b)
			fmt.Printf("%v",0)
		} else {
			a= (largest-a)+1
			b= (largest-b)+1
			c= (largest-c)+1
			fmt.Printf("%v %v %v",a,b,c)
		}
		fmt.Println()
	}
}

package main

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

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

	for test := parseInt(getString(reader)); test > 0; test-- {
		abc := getIntln(reader)
		a, b, c := abc[0], abc[1], abc[2]
		if a == b && b == c && c == a {
			writer.WriteString("1 1 1\n")
		} else if a == b {
			if a > c {
				writer.WriteString(fmt.Sprintln(1, 1, (a + 1 - c)))
			} else {
				writer.WriteString(fmt.Sprintln((c + 1 - a), (c + 1 - b), 0))
			}
		} else if b == c {
			if c > a {
				writer.WriteString(fmt.Sprintln((c + 1 - a), 1, 1))
			} else {
				writer.WriteString(fmt.Sprintln(0, (a + 1 - b), (a + 1 - c)))
			}
		} else if a == c {
			if a > b {
				writer.WriteString(fmt.Sprintln(1, (a + 1 - b), 1))
			} else {
				writer.WriteString(fmt.Sprintln((b + 1 - a), 0, (b + 1 - c)))
			}
		} else {
			if a > b {
				if a > c {
					writer.WriteString(fmt.Sprintln(0, (a + 1 - b), (a + 1 - c)))
				} else {
					writer.WriteString(fmt.Sprintln((c + 1 - a), (c + 1 - b), 0))
				}
			} else {
				if b > c {
					writer.WriteString(fmt.Sprintln((b + 1 - a), 0, (b + 1 - c)))
				} else {
					writer.WriteString(fmt.Sprintln((c + 1 - a), (c + 1 - b), 0))
				}
			}
		}
	}
	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"
	"strconv"
	"strings"
)

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

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

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

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

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

/**
Run solve the problem CF1593A
Date: 8/11/21
User: pepradere
URL: https://codeforces.com/problemset/problem/1593/A
Problem: CF1593A
**/
func (in *CF1593A) Run() {
	t := in.NextInt()
	for ; t > 0; t-- {
		a, b, c := in.NextInt64(), in.NextInt64(), in.NextInt64()

		if a > b && a > c {
			fmt.Print(0, " ")
		} else {
			max := max(b,c)+1
			fmt.Print(max-a, " ")
		}

		if b > a && b > c {
			fmt.Print(0, " ")
		} else {
			max := max(a,c)+1
			fmt.Print(max-b, " ")
		}

		if c > a && c > b {
			fmt.Print(0, " ")
		} else {
			max := max(a,b)+1
			fmt.Print(max-c, " ")
		}
		fmt.Println()
	}
}

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

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

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

package main

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

//problem A

type Elections struct {
	a, b, c int64
}

func (e *Elections) max(x, y int64) int64 {
	if x < y {
		return y
	}
	return x
}

func (e *Elections) needVotes(a, b, c int64) int64 {
	votes := int64(0)
	if a <= b {
		votes = e.max(votes, b-a+1)
	}

	if a <= c {
		votes = e.max(votes, c-a+1)
	}

	return votes
}

func (e *Elections) AWin() int64 {
	return e.needVotes(e.a, e.b, e.c)
}

func (e *Elections) BWin() int64 {
	return e.needVotes(e.b, e.a, e.c)
}

func (e *Elections) CWin() int64 {
	return e.needVotes(e.c, e.a, e.b)
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t int
	var e Elections

	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d %d %d\n", &e.a, &e.b, &e.c)
		fmt.Printf("%d %d %d\n", e.AWin(), e.BWin(), e.CWin())
	}
}

package main

import "fmt"

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

func help(a, b, c int) int {
        return max(max(b, c)-a+1, 0)
}

func work() {
        var a, b, c int
        fmt.Scan(&a, &b, &c)
        fmt.Printf(
                "%v %v %v\n",
                help(a, b, c),
                help(b, a, c),
                help(c, a, b),
        )
}

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

package main

import (
	"fmt"
	"os"
)

func main() {
	testCase := 0
	fmt.Scanf("%d", &testCase)

	inputs := [][]int{}
	for i := 0; i < testCase; i++ {
		input := make([]int, 3)
		fmt.Fscan(os.Stdin, packAddrs(input)...)

		inputs = append(inputs, input)
	}

	for _, v := range inputs {
		topVote := 0
		for _, w := range v {
			if topVote < w {
				topVote = w
			}
		}

		countTopVote := 0
		for _, w := range v {
			if topVote == w {
				countTopVote++
			}
		}

		output := []int{}
		if countTopVote == 1 {
			for _, w := range v {
				if w != topVote {
					output = append(output, topVote-w+1)
				} else {
					output = append(output, 0)
				}
			}
		} else {
			for _, w := range v {
				if w == topVote {
					output = append(output, 1)
				} else {
					output = append(output, topVote-w+1)
				}
			}
		}

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

func packAddrs(n []int) []interface{} {
	p := make([]interface{}, len(n))
	for i := range n {
		p[i] = &n[i]
	}
	return p
}

package main

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

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

	return a
}

func solve(a, b, c int) int {
	return max(-1, max(b - a, c - a)) + 1
}

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

	var t, a, b, c int
	_, _ = fmt.Fscan(r, &t)

	for ; t > 0; t-- {
		_, _ = fmt.Fscan(r, &a, &b, &c)
		fmt.Printf("%d %d %d\n", solve(a, b, c), solve(b, a, c), solve(c, a, b))
	}
}

package main

import (
	"fmt"
)

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

func findEach(a, b, c int) int {
	if a > max(b, c) {
		return 0
	}
	return max(b, c) - a + 1
}

func solve() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	fmt.Println(findEach(a, b, c), findEach(b, a, c), findEach(c, a, b))
}

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

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

package main

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

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

	var t, a, b, c int
	_, _ = fmt.Fscan(r, &t)
	for ; t > 0; t-- {
		_, _ = fmt.Fscan(r, &a, &b, &c)
		fmt.Printf("%d %d %d\n", candidate(a, b, c), candidate(b, a, c), candidate(c, a, b))
	}
}

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

func candidate(score, a, b int) int {
	if score > max(a, b) {
		return 0
	}
	return max(a, b) + 1 - score
}

package main

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

func main() {
	var ignore bool
	res := [][]int{}

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line := scanner.Text()
		if !ignore {
			ignore = true
			continue
		}
		var a, b, c int
		fmt.Sscanf(line, "%d %d %d", &a, &b, &c)
		var ra, rb, rc = max(b, c) + 1 - a, max(a, c) + 1 - b, max(a, b) + 1 - c
		res = append(res, []int{ra, rb, rc})
	}

	for _, v := range res {
		for i, n := range v {
			if n < 0 {
				n = 0
			}
			if i > 0 {
				fmt.Print(" ")
			}
			fmt.Print(n)
		}
		fmt.Println()
	}

}

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

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

package main

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

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

func calc(a int, b int, c int) int {
	temp := Max(b, c)
	if temp >= a {
		return (temp + 1) - a
	}
	return 0
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)
	for i := 0; i < n; i++ {
		var a, b, c int
		fmt.Fscan(reader, &a)
		fmt.Fscan(reader, &b)
		fmt.Fscan(reader, &c)
		fmt.Print(calc(a, b, c), " ")
		fmt.Print(calc(b, a, c), " ")
		fmt.Println(calc(c, b, a))
	}
}

package main

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

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

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

func Solve(a, b, c int) int {
	if a > b && a > c {
		return 0
	}
	return Max(b, c) + 1 - a
}

func main() {
	var ntc, a, b, c int
	fmt.Fscan(in, &ntc)
	for t := 0; t < ntc; t++ {
		fmt.Fscan(in, &a, &b, &c)
		fmt.Fprintf(out, "%d %d %d\n", Solve(a, b, c), Solve(b, a, c), Solve(c, a, b))
	}
	out.Flush()
}

package main

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

type Obj struct {
	V   int
	Mod int
	Cnt int
}

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)

		m, mCnt := max(a, b, c)

		if a <= m {
			a = m - a
			if mCnt != 1 || a != 0 {
				a++
			}
		}
		if b <= m {
			b = m - b
			if mCnt != 1 || b != 0 {
				b++
			}
		}
		if c <= m {
			c = m - c
			if mCnt != 1 || c != 0 {
				c++
			}
		}
		fmt.Fprintln(out, a, b, c)
	}

}

func max(a, b, c int) (m int, cnt int) {
	if a > b {
		m = a
	} else {
		m = b
	}
	if m < c {
		m = c
	}

	if a == m {
		cnt++
	}
	if b == m {
		cnt++
	}
	if c == m {
		cnt++
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t, a, b, c int
	Fscan(in, &t)
	for t > 0 {
		Fscan(in, &a, &b, &c)
		m := maxOfThree(a, b, c)

		sa := m - a
		sb := m - b
		sc := m - c

		if sa == 0 {
			if a == b || a == c {
				sa += 1
			}
		} else {
			sa += 1
		}

		if sb == 0 {
			if a == b || b == c {
				sb += 1
			}
		} else {
			sb += 1
		}

		if sc == 0 {
			if a == c || b == c {
				sc += 1
			}
		} else {
			sc += 1
		}

		Println(sa, sb, sc)
		t--
	}

}

func max(n, m int) int {
	if n > m {
		return n
	}
	return m
}

func maxOfThree(n, m, l int) int {
	result := max(n, m)
	result = max(result, l)
	return result
}

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

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
}

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 int64
		fmt.Fscan(input, &a, &b, &c)
		greatest := MAX(MAX(a, b), c)
		var num int
		if a == greatest {
			num++
		}
		if b == greatest {
			num++
		}
		if c == greatest {
			num++
		}

		if a < greatest {
			fmt.Println(greatest - a + 1)
		} else {
			if num == 1 {
				fmt.Println(0)
			} else {
				fmt.Println(1)
			}
		}

		if b < greatest {
			fmt.Println(greatest - b + 1)
		} else {
			if num == 1 {
				fmt.Println(0)
			} else {
				fmt.Println(1)
			}
		}
		if c < greatest {
			fmt.Println(greatest - c + 1)
		} else {
			if num == 1 {
				fmt.Println(0)
			} else {
				fmt.Println(1)
			}
		}
	}

}

package main

import (
	"fmt"
)

func max(a []int) int {
	x := a[0]
	for _, k := range a {
		if x < k {
			x = k
		}
	}
	return x
}

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		var a, b, c int
		fmt.Scanf("%d %d %d\n", &a, &b, &c)
		fmt.Printf("%d %d %d\n", max([]int{0, b + 1 - a, c + 1 - a}), max([]int{0, a + 1 - b, c + 1 - b}), max([]int{0, a + 1 - c, b + 1 - c}))
	}
}

package main

import "fmt"

func f(a, b, c int) (int, int, int) {
	var r1, r2, r3 int
	m1 := max(b, c)
	if max(b, c) >= a {
		r1 = m1 - a + 1
	}

	m2 := max(a, c)
	if m2 >= b {
		r2 = m2 - b + 1
	}

	m3 := max(a, b)
	if m3 >= c {
		r3 = m3 - c + 1
	}

	return r1, r2, r3
}

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

func main() {
	var a, b, c, t int
	fmt.Scan(&t)
	for ; t > 0; t-- {
		fmt.Scan(&a, &b, &c)
		fmt.Println(f(a, b, c))
	}
}

package main

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

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

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

		cnt := make(map[int]int)
		cnt[a]++
		cnt[b]++
		cnt[c]++

		x := a
		if b > x {
			x = b
		}
		if c > x {
			x = c
		}

		na := x - a
		nb := x - b
		nc := x - c

		if a == x && cnt[x] != 1 {
			na++
		}
		if a != x {
			na++
		}
		if b == x && cnt[x] != 1 {
			nb++
		}
		if b != x {
			nb++
		}
		if c == x && cnt[x] != 1 {
			nc++
		}
		if c != x {
			nc++
		}
		fmt.Println(na, nb, nc)
	}
}

package main

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

func solve(arr ...float64) int {
	return int(math.Max(0, math.Max(arr[0], arr[1])+1-arr[2]))
}
func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]float64, 3)
		for i := 0; i < len(arr); i++ {
			arr[i], _ = strconv.ParseFloat(sc.nextString(), 64)
		}
		fmt.Printf("%d %d %d\n", solve(arr...), solve(arr...), solve(arr...))
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

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

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

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

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

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

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

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

func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]int, 3)
		max := 0
		c := 0
		for i := 0; i < len(arr); i++ {
			arr[i] = sc.nextInt()
			if max <= arr[i] {
				if max == arr[i] {
					c++
				}
				max = arr[i]
			}
		}
		for i := 0; i < len(arr); i++ {
			if c == 3 {
				fmt.Print(arr[i]+1, " ")
			} else if arr[i] == max {
				fmt.Print(0, " ")
			} else {
				fmt.Print(max-arr[i]+1, " ")
			}
		}
		fmt.Println()
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

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

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

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

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

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

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

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

func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]int, 3)
		max := 0
		c := 0
		for i := 0; i < len(arr); i++ {
			arr[i] = sc.nextInt()
			if max <= arr[i] {
				if max == arr[i] {
					c++
				}
				max = arr[i]
			}
		}
		for i := 0; i < len(arr); i++ {
			if arr[i] == max && c != 3 {
				fmt.Print(0, " ")
			} else if c == 3 {
				fmt.Print(arr[i]+1, " ")
			} else {
				fmt.Print(max-arr[i]+1, " ")
			}
		}
		fmt.Println()
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

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

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

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

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

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

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

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

func (sc *A) run() {
	T := sc.nextInt()
	for t := 0; t < T; t++ {
		arr := make([]int, 3)
		max := 0
		for i := 0; i < len(arr); i++ {
			arr[i] = sc.nextInt()
			if max < arr[i] {
				max = arr[i]
			}
		}
		for i := 0; i < len(arr); i++ {
			if arr[i] == max {
				fmt.Print(0, " ")
			} else {
				fmt.Print(max-arr[i]+1, " ")
			}
		}
		fmt.Println()
	}
}

func main() {
	file, err := os.Open("input.txt")
	var F *bufio.Reader
	if err == nil {
		F = bufio.NewReader(file)
		os.Stdin = file
	} else {
		F = bufio.NewReader(os.Stdin)
	}
	defer func(file *os.File) {
		_ = file.Close()
	}(file)
	NewA(F).run()
}

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

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

func (sc *A) nextLine() string {
	line, err := sc.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	sc.split = []string{}
	sc.index = 0
	return line
}

func (sc *A) load() {
	if len(sc.split) <= sc.index {
		sc.split = strings.Split(sc.nextLine(), sc.separator)
		sc.index = 0
	}
}

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

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

func (sc *A) nextString() string {
	sc.load()
	val := strings.TrimSpace(sc.split[sc.index])
	sc.index++
	return val
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

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)
		mx := Max(a, b, c)
		ma, mb, mc := mx-a+1, mx-b+1, mx-c+1
		if mx == a && mx > 0 {
			ma = 0
		}
		if mx == b && mx > 0 {
			mb = 0
		}
		if mx == c && mx > 0 {
			mc = 0
		}
		if ma == mb && ma == 0 {
			ma, mb = 1, 1
		}
		if mb == mc && mc == 0 {
			mb, mc = 1, 1
		}
		if ma == mc && ma == 0 {
			ma, mc = 1, 1
		}
		if ma == mb && mb == mc && ma == 0 {
			ma, mb, mc = 1, 1, 1
		}
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

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)
		mx := Max(a, b, c)
		ma, mb, mc := mx-a+1, mx-b+1, mx-c+1
		if mx == a && mx > 0 {
			ma = 0
		}
		if mx == b && mx > 0 {
			mb = 0
		}
		if mx == c && mx > 0 {
			mc = 0
		}
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func Max(arg ...int) int {
	m := arg[0]
	for _, v := range arg {
		if v > m {
			m = v
		}
	}
	return m
}

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)
		mx := Max(a, b, c)
		ma, mb, mc := mx-a+1, mx-b+1, mx-c+1
		if mx == a {
			ma = 0
		}
		if mx == b {
			mb = 0
		}
		if mx == c {
			mc = 0
		}
		fmt.Fprintln(w, ma, mb, mc)
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		flag := 0
		max := 0
		if sl[0] >= sl[1] && sl[1] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		if sl[0] == max {flag++}
		if sl[1] == max {flag++}
		if sl[2] == max {flag++}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				if flag == 1 {
					ans[i][j] = 0
				} else {
					ans[i][j] = 1
				}
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

package main

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

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		if sl[0] ==  sl[1] && sl[1] == sl[2] {
			ans[i][0] =1
			ans[i][1] = 1
			ans[i][2] = 1
			continue
		}
		max := 0
		if sl[0] >= sl[1] && sl[1] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				ans[i][j] = 0
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

package main

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

func main() {
	//输入输出部分
	cnt := 0
	fmt.Fscan(os.Stdin, &cnt)
	ans := make([][]int, cnt)
	for j :=0; j < cnt; j++ {
		ans[j] = make([]int, 3)
		for i := 0; i < 3; i++ {
			fmt.Fscan(os.Stdin, &ans[j][i])
		}
	}
	//算法部分
	for i, sl := range ans{
		if sl[0] ==  sl[1] && sl[1] == sl[2] {
			ans[i][0] += 1
			ans[i][1] += 1
			ans[i][2] += 1
			continue
		}
		max := 0
		if sl[0] >= sl[1] && sl[1] >= sl[2] {
			max = sl[0]
		} else if sl[1] >= sl[0] && sl[1] >= sl[2] {
			max = sl[1]
		} else {
			max = sl[2]
		}
		for j, v := range sl {
			if v != max {
				ans[i][j] = max -v + 1
			} else {
				ans[i][j] = 0
			}
		}
	}

	for _, sl := range ans {
		fmt.Println(strconv.Itoa(sl[0]) + " " + strconv.Itoa(sl[1]) + " " + strconv.Itoa(sl[2]))
	}
}

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)
		fmt.Println(ddd(a, b, c), ddd(b, a, c), ddd(c, a, b))
	}

}

func ddd(a, b, c int) int {
	if a > max(b, c) {
		return 0
	}
	return max(a, b) - a + 1
}

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

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)
		dd := max(a, max(b, c))
		if a == b && a == c {
			fmt.Println(a+1, b+1, c+1)
		} else if dd-b == 0 {
			fmt.Println(dd-a+1, "0", dd-c+1)
		} else if dd-c == 0 {
			fmt.Println(dd-a+1, dd-b+1, "0")
		} else if dd-a == 0 {
			fmt.Println("0", dd-b+1, dd-c+1)

		}
	}

}

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

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)
		dd := max(a, max(b, c))
		if a == b && a == c {
			fmt.Println(dd-a+1, dd-b+1, dd-c+1)
		} else if dd-b == 0 {
			fmt.Println(dd-a+1, "0", dd-c+1)
		} else if dd-c == 0 {
			fmt.Println(dd-a+1, dd-b+1, "0")
		} else if dd-a == 0 {
			fmt.Println("0", dd-b+1, dd-c+1)

		}
	}

}

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

package main

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

func main() {
	var (
		t   int
		a   int
		b   int
		c   int
		max 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])
		if a > b {
			max = a
		} else {
			max = b
		}
		if c > max {
			max = c
		}
		an, bn, cn := 0, 0, 0
		if max != a {
			an = max - a + 1
		}
		if max != b {
			bn = max - b + 1
		}
		if max != c {
			cn = max - c + 1
		}
		if a == 0 && b == 0 && c == 0 {
			fmt.Println(1, 1, 1)
		} else {
			fmt.Println(an, bn, cn)
		}
	}
}

package main

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

func max(a int, rest ...int) int {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

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++ {
		a := make([]int, 3)
		fmt.Fscan(in, &a[0], &a[1], &a[2])

		m := max(a[0], a[1], a[2])

		for i := 0; i < len(a); i++ {
			if a[i] != m {
				fmt.Fprintf(out, "%d ", m-a[i]+1)
			} else {
				fmt.Fprintf(out, "%d ", 0)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

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

	T int
)

func main() {
	fmt.Fscan(r, &T)
	for ; T > 0; T-- {
		var a [3]int
		fmt.Fscan(r, &a[0], &a[1], &a[2])
		max, mul := 0, 0
		for i := 1; i < 3; i++ {
			if a[max] == a[i] {
				mul = 1
			} else if a[max] < a[i] {
				max = i
				mul = 0
			}
		}
		for i := range a {
			if mul == 0 && max == i {
				fmt.Fprint(w, 0, "")
			} else {
				fmt.Fprint(w, a[max] + 1 - a[i], "")
			}
		}
		fmt.Fprintln(w)
	}
	_ = w.Flush()
}

package main // ignore

import "fmt"

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

func solve () {
    var a, b, c int
    fmt.Scan(&a, &b, &c)

    ansa := max(max(b, c) - a, 0) + 1
    ansb := max(max(a, c) - b, 0) + 1
    ansc := max(max(a, b) - c, 0) + 1

    // if a + ansa == max(b, c) {ansa++}
    // if b + ansb == max(a, c) {ansb++}
    // if c + ansc == max(a, b) {ansc++}

    fmt.Println(ansa, ansb, ansc)
}

func main () {
    var t int
    fmt.Scan(&t)
    for ; t > 0; t-- {solve()}
}

package main

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

var a, b, c int

func main() {

	r := bufio.NewReader(os.Stdin)

	var t int

	fmt.Fscan(r, &t)

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

		solve()

		fmt.Println()
	}
}

func solve() {
	var d1, d2 int
	if a - b < 0 {
		d1 = b - a + 1
	}
	if a - c < 0 {
		d2 = c - a + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if b - a < 0 {
		d1 = a - b + 1
	}
	if b - c < 0 {
		d2 = c - b + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

	d1 = 0
	d2 = 0

	if c - a < 0 {
		d1 = a - c + 1
	}
	if c - b < 0 {
		d2 = b - c + 1
	}
	fmt.Print(max(d1, d2))
	fmt.Print(" ")

}

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


package main

import (
	"fmt"
)

func pow(x, y int) (res int) {
	res = 1
	for y > 0 {
		res = res * x
		y--
	}
	return res
}

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

func common(last_x, x, last_y, y int64) int64 {
	if x < last_y || y < last_x {
		return 0
	}
	if last_x > last_y {
		return common(last_y, y, last_x, x)
	}

	res := min(x, y) - last_y
	if last_x != last_y {
		res += 1
	}

	return res
}

func main() {
	var last_x, last_y int64 = 0, 0
	var n int
	fmt.Scan(&n)
	res := int64(1)
	for ; n > 0; n-- {
		var x, y int64
		fmt.Scan(&x, &y)
		res += common(last_x, x, last_y, y)
		last_x, last_y = x, y
	}
	fmt.Println(res)
}

package main

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

func solveB(a,b,c,d int64) int64 {
	//fmt.Printf("%d %d %d %d\n",a,b,c,d)
	if a>b || c > d||b < c || a > d{
		return 0
	}
	var maxx int64=a
	if maxx < c{
		maxx = c
	}
	var maxy int64=b
	if maxy > d{
		maxy = d
	}
	//fmt.Printf("%d %d %d %d %d %d\n",a,b,c,d,maxx,maxy)
	if maxy-maxx+1 > 0{
		return maxy-maxx+1
	}
	return 0
}
func main() {
	buf := bufio.NewReader(os.Stdin)

	var n int
	var x,y int64

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

	var prex,prey int64
	var ans int64=1
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d %d\n" , &x,&y)
		if prex==prey{
			prex++
			prey++
		}
		ans += solveB(prex,x,prey,y)
		prex = x
		prey = y
	}

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

package main

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

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

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

func main() {
	var n, a, b, c, pcurr, a1, b1, prev, curr int
	c = 1
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d %d\n", &a1, &b1)
		prev, curr = max(a, b), min(a1, b1)
		diff := curr - prev
		if diff >= 0 {
			c += diff
			if pcurr != prev {
				c++
			}
		}
		a = a1
		b = b1
		pcurr = curr
	}
	fmt.Printf("%d\n", c)
}

package main

import "fmt"

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

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

func main() {
	var n, a, b, c, pcurr int
	c = 1
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var a1, b1 int
		fmt.Scan(&a1, &b1)
		// fmt.Println(a1, b1)

		var prev, curr int = max(a, b), min(a1, b1)
		// fmt.Println(prev, curr)
		diff := curr - prev
		if diff >= 0 {
			c += diff
			if pcurr != prev {
				c++
			}
		}
		// pa = a
		// pb = b
		// fmt.Println(pa, pb)

		a = a1
		b = b1
		pcurr = curr
		// fmt.Println(c)
	}
	// if c == 0 {
	// 	fmt.Println(1)
	// } else {
	fmt.Println(c)
	// }
}

package main

import "fmt"

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

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

func main() {
	var n, a, b, c, pcurr int
	c = 1
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var a1, b1 int
		fmt.Scan(&a1)
		fmt.Scan(&b1)
		//fmt.Println("input:", a1, b1)
		//fmt.Println(a, b)

		var prev, curr int = max(a, b), min(a1, b1)
		//fmt.Println(prev, curr)
		diff := curr - prev
		if diff >= 0 {
			c += diff
			if pcurr != prev {
				c++
			}
		}
		// pa = a
		// pb = b
		// fmt.Println(pa, pb)

		a = a1
		b = b1
		pcurr = curr
		//fmt.Println(c)
	}
	// if c == 0 {
	// 	fmt.Println(1)
	// } else {
	fmt.Println(c)
	// }
}

package main

import "fmt"

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

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

func main() {
	var n, a, b, c, pcurr, a1, b1, prev, curr int
	c = 1
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a1, &b1)
		prev, curr = max(a, b), min(a1, b1)
		diff := curr - prev
		if diff >= 0 {
			c += diff
			if pcurr != prev {
				c++
			}
		}
		a = a1
		b = b1
		pcurr = curr
	}
	fmt.Println(c)
}

package main

import (
	"fmt"
)

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

	var ans, la, lb int
	var a, b int

	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d\n", &a, &b)
		r := minInt(a, b) - maxInt(la, lb) + 1
		if r >= 0 {
			ans += r
		}
		if a == b {
			ans--
		}
		la = a
		lb = b
	}
	if la == lb {
		ans++
	}

	fmt.Println(ans)
}
func minInt(a, b int) int {
	if b > a {
		return a
	}
	return b
}

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

package main

import (
	"fmt"
)

func pow(x, y int) (res int) {
	res = 1
	for y > 0 {
		res = res * x
		y--
	}
	return res
}

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

func main() {
	var last_x, last_y int64 = 0, 0
	var n int
	fmt.Scan(&n)
	res := int64(1)
	for ; n > 0; n-- {
		var x, y int64
		fmt.Scan(&x, &y)
		if last_x == last_y {
			res += min(x, y) - last_x
		}	else if last_x > last_y && x <= y {
			res += min(x, y) - last_x + 1
		} else if last_x < last_y && x >= y {
			res += min(x, y) - last_y + 1
		}
		last_x, last_y = x, y
	}
	fmt.Println(res)
}

package main

import "fmt"

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

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

func main() {
	var n, a, b, c int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var a1, b1 int
		fmt.Scanf("%d %d", &a1, &b1)
		if a == a1 && b == b1 {
			continue
		}
		var prev, curr int = max(a, b), min(a1, b1)
		// fmt.Println(prev, curr)
		c += curr - prev + 1
		a = a1
		b = b1
	}
	if c == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(c)
	}
}

package main

import "fmt"

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

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

func main() {
	var n, a, b, c, pcurr int
	c = 1
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var a1, b1 int
		fmt.Scanf("%d %d", &a1, &b1)
		// fmt.Println(a1, b1)

		var prev, curr int = max(a, b), min(a1, b1)
		// fmt.Println(prev, curr)
		diff := curr - prev
		if diff >= 0 {
			c += diff
			if pcurr != prev {
				c++
			}
		}
		// pa = a
		// pb = b
		// fmt.Println(pa, pb)

		a = a1
		b = b1
		pcurr = curr
		// fmt.Println(c)
	}
	// if c == 0 {
	// 	fmt.Println(1)
	// } else {
	fmt.Println(c)
	// }
}

package main

import "fmt"

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

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

func main() {
	var n, a, b, c, pcurr int
	c = 1
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var a1, b1 int
		fmt.Scanf("%d %d", &a1, &b1)
		// fmt.Println(a1, b1)

		var prev, curr int = max(a, b), min(a1, b1)
		// fmt.Println(prev, curr)
		diff := curr - prev
		if diff > 0 {
			c += diff
			if pcurr != prev {
				c++
			}
		}
		// pa = a
		// pb = b
		// fmt.Println(pa, pb)

		a = a1
		b = b1
		pcurr = curr
		// fmt.Println(c)
	}
	// if c == 0 {
	// 	fmt.Println(1)
	// } else {
	fmt.Println(c)
	// }
}

package main

import (
	"fmt"
	"math"
)

type Score struct {
	A float64
	B float64
}

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

	scores := make([]Score, n+1, n+1)
	scores[0] = Score{0, 0}

	for i := 1; i < n+1; i++ {
		score := Score{0, 0}
		fmt.Scanf("%f %f\n", &score.A, &score.B)
		scores[i] = score
	}

	var eq uint64 = 1
	if n == 1 {
		fmt.Println(eq)
		return
	}

	for i := 1; i < n+1; i++ {
		a := scores[i-1]
		b := scores[i]

		l := uint64(math.Min(b.A, b.B))
		u := uint64(math.Max(a.A, a.B))

		if l >= u {
			if l == u && l != 0 {
				eq++
				continue
			} else {
				eq += l - u
			}
		}
	}

	// check last
	last := scores[len(scores)-1]
	if uint64(last.A) == uint64(last.B) && uint64(last.A) != 0 {
		eq++
	}

	fmt.Println(eq)
}

package main

import (
	"fmt"
)

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

	var ans, la, lb int
	for i := 0; i <= n; i++ {
		var a, b int
		fmt.Scanf("%d %d\n", &a, &b)
		r := minInt(a, b) - maxInt(la, lb) + 1
		if r >= 0 {
			ans += r
		}
		if a == b {
			ans--
		}
		la = a
		lb = b
	}
	if la == lb {
		ans++
	}

	fmt.Println(ans)
}
func minInt(a, b int) int {
	if b > a {
		return a
	}
	return b
}

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

package main

import (
	"fmt"
	"math"
)

type Score struct {
	A float64
	B float64
}

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

	scores := make([]Score, n+1, n+1)
	scores[0] = Score{0, 0}

	for i := 1; i < n+1; i++ {
		score := Score{0, 0}
		fmt.Scanf("%f %f\n", &score.A, &score.B)
		scores[i] = score
	}

	var eq uint64 = 1
	for i := 1; i < n+1; i++ {
		a := scores[i-1]
		b := scores[i]

		l := uint64(math.Min(b.A, b.B))
		u := uint64(math.Max(a.A, a.B))

		if l >= u {
			if l == u && l != 0 {
				eq++
				continue
			} else {
				eq += l - u
			}
		}
	}

	// check last
	if n > 1 {
		last := scores[len(scores)-1]
		if uint64(last.A) == uint64(last.B) && uint64(last.A) != 0 {
			eq++
		}
	}

	fmt.Println(eq)
}

package main

import (
	"fmt"
	"math"
)

type Score struct {
	A float64
	B float64
}

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

	scores := make([]Score, n+1, n+1)
	scores[0] = Score{0, 0}

	for i := 1; i < n+1; i++ {
		score := Score{0, 0}
		fmt.Scanf("%f %f\n", &score.A, &score.B)
		scores[i] = score
	}

	var eq uint64 = 1
	for i := 1; i < n+1; i++ {
		a := scores[i-1]
		b := scores[i]

		l := uint64(math.Min(b.A, b.B))
		u := uint64(math.Max(a.A, a.B))

		if l >= u {
			if l == u && l != 0 {
				eq++
				continue
			} else {
				eq += l - u
			}
		}
	}

	// check last
	last := scores[len(scores)-1]
	if uint64(last.A) == uint64(last.B) && uint64(last.A) != 0 {
		eq++
	}

	fmt.Println(eq)
}

package main

import (
	"fmt"
	"math"
)

type Score struct {
	A float64
	B float64
}

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

	scores := make([]Score, n+1, n+1)
	scores[0] = Score{0, 0}

	for i := 1; i < n+1; i++ {
		score := Score{0, 0}
		fmt.Scanf("%f %f\n", &score.A, &score.B)
		scores[i] = score
	}

	var eq uint64 = 1
	for i := 1; i < n+1; i++ {
		a := scores[i-1]
		b := scores[i]

		l := uint64(math.Min(b.A, b.B))
		u := uint64(math.Max(a.A, a.B))

		if l >= u {
			if l > u {
				eq += l - u
			} else if l != 0 && uint64(a.A) != uint64(a.B) {
				eq++
			}
		}
	}

	// check last
	if n > 1 {
		last := scores[len(scores)-1]
		if uint64(last.A) == uint64(last.B) && uint64(last.A) != 0 {
			eq++
		}
	}

	fmt.Println(eq)
}

package main

import (
	"fmt"
	"math"
)

type Score struct {
	A float64
	B float64
}

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

	scores := make([]Score, n+1, n+1)
	scores[0] = Score{0, 0}

	for i := 1; i < n+1; i++ {
		score := Score{0, 0}
		fmt.Scanf("%f %f\n", &score.A, &score.B)
		scores[i] = score
	}

	var eq uint64 = 1
	for i := 1; i < n+1; i++ {
		a := scores[i-1]
		b := scores[i]

		l := uint64(math.Min(b.A, b.B))
		u := uint64(math.Max(a.A, a.B))

		if l >= u {
			if l == u && l != 0 {
				eq++
				continue
			} else {
				eq += l - u
			}
		}
	}

	fmt.Println(eq)
}


package main

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

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

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

func Dprint(format string, a ...interface{}) {
	if Debug {
		fmt.Fprintf(os.Stderr, format+"\n", a...)
	}
}

var (
	q    int
	n    int
	rows [2][]int
)

func typ(t byte) int {
	switch t {
	case '1', '2':
		return 1
	case '3', '4', '5', '6':
		return 2
	}
	Dprint("Type=%v", t)
	panic("invalid type")
}

// walk from rows[sr][sc] to rows[1][n-1]
func walk(sr, sc int, ltr bool) bool {
	Dprint("walk, sr=%v,v sc=%v, ltr=%v", sr, sc, ltr)
	if sr == 1 && sc == n {
		return true
	}
	if sc >= n || sr < 0 || sr >= 2 {
		return false
	}

	if rows[sr][sc] == 1 {
		if ltr {
			return walk(sr, sc+1, true)
		} else {
			return false
		}
	}

	if rows[sr][sc] == 2 {
		if ltr {
			if sr == 0 {
				return walk(1, sc, false)
			} else {
				return walk(0, sc, false)
			}
		} else {
			return walk(sr, sc+1, true)
		}
	}

	panic("wat")
}

func main() {
	defer writer.Flush()
	Scanf("%d\n", &q)

	for i := 0; i < q; i++ {
		Scanf("%d\n", &n)

		for r := 0; r < 2; r++ {
			rows[r] = make([]int, n)
			for j := 0; j < n; j++ {
				var t byte
				Scanf("%c", &t)
				rows[r][j] = typ(t)
			}
			Scanf("\n")
		}

		Dprint("walk on %v", rows)
		if walk(0, 0, true) {
			Printf("YES\n")
		} else {
			Printf("NO\n")
		}
	}
}

package main

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

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

func f(in io.Reader, out io.Writer) {
	var q int
	fmt.Fscanf(in, "%d\n", &q)

	s := bufio.NewScanner(in)
	s.Buffer(make([]byte, 0, 200*1024), 200*1024)

	for i := 0; i < q; i += 1 {
		_ = read(s)
		m := [2][]byte{}
		m[0] = []byte(read((s)))
		m[1] = []byte(read((s)))
		if test(m) {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

func test(m [2][]byte) bool {
	from := "left"
	i := 1
	j := 1

	for true {
		pipe := m[i-1][j-1]

		switch from {
		case "left":
			switch pipe {
			case '1', '2':
				j += 1
			default:
				switch i {
				case 1:
					i += 1
					from = "top"
				case 2:
					i -= 1
					from = "bottom"
				}
			}
		case "top":
			switch pipe {
			case '1', '2':
				return false
			default:
				j += 1
				from = "left"
			}

		case "bottom":
			switch pipe {
			case '1', '2':
				return false
			default:
				j += 1
				from = "left"
			}
		}

		if j > len(m[1]) {
			return i == 2
		}
	}

	return false
}

func read(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}

package main

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

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

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

	var s1, s2 string

	for i := 0; i < q; i++ {
		fmt.Fscanf(reader, "%d\n", &n)
		fmt.Fscanf(reader, "%s\n", &s1)
		fmt.Fscanf(reader, "%s\n", &s2)

		xia := 0
		j := 0
		for ; j < n; j++ {
			if xia == 0 {
				if s1[j] == '1' || s1[j] == '2' {
					xia = 0
				} else {
					xia = 1
					j--
				}
			} else if xia == 1 {
				if s2[j] == '1' || s2[j] == '2' {
					break //NO
				} else {
					xia = 2
				}
			} else if xia == 2 {
				if s2[j] == '1' || s2[j] == '2' {
					xia = 2
				} else {
					xia = 3
					j--
				}
			} else if xia == 3 {
				if s1[j] == '1' || s1[j] == '2' {
					break //NO
				} else {
					xia = 0
				}
			}
		}

		if xia == 2 && j == n {
			fmt.Printf("YES\n")
		} else {
			fmt.Printf("NO\n")
		}
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/1234/problem/C

package main

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

type Transition struct {
	From string
	To   string
}

type Move struct {
	X int
	Y int
}

type QueueItem struct {
	X         int
	Y         int
	Direction string
}

var pieceMap = map[string]Transition{
	"1": {From: "Top", To: "Bottom"},
	"2": {From: "Left", To: "Right"},
	"3": {From: "Bottom", To: "Right"},
	"4": {From: "Left", To: "Bottom"},
	"5": {From: "Left", To: "Top"},
	"6": {From: "Top", To: "Right"},
}

var moveMap = map[string]Move{
	"Right":  {X: 0, Y: 1},
	"Bottom": {X: 1, Y: 0},
	"Top":    {X: -1, Y: 0},
}

var oppositeMap = map[string]string{
	"Right":  "Left",
	"Left":   "Right",
	"Top":    "Bottom",
	"Bottom": "Top",
}

var rotations = map[string][]string{
	"1": {"1", "2"},
	"2": {"1", "2"},
	"3": {"3", "4", "5", "6"},
	"4": {"3", "4", "5", "6"},
	"5": {"3", "4", "5", "6"},
	"6": {"3", "4", "5", "6"},
}

func Solve(n int, a []string) string {
	queue := []QueueItem{{0, 0, "Left"}}
	for len(queue) > 0 {
		var item QueueItem
		item, queue = queue[0], queue[1:]
		if item.X == 1 && item.Y == n {
			return "YES"
		}
		if item.X < 0 || item.X > 1 || item.Y < 0 || item.Y > n-1 {
			continue
		}
		currentPiece := string(a[item.X][item.Y])
		for _, pieceID := range rotations[currentPiece] {
			piece := pieceMap[pieceID]
			if item.Direction == piece.From {
				queue = append(queue, QueueItem{
					X:         item.X + moveMap[piece.To].X,
					Y:         item.Y + moveMap[piece.To].Y,
					Direction: oppositeMap[piece.To],
				})
			}
		}
	}
	return "NO"
}

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

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

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

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

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

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

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

	return res
}

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

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

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

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

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

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

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

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

	if e == 0 {
		return 1
	}

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

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

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

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

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

	return a
}

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

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

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

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

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

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

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

	return string(res)
}

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

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

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

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

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

var q int
var n int
var Rows [2][]rune

func main() {
	q = ReadInt()

	for i := 0; i < q; i++ {
		n = ReadInt()
		Rows[0] = ReadRuneSlice()
		Rows[1] = ReadRuneSlice()
		// 現在地
		h, w := 0, 0

		for w < n {
			if Rows[h][w] == '1' || Rows[h][w] == '2' {
				w++
			} else {
				if h == 0 && (Rows[1][w] == '1' || Rows[1][w] == '2') {
					fmt.Println("NO")
					break
				}
				if h == 1 && (Rows[0][w] == '1' || Rows[0][w] == '2') {
					fmt.Println("NO")
					break
				}

				if h == 0 {
					h++
					w++
				} else {
					h--
					w++
				}
			}

			if w == n {
				if h == 0 {
					fmt.Println("NO")
				} else {
					fmt.Println("YES")
				}
			}
		}
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

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

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

	var s1, s2 string

	for i := 0; i < q; i++ {
		fmt.Fscanf(reader, "%d\n", &n)
		fmt.Fscanf(reader, "%s\n", &s1)
		fmt.Fscanf(reader, "%s\n", &s2)

		xia := 0
		ans := false
		for j := n - 1; j >= 0 && !ans; j-- {
			if xia == 0 {
				if s2[j] == '1' || s2[j] == '2' {
					xia = 0
				} else {
					xia = 1
					j++
				}
			} else if xia == 1 {
				if s1[j] == '1' || s1[j] == '2' {
					fmt.Printf("NO\n")
					ans = true
				} else {
					xia = 2
				}
			} else if xia == 2 {
				if s1[j] == '1' || s1[j] == '2' {
					xia = 2
				} else {
					xia = 0
				}
			}
		}

		if !ans {
			if xia == 2 {
				fmt.Printf("YES\n")
			} else {
				fmt.Printf("NO\n")
			}
		}
	}
}

package main

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

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

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

	var s1, s2 string

	for i := 0; i < q; i++ {
		fmt.Fscanf(reader, "%d\n", &n)
		fmt.Fscanf(reader, "%s\n", &s1)
		fmt.Fscanf(reader, "%s\n", &s2)

		xia := 0
		j := 0
		for ; j < n; j++ {
			if xia == 0 {
				if s2[j] == '1' || s2[j] == '2' {
					xia = 0
				} else {
					xia = 1
					j--
				}
			} else if xia == 1 {
				if s1[j] == '1' || s1[j] == '2' {
					break //NO
				} else {
					xia = 2
				}
			} else if xia == 2 {
				if s1[j] == '1' || s1[j] == '2' {
					xia = 2
				} else {
					xia = 3
					j--
				}
			} else if xia == 3 {
				if s1[j] == '1' || s1[j] == '2' {
					break //NO
				} else {
					xia = 0
				}
			}
		}

		if xia == 2 && j == n {
			fmt.Printf("YES\n")
		} else {
			fmt.Printf("NO\n")
		}
	}
}


package main

import (
	"fmt"
)

func main() {
	var n, count int
	fmt.Scan(&n)
	m := make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&m[i])
	}
	for i := 1; i < n-1; i++ {
		for j := 1; j < n-1; j++ {
			if m[i][j] == 'X' && m[i-1][j-1] == 'X' && m[i-1][j+1] == 'X' && m[i+1][j+1] == 'X' && m[i+1][j-1] == 'X' {
				count += 1
			}
		}
	}
	fmt.Println(count)
}

package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	var m = make([]string, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &m[i])
	}
	var ans int
	for i := 1; i < n-1; i++ {
		for j := 1; j < n-1; j++ {
			if m[i][j] == 'X' && m[i-1][j-1] == 'X' && m[i-1][j+1] == 'X' && m[i+1][j-1] == 'X' && m[i+1][j+1] == 'X' {
				ans++
			}
		}
	}
	fmt.Println(ans)
}

package main

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

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

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

func main() {
	defer writer.Flush()
	n := 0
	scanf("%d\n", &n)
	arr := []string{}
	s := ""
	for i := 0; i < n; i++ {
		scanf("%s\n", &s)
		arr = append(arr, s)

	}
	ans := 0
	for i := 1; i < n-1; i++ {
		for j := 1; j < n-1; j++ {
			if arr[i][j] == arr[i-1][j-1] && arr[i][j] == arr[i+1][j+1] && arr[i][j] == arr[i-1][j+1] && arr[i][j] == arr[i+1][j-1] && arr[i][j] == byte('X') {
				ans++
			}
		}
	}
	printf("%d", ans)
}

package main

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

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

	fmt.Fscanf(buf, "%d\n", &n)
	mapp:= make([][]byte,n)
	for i := 0; i < n; i++ {
		v := make([]byte,n)
		fmt.Fscanf(buf,"%s\n",&v)
		mapp[i] = v
		//fmt.Printf("%s",v)
	}
	//fmt.Printf("%s\n",mapp[0])
	res:=0

	for i := 1;i < n-1;i++{
		for j := 1;j < n-1;j++{
			if mapp[i][j] == 'X' && mapp[i-1][j-1]=='X'&& mapp[i-1][j+1]=='X'&& mapp[i+1][j-1]=='X'&& mapp[i+1][j+1]=='X'{
				res++
			}
		}
	}
	fmt.Printf("%d\n",res)
}

package main

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

func readLine(r *bufio.Reader) string {
	v, _ := r.ReadString('\n')
	return strings.Trim(v,"\r\n ")
}
func toInt(s string) int  {
	i, _ := strconv.Atoi(s)
	return i
}

func checkForCross (m *[500][500]byte, i,j int) bool {
	if 	m[i][j] 	 == m[i-1][j-1] &&
		m[i-1][j-1]  == m[i-1][j+1] &&
		m[i-1][j+1]  == m[i+1][j-1] &&
		m [i-1][j+1] == m[i+1][j+1] &&
		m[i][j] 	 == byte('X') {
		return true
	}
	return false
}

func main() {
	r := bufio.NewReader(os.Stdin)
	n := toInt(readLine(r))

	var m [500][500]byte

	for i:=0; i<n ; i++  {
		t := []byte(readLine(r))
		for j:=0; j<len(t); j++  {
			m[i][j] = t[j]
		}
	}

	count := 0
	for i:=1; i<n-1 ; i++ {
		for j := 1; j < n-1; j++ {
			if checkForCross(&m, i, j) {
				count++
			}
		}
	}
	fmt.Println(count)

}


package main

import "fmt"

func main(){

    var start string = "blue"
    var c int = 0

    ignore := false

    fmt.Scanf("%d\n", &c)

    for i := 0; i < c; i++ {
        var msg string
        fmt.Scanf("%s\n", &msg)

        if msg == "lock" {
            ignore = true
        }else if msg == "unlock" {
            ignore = false
        }else if msg == "red" || msg == "orange" || msg == "yellow" || msg == "green" || msg == "blue" || msg == "indigo" || msg == "violet" {
            if !ignore{
                start = msg
            }
        }
    }
    fmt.Print(start)
}

package main

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

const (
	lock    = "lock"
	unlock = "unlock"
)

const (
	red     = "red"
	orange  = "orange"
	yellow  = "yellow"
	green   = "green"
	blue    = "blue"
	indigo  = "indigo"
	violet  = "violet"
)

type State struct {
	status string
	color string
}

func (s *State) DoCmd(cmd string) {
	switch cmd {
	case lock, unlock:
		s.status = cmd
	case red,orange,yellow,green, blue, indigo, violet:
		if s.status == lock {
			return
		}
		s.color = cmd
	}
}

func main() {
	state := State{
		status: unlock,
		color:  blue,
	}

	reader := bufio.NewReader(os.Stdin)
	countLine, _, err := reader.ReadLine()
	if err != nil {
		panic(err.Error())
	}

	countMsgs, err := strconv.Atoi(string(countLine))
	if err != nil {
		panic(err.Error())
	}

	for i := 0; i < countMsgs; i++{
		line, _, err := reader.ReadLine()
		if err != nil {
			fmt.Print(state.color)
			return
		}
		state.DoCmd(string(line))
	}

	fmt.Print(state.color)
}

package main

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

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

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

	current := "blue"
	isLocked := false

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(r, &s)

		if s == "lock" {
			isLocked = true
		} else if s == "unlock" {
			isLocked = false
		} else {
			if isLocked {
				continue
			}
			current = s
		}
	}

	fmt.Println(current)
}

package main

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

const (
    lockState = "lock"
    unlockState = "unlock"
)

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

    color := "blue"
    lock := false

    cmdNum, _ := strconv.Atoi(scanner.Text())

    for i := 0 ; i < cmdNum ; i ++ {
        scanner.Scan()
        cmd := scanner.Text()

        switch cmd {
        case lockState:
            lock = true
        case unlockState:
            lock = false
        default:
            if !lock {
                color = cmd
            }
        }
    }

    fmt.Println(color)
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N := 0
	fmt.Fscan(f, &N)
	col, s, ok := "blue", "", false
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &s)
		if s == "lock" {
			ok = true
			continue
		} else if s == "unlock" {
			ok = false
			continue
		} else {
			if !ok {
				col = s
			}
		}
	}
	fmt.Fprintln(w, col)
	w.Flush()
}

func main() {
	solve()
}

package main

import "fmt"

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

	isLock := false
	color := "blue"
	for i := 0; i < n; i++ {
		var command string
		_, err := fmt.Scanf("%s\n", &command)
		if err != nil {
			return
		}

		if command == "lock" {
			isLock = true
			continue
		}
		if command == "unlock" {
			isLock = false
			continue
		}
		if !isLock {
			color = command
		}
	}

	fmt.Println(color)
}

package main

import (
	"fmt"
)

func main() {
	var i int
	var str string
	curStr := "blue"
	curLockState := false

	_, _ = fmt.Scan(&i)
	for t := 0; t < i; t++ {
		_, _ = fmt.Scan(&str)
		if str == "lock" {
			curLockState = true
			continue
		}
		if str == "unlock" {
			curLockState = false
			continue
		}
		if curLockState == false {
			curStr = str
		}
	}
	fmt.Println(curStr)
}

package main

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

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

	var n int
	fmt.Fscanln(in, &n)

	color := "blue"
	var locked bool

	for i := 0; i < n; i++ {
		var command string
		fmt.Fscanln(in, &command)
		switch command {
		case "lock":
			locked = true
		case "unlock":
			locked = false
		default:
			if !locked {
				color = command
			}
		}
	}

	fmt.Println(color)
}

package main

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

const (
	lock    = "lock"
	unlock = "unlock"
)

const (
	red     = "red"
	orange  = "orange"
	yellow  = "yellow"
	green   = "green"
	blue    = "blue"
	indigo  = "indigo"
	violet  = "violet"
)

type State struct {
	status string
	color string
}

func (s *State) DoCmd(cmd string) {
	switch cmd {
	case lock, unlock:
		s.status = cmd
	case red,orange,yellow,green, blue, indigo, violet:
		if s.status == lock {
			return
		}
		s.color = cmd
	}
}

func main() {
	state := State{
		status: unlock,
		color:  blue,
	}

	reader := bufio.NewReader(os.Stdin)
	countLine, _, err := reader.ReadLine()
	if err != nil {
		panic(err.Error())
	}

	countMsgs, err := strconv.Atoi(string(countLine))
	if err != nil {
		panic(err.Error())
	}

	for i := 0; i < countMsgs-1; i++{
		line, _, err := reader.ReadLine()
		if err != nil {
			fmt.Print(state.color)
			return
		}
		state.DoCmd(string(line))
	}

	fmt.Print(state.color)
}

package main

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

const (
	lock    = "lock"
	unlock = "unlock"
)

const (
	red     = "red"
	orange  = "orange"
	yellow  = "yellow"
	green   = "green"
	blue    = "blue"
	indigo  = "indigo"
	violet  = "violet"
)

type State struct {
	status string
	color string
}

func (s *State) DoCmd(cmd string) {
	switch cmd {
	case lock, unlock:
		s.status = cmd
	case red,orange,yellow,green, blue, indigo, violet:
		if s.status == lock {
			return
		}
		s.color = cmd
	}
}

func main() {
	state := State{
		status: unlock,
		color:  blue,
	}
	reader := bufio.NewReader(os.Stdin)
	line, _, err := reader.ReadLine()
	if err != nil {
		return
	}

	countMsgs, err := strconv.Atoi(string(line))
	if err != nil {
		panic(err.Error())
	}

	for i := 0; i < countMsgs; i++{
		state.DoCmd(string(line))
	}

	fmt.Print(state.color)
}

package main

import "fmt"

func main(){

    var start string = "blue"
    var c int = 0

    ignore := false

    fmt.Scanf("%d", &c)

    for i := 0; i < c; i++ {
        var msg string
        fmt.Scanf("%s\n", &msg)

        if msg == "lock" {
            ignore = true
        }else if msg == "unlock" {
            ignore = false
        }else if msg == "red" || msg == "orange" || msg == "yellow" || msg == "green" || msg == "blue" || msg == "indigo" || msg == "violet"{
            if !ignore{
                start = msg
            }
        }
    }
    fmt.Print(start)
}

package main

import "fmt"

func main(){

    var start string = "blue"
    var c int = 0

    ignore := false

    fmt.Scanf("%d", &c)

    for i := 0; i < c; i++ {
        var msg string
        fmt.Scanf("%s\n", &msg)

        if msg == "lock" {
            ignore = true
        }else if msg == "unlock" {
            ignore = false
        }else{
            if !ignore{
                start = msg
            }
        }
    }
    fmt.Print(start)
}

package main

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

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

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

	current := "blue"
	isLocked := false

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(r, &s)

		if isLocked {
			continue
		}
		if s == "lock" {
			isLocked = true
		} else if s == "unlock" {
			isLocked = false
		} else {
			current = s
		}
	}

	fmt.Println(current)
}

package main

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

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

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

	current := "blue"
	isLocked := false

	for i := 0; i < n; i++ {
		var s string
		fmt.Fscan(r, &s)

		if isLocked {
			continue
		}
		if s == "lock" {
			isLocked = true
		} else if s == "unlocked" {
			isLocked = false
		} else {
			current = s
		}
	}

	fmt.Println(current)
}


package main

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

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

type big int64

var mod big = 998244353

func main() {
	defer w.Flush()
	var t big
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		var n big
		fmt.Fscan(r, &n)
		a := make([]big, n)
		for i := big(0); i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		b := make([]big, 1)
		c := make([]big, 1)
		b[0] = a[n-1]
		c[0] = 1
		var res big = 0
		for i := n - 2; i >= 0; i-- {
			b2 := make([]big, 1)
			c2 := make([]big, 1)
			b2[0] = a[i]
			c2[0] = 1
			for j := 0; j < len(b); j++ {
				tim := (a[i] - 1) / b[j]
				cur := a[i] / (tim + 1)
				if b2[len(b2)-1] == cur {
					c2[len(c2)-1] += c[j]
				} else {
					b2 = append(b2, cur)
					c2 = append(c2, c[j])
				}
				res = (res + (i+1)*tim%mod*c[j]) % mod
			}
			b = b2
			c = c2
		}
		fmt.Fprintln(w, res)
	}
}

package main

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

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

type big int64

var mod big = 998244353

func main() {
	defer w.Flush()
	var t big
	fmt.Fscan(r, &t)
	for t > 0 {
		t--
		var n big
		fmt.Fscan(r, &n)
		a := make([]big, n)
		for i := big(0); i < n; i++ {
			fmt.Fscan(r, &a[i])
		}
		b := make([]big, 0)
		c := make([]big, 0)
		var res big = 0
		for i := n - 1; i >= 0; i-- {
			b2 := make([]big, 1)
			c2 := make([]big, 1)
			b2[0] = a[i]
			c2[0] = 1
			for j := 0; j < len(b); j++ {
				tim := (a[i] - 1) / b[j]
				cur := a[i] / (tim + 1)
				if b2[len(b2)-1] == cur {
					c2[len(c2)-1] += c[j]
				} else {
					b2 = append(b2, cur)
					c2 = append(c2, c[j])
				}
				res = (res + (i+1)*tim%mod*c[j]) % mod
			}
			b = b2
			c = c2
		}
		fmt.Fprintln(w, res)
	}
}


package main

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

var ans int
var ansX []int
var ansY []int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	x := make([]int, 3)
	y := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Fscanf(in, "%d %d\n", &x[i], &y[i])
	}
	ans1, ans1X, ans1Y := solve(x, y)
	x[0], x[2] = x[2], x[0]
	y[0], y[2] = y[2], y[0]
	ans2, ans2X, ans2Y := solve(x, y)
	x[1], x[2] = x[2], x[1]
	y[1], y[2] = y[2], y[1]
	ans3, ans3X, ans3Y := solve(x, y)
	if ans1 <= ans2 && ans1 <= ans3 {
		ans, ansX, ansY = ans1, ans1X, ans1Y
	} else if ans2 <= ans1 && ans2 <= ans3 {
		ans, ansX, ansY = ans2, ans2X, ans2Y
	} else {
		ans, ansX, ansY = ans3, ans3X, ans3Y
	}
	outputAns(out)
	return
}

func solve(x []int, y []int) (int, []int, []int) {
	ans = 0
	ansX = make([]int, 0)
	ansY = make([]int, 0)
	ansX = append(ansX, x[0])
	ansY = append(ansY, y[0])
	ans++
	ansX = append(ansX, x[1])
	ansY = append(ansY, y[1])
	ans++
	fill(x[0], y[0], x[1], y[1])
	//fmt.Println(ans)
	dis := -1
	bestX := 0
	bestY := 0
	for i := 0; i < ans; i++ {
		dish := abs(ansX[i]-x[2]) + abs(ansY[i]-y[2])
		if dis == -1 || dis > dish {
			if dish == 0 {
				//outputAns(out)
				return ans, ansX, ansY
			}
			dis = dish
			bestX = ansX[i]
			bestY = ansY[i]
		}
	}
	ansX = append(ansX, x[2])
	ansY = append(ansY, y[2])
	ans++
	//fmt.Println(ans)
	fill(bestX, bestY, x[2], y[2])
	//outputAns(out)
	return ans, ansX, ansY
}

func outputAns(out io.Writer) {
	fmt.Fprintf(out, "%d\n", ans)
	for i := 0; i < ans; i++ {
		fmt.Fprintf(out, "%d %d\n", ansX[i], ansY[i])
	}
	return
}

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

func fill(x1, y1, x2, y2 int) {
	if x1 > x2 {
		fill(x2, y2, x1, y1)
		return
	}
	if x1 == x2 {
		if y1 < y2 {
			for i := y1 + 1; i < y2; i++ {
				ansX = append(ansX, x1)
				ansY = append(ansY, i)
				ans++
			}
			return
		}
		for i := y2 + 1; i < y1; i++ {
			ansX = append(ansX, x1)
			ansY = append(ansY, i)
			ans++
		}
		return
	}
	if y1 < y2 {
		for i := x1 + 1; i <= x2; i++ {
			ansX = append(ansX, i)
			ansY = append(ansY, y1)
			ans++
		}
		for i := y1 + 1; i < y2; i++ {
			ansX = append(ansX, x2)
			ansY = append(ansY, i)
			ans++
		}
	} else if y1 == y2 {
		for i := x1 + 1; i < x2; i++ {
			ansX = append(ansX, i)
			ansY = append(ansY, y1)
			ans++
		}
	} else {
		for i := x1 + 1; i <= x2; i++ {
			ansX = append(ansX, i)
			ansY = append(ansY, y1)
			ans++
		}
		for i := y2 + 1; i < y1; i++ {
			ansX = append(ansX, x2)
			ansY = append(ansY, i)
			ans++
		}
	}
}

// hmm........
package main

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

var dirs = [][2]int{
	[2]int{-1, 0},
	[2]int{1, 0},
	[2]int{0, -1},
	[2]int{0, 1},
}

func bfs(m [][]bool, root [2]int) (map[[2]int]int, map[[2]int][2]int) {
	w, h := len(m[0]), len(m)
	distance, parent := map[[2]int]int{}, map[[2]int][2]int{}
	visited, queue := map[[2]int]bool{}, [][2]int{}

	for i, l := range m {
		for j, v := range l {
			if v {
				visited[[2]int{i, j}], queue = true, append(queue, [2]int{i, j})
				distance[[2]int{i, j}] = 0
			}
		}
	}
	if !visited[root] {
		queue, distance[root] = append(queue, root), 1
	}

	for len(queue) > 0 {
		newQueue := make([][2]int, 0, len(queue)*2)
		for _, task := range queue {
			for _, d := range dirs {
				newPos := [2]int{task[0] + d[0], task[1] + d[1]}
				if visited[newPos] || (newPos[0] < 0) || (newPos[1] < 0) || (newPos[0] >= h) || (newPos[1] >= w) {
					continue
				}
				visited[newPos], parent[newPos], distance[newPos], newQueue = true, task, distance[task]+1, append(newQueue, newPos)
			}
		}
		queue = newQueue
	}
	return distance, parent
}

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	p, xs, ys := make([][2]int, 3), []int{}, []int{}

	for i := 0; i < 3; i++ {
		scanner.Scan()
		x, _ := strconv.Atoi(scanner.Text())
		xs = append(xs, x)
		scanner.Scan()
		y, _ := strconv.Atoi(scanner.Text())
		p[i] = [2]int{x, y}
		ys = append(ys, y)
	}

	sort.Ints(xs)
	midX, midY := xs[1], -1
	for i := 0; i < 3; i++ {
		if p[i][0] == midX {
			midY = p[i][1]
		}
	}

	visited, count, res := map[[2]int]bool{}, 0, ""
	for i := 0; i < 3; i++ {
		for j := min(midY, p[i][1]); j <= max(midY, p[i][1]); j++ {
			if visited[[2]int{midX, j}] {
				continue
			}
			count++
			visited[[2]int{midX, j}] = true
			res += fmt.Sprintln(midX, j)
		}
	}

	for i := 0; i < 3; i++ {
		for j := min(midX, p[i][0]); j <= max(midX, p[i][0]); j++ {
			if visited[[2]int{j, p[i][1]}] {
				continue
			}
			count++
			visited[[2]int{j, p[i][1]}] = true
			res += fmt.Sprintln(j, p[i][1])
		}
	}
	fmt.Println(count)
	fmt.Println(res)
}

package main

import (
	"fmt"
)

type node struct {
	x, y int
}

func main(){
	var xa, ya, xb, yb, xc, yc int
	fmt.Scan(&xa, &ya, &xb, &yb, &xc, &yc)

	//sort
	if xa > xb{
		t := xa
		xa = xb
		xb =t
		t = ya
		ya = yb
		yb = t
	}
	if xa > xc{
		t := xa
		xa = xc
		xc = t
		t = ya
		ya = yc
		yc = t
	}
	if xb > xc{
		t := xb
		xb = xc
		xc = t
		t = yb
		yb = yc
		yc = t
	}
	var result[] node
	result = append(result, node{xa, ya})
	tmpx := xa
	for ; ;{
		if tmpx < xb{
			tmpx++
			result = append(result, node{tmpx, ya})
		}else {
			break
		}
	}
	tmpy := ya
	for ; ;{
		if tmpy < yb{
			tmpy++
			result = append(result, node{tmpx, tmpy})
		}else if tmpy > yb{
			tmpy--
			result = append(result, node{tmpx, tmpy})
		}else {
			break
		}
	}
	if yc > ya && yc > yb{
		if ya > yb{
			tmpy = ya
		}else {
			tmpy = yb
		}
	}else if yc < ya && yc < yb{
		if ya < yb{
			tmpy = ya
		}else{
			tmpy = yb
		}
	}else{
		tmpy = yc
	}
	for ; ;{
		if tmpx < xc{
			tmpx++
			result = append(result, node{tmpx, tmpy})
		}else {
			break
		}
	}
	for ; ;{
		if tmpy < yc{
			tmpy++
			result = append(result, node{tmpx, tmpy})
		}else if tmpy > yc{
			tmpy--
			result = append(result, node{tmpx, tmpy})
		}else {
			break
		}
	}
	fmt.Println(len(result))
	for _, each := range result{
		fmt.Printf("%d %d\n", each.x, each.y)
	}

	}

package main

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

var ans int
var ansX []int
var ansY []int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	x := make([]int, 3)
	y := make([]int, 3)
	for i := 0; i < 3; i++ {
		fmt.Fscanf(in, "%d %d\n", &x[i], &y[i])
	}
	ans1, ans1X, ans1Y := solve(x, y)
	x[0], x[2] = x[2], x[0]
	y[0], y[2] = y[2], y[0]
	ans2, ans2X, ans2Y := solve(x, y)
	x[1], x[2] = x[2], x[1]
	y[1], y[2] = y[2], y[1]
	ans3, ans3X, ans3Y := solve(x, y)
	if ans1 <= ans2 && ans1 <= ans3 {
		ans, ansX, ansY = ans1, ans1X, ans1Y
	} else if ans2 <= ans1 && ans2 <= ans3 {
		ans, ansX, ansY = ans2, ans2X, ans2Y
	} else {
		ans, ansX, ansY = ans3, ans3X, ans3Y
	}
	outputAns(out)
	return
}

func solve(x []int, y []int) (int, []int, []int) {
	ans = 0
	ansX = make([]int, 0)
	ansY = make([]int, 0)
	ansX = append(ansX, x[0])
	ansY = append(ansY, y[0])
	ans++
	ansX = append(ansX, x[1])
	ansY = append(ansY, y[1])
	ans++
	fill(x[0], y[0], x[1], y[1])
	//fmt.Println(ans)
	dis := -1
	bestX := 0
	bestY := 0
	for i := 0; i < ans; i++ {
		dish := abs(ansX[i]-x[2]) + abs(ansY[i]-y[2])
		if dis == -1 || dis > dish {
			if dish == 0 {
				//outputAns(out)
				return ans, ansX, ansY
			}
			dis = dish
			bestX = ansX[i]
			bestY = ansY[i]
		}
	}
	ansX = append(ansX, x[2])
	ansY = append(ansY, y[2])
	ans++
	//fmt.Println(ans)
	fill(bestX, bestY, x[2], y[2])
	//outputAns(out)
	return ans, ansX, ansY
}

func outputAns(out io.Writer) {
	fmt.Fprintf(out, "%d\n", ans)
	for i := 0; i < ans; i++ {
		fmt.Fprintf(out, "%d %d\n", ansX[i], ansY[i])
	}
	return
}

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

func fill(x1, y1, x2, y2 int) {
	if x1 > x2 {
		fill(x2, y2, x1, y1)
		return
	}
	if x1 == x2 {
		for i := y1 + 1; i < y2; i++ {
			ansX = append(ansX, x1)
			ansY = append(ansY, y1)
			ans++
		}
		return
	}
	if y1 < y2 {
		for i := x1 + 1; i <= x2; i++ {
			ansX = append(ansX, i)
			ansY = append(ansY, y1)
			ans++
		}
		for i := y1 + 1; i < y2; i++ {
			ansX = append(ansX, x2)
			ansY = append(ansY, i)
			ans++
		}
	} else if y1 == y2 {
		for i := x1 + 1; i < x2; i++ {
			ansX = append(ansX, i)
			ansY = append(ansY, y1)
			ans++
		}
	} else {
		for i := x1 + 1; i <= x2; i++ {
			ansX = append(ansX, i)
			ansY = append(ansY, y1)
			ans++
		}
		for i := y2 + 1; i < y1; i++ {
			ansX = append(ansX, x2)
			ansY = append(ansY, i)
			ans++
		}
	}
}