On a chessboard with a width of $$$n$$$ and a height of $$$n$$$, rows are numbered from bottom to top from $$$1$$$ to $$$n$$$, columns are numbered from left to right from $$$1$$$ to $$$n$$$. Therefore, for each cell of the chessboard, you can assign the coordinates $$$(r,c)$$$, where $$$r$$$ is the number of the row, and $$$c$$$ is the number of the column.The white king has been sitting in a cell with $$$(1,1)$$$ coordinates for a thousand years, while the black king has been sitting in a cell with $$$(n,n)$$$ coordinates. They would have sat like that further, but suddenly a beautiful coin fell on the cell with coordinates $$$(x,y)$$$...Each of the monarchs wanted to get it, so they decided to arrange a race according to slightly changed chess rules:As in chess, the white king makes the first move, the black king makes the second one, the white king makes the third one, and so on. However, in this problem, kings can stand in adjacent cells or even in the same cell at the same time.The player who reaches the coin first will win, that is to say, the player who reaches the cell with the coordinates $$$(x,y)$$$ first will win.Let's recall that the king is such a chess piece that can move one cell in all directions, that is, if the king is in the $$$(a,b)$$$ cell, then in one move he can move from $$$(a,b)$$$ to the cells $$$(a + 1,b)$$$, $$$(a - 1,b)$$$, $$$(a,b + 1)$$$, $$$(a,b - 1)$$$, $$$(a + 1,b - 1)$$$, $$$(a + 1,b + 1)$$$, $$$(a - 1,b - 1)$$$, or $$$(a - 1,b + 1)$$$. Going outside of the field is prohibited.Determine the color of the king, who will reach the cell with the coordinates $$$(x,y)$$$ first, if the white king moves first.

The first line contains a single integer $$$n$$$ ($$$2 \le n \le 10^{18}$$$) — the length of the side of the chess field. The second line contains two integers $$$x$$$ and $$$y$$$ ($$$1 \le x,y \le n$$$) — coordinates of the cell, where the coin fell.

In a single line print the answer "White" (without quotes), if the white king will win, or "Black" (without quotes), if the black king will win. You can print each letter in any case (upper or lower).

NoteAn example of the race from the first sample where both the white king and the black king move optimally: The white king moves from the cell $$$(1,1)$$$ into the cell $$$(2,2)$$$. The black king moves form the cell $$$(4,4)$$$ into the cell $$$(3,3)$$$. The white king moves from the cell $$$(2,2)$$$ into the cell $$$(2,3)$$$. This is cell containing the coin, so the white king wins.  An example of the race from the second sample where both the white king and the black king move optimally: The white king moves from the cell $$$(1,1)$$$ into the cell $$$(2,2)$$$. The black king moves form the cell $$$(5,5)$$$ into the cell $$$(4,4)$$$. The white king moves from the cell $$$(2,2)$$$ into the cell $$$(3,3)$$$. The black king moves from the cell $$$(4,4)$$$ into the cell $$$(3,5)$$$. This is the cell, where the coin fell, so the black king wins.  In the third example, the coin fell in the starting cell of the black king, so the black king immediately wins.

package main

import (
	"fmt"
	"bufio"
	"os"
)
func Abs(x uint64,y uint64)uint64{
	if x>y{
		return x-y
	}
	return y-x
}
func Min(x uint64,y uint64)uint64{
	if x>y{
		return y
	}
	return x
}
type Point struct {
	x uint64
	y uint64
	ans uint64
}

func Slove_White(temp Point,n,x,y uint64)uint64{
	for {
		if temp.x==x&&temp.y==y{
			break
		}
		if temp.x==x{
			temp.y++
			return temp.ans+Abs(y,temp.y)
		}
		if temp.y==y{
			temp.x++
			return temp.ans+Abs(x,temp.x)

		}
		add:=Min(Abs(x,temp.x),Abs(y,temp.y))
		temp.x+=add
		temp.y+=add
		temp.ans+=add
	}
	return temp.ans
}

func Slove_Block(temp Point,n,x,y uint64)uint64{
	for {
		if temp.x==x&&temp.y==y{
			break
		}
		if temp.x==x{
			temp.y--
			return temp.ans+Abs(x,temp.x)
		}
		if temp.y==y{
			temp.x--
			return temp.ans+Abs(y,temp.y)
		}
		add:=Min(Abs(x,temp.x),Abs(y,temp.y))
		temp.x-=add
		temp.y-=add
		temp.ans+=add
	}
	return temp.ans
}

var in = bufio.NewReaderSize(os.Stdin, 2<<16)
func main(){
	var n,x,y uint64
	fmt.Fscan(in, &n)

	fmt.Fscan(in, &x, &y)
	white:=Point{x:1,y:1,ans:0}
	white_ans:=Min(Abs(white.x,x),Abs(white.y,y))
	white.x+=white_ans
	white.y+=white_ans
	white_ans+=Abs(white.x,x)
	white_ans+=Abs(white.y,y)

	block:=Point{x:n,y:n,ans:0}
	block_ans:=Min(Abs(block.x,x),Abs(block.y,y))
	block.x-=block_ans
	block.y-=block_ans
	block_ans+=Abs(block.x,x)
	block_ans+=Abs(block.y,y)

	//fmt.Println(white_ans,block_ans)
	if white_ans<=block_ans{
		fmt.Println("White")
	}else{
		fmt.Println("Black")
	}

}

package main

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

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

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

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

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

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

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

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readll()
	x := readll()
	y := readll()

	dw := dist(n, 1, 1, x, y)
	db := dist(n, n, n, x, y)

	if dw <= db {
		println("White")
	} else {
		println("Black")
	}

}

func dist(n, sx, sy, gx, gy int64) int64 {
	dx := absll(gx - sx)
	dy := absll(gy - sy)

	return maxll(dx, dy)
}

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 max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func main() {
	defer writer.Flush()
	var x, y, n, a, b int64
	scanf("%d\n", &n)
	scanf("%d %d\n", &x, &y)

	a = max(x-1, y-1)
	b = max(n-x, n-y)
	if a <= b {
		printf("White\n")
	} else {
		printf("Black")
	}

}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	writer.WriteString(fmt.Sprintf("%s", Problem705A()))
}

func Problem705A() string {
	n := getI64()
	x := getI64()
	y := getI64()

	if (x-1 + y-1) <= (n-x + n-y) {
		return "White"
	} else {
		return "Black"
	}
}

package main

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

func main() {
	var (
		n, x, y int64
	)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	n, _ = strconv.ParseInt(scanner.Text(), 10, 64)

	scanner.Scan()
	x, _ = strconv.ParseInt(scanner.Text(), 10, 64)

	scanner.Scan()
	y, _ = strconv.ParseInt(scanner.Text(), 10, 64)

	dw := min(abs(x-1), abs(y-1))
	db := min(abs(x-n), abs(y-n))

	if dw <= db {
		fmt.Println("White")
	} else {
		fmt.Println("Black")
	}
}

func abs(a int64) int64 {
	if a >= 0 {
		return a
	}

	return -a
}

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

	return b
}

package main

import (
	"fmt"
	"bufio"
	"os"
)
func Abs(x uint64,y uint64)uint64{
	if x>y{
		return x-y
	}
	return y-x
}
func Min(x uint64,y uint64)uint64{
	if x>y{
		return y
	}
	return x
}
type Point struct {
	x uint64
	y uint64
	ans uint64
}

func Slove_White(temp Point,n,x,y uint64)uint64{
	for {
		if temp.x==x&&temp.y==y{
			break
		}
		if temp.x==x{
			temp.y++
			return temp.ans+Abs(y,temp.y)
		}
		if temp.y==y{
			temp.x++
			return temp.ans+Abs(x,temp.x)

		}
		add:=Min(Abs(x,temp.x),Abs(y,temp.y))
		temp.x+=add
		temp.y+=add
		temp.ans+=add
	}
	return temp.ans
}

func Slove_Block(temp Point,n,x,y uint64)uint64{
	for {
		if temp.x==x&&temp.y==y{
			break
		}
		if temp.x==x{
			temp.y--
			return temp.ans+Abs(x,temp.x)
		}
		if temp.y==y{
			temp.x--
			return temp.ans+Abs(y,temp.y)
		}
		add:=Min(Abs(x,temp.x),Abs(y,temp.y))
		temp.x-=add
		temp.y-=add
		temp.ans+=add
	}
	return temp.ans
}

var in = bufio.NewReaderSize(os.Stdin, 2<<16)
func main(){
	var n,x,y uint64
	fmt.Fscan(in, &n)

	fmt.Fscan(in, &x, &y)
	white:=Point{x:1,y:1,ans:0}
	white_ans:=Min(Abs(white.x,x),Abs(white.y,y))
	white.x+=white_ans
	white.y+=white_ans
	white_ans+=Abs(white.x,x)
	white_ans+=Abs(white.y,y)

	block:=Point{x:n,y:n,ans:0}
	block_ans:=Min(Abs(block.x,x),Abs(block.y,y))
	block.x+=block_ans
	block.y+=block_ans
	block_ans+=Abs(block.x,x)
	block_ans+=Abs(block.y,y)

	//fmt.Println(white_ans,block_ans)
	if white_ans<=block_ans{
		fmt.Println("White")
	}else{
		fmt.Println("Black")
	}

}

package main

import (
	"fmt"
	"bufio"
	"os"
)
func Abs(x uint64,y uint64)uint64{
	if x>y{
		return x-y
	}
	return y-x
}
func Min(x uint64,y uint64)uint64{
	if x>y{
		return y
	}
	return x
}
type Point struct {
	x uint64
	y uint64
	ans uint64
}

func Slove_White(temp Point,n,x,y uint64)uint64{
	for {
		if temp.x==x&&temp.y==y{
			break
		}
		if temp.x==x{
			temp.y++
			return temp.ans+Abs(y,temp.y)
		}
		if temp.y==y{
			temp.x++
			return temp.ans+Abs(x,temp.x)

		}
		add:=Min(Abs(x,temp.x),Abs(y,temp.y))
		temp.x+=add
		temp.y+=add
		temp.ans+=add
	}
	return temp.ans
}

func Slove_Block(temp Point,n,x,y uint64)uint64{
	for {
		if temp.x==x&&temp.y==y{
			break
		}
		if temp.x==x{
			temp.y--
			return temp.ans+Abs(x,temp.x)
		}
		if temp.y==y{
			temp.x--
			return temp.ans+Abs(y,temp.y)
		}
		add:=Min(Abs(x,temp.x),Abs(y,temp.y))
		temp.x-=add
		temp.y-=add
		temp.ans+=add
	}
	return temp.ans
}
var in = bufio.NewReaderSize(os.Stdin, 2<<16)
func main(){
	var n,x,y uint64
	fmt.Fscan(in, &n)

	fmt.Fscan(in, &x, &y)
	white:=Point{x:1,y:1,ans:0}
	white_ans:=Slove_White(white,n,x,y)

	block:=Point{x:n,y:n,ans:0}
	block_ans:=Slove_Block(block,n,x,y)

	//fmt.Println(white_ans,block_ans)
	if white_ans<=block_ans{
		fmt.Println("White")
	}else{
		fmt.Println("Black")
	}

}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	writer.WriteString(fmt.Sprintf("%s", Problem705A()))
}

func Problem705A() string {
	n := getI64()
	x := getI64()
	y := getI64()

	whiteX :=  int64(math.Abs(float64(x - 1)))
	whiteY := int64(math.Abs(float64(y - 1)))
	blackX := int64(math.Abs(float64(n - x)))
	blackY := int64(math.Abs(float64(n - y)))

	if (whiteX + whiteY) <= (blackX + blackY) {
		return "White"
	} else {
		return "Black"
	}
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	writer.WriteString(fmt.Sprintf("%s", Problem705A()))
}

func Problem705A() string {
	n := getI64()
	x := getI64()
	y := getI64()

	whiteX :=  int64(math.Abs(float64(1 - x)))
	whiteY := int64(math.Abs(float64(1 - y)))
	blackX := int64(math.Abs(float64(n - x)))
	blackY := int64(math.Abs(float64(n - y)))

	if (whiteX + whiteY) <= (blackX + blackY) {
		return "White"
	} else {
		return "Black"
	}
}

package main

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

var scanner *bufio.Scanner

func getI64() int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}
func getI() int {
	return int(getI64())
}
func getF() float64 {
	scanner.Scan()
	x, _ := strconv.ParseFloat(scanner.Text(), 64)
	return x
}
func getS() string {
	scanner.Scan()
	return scanner.Text()
}

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() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	writer.WriteString(fmt.Sprintf("%s", Problem705A()))
}

func Problem705A() string {
	n := getI()
	x := getI()
	y := getI()

	whiteX :=  int(math.Abs(float64(1 - x)))
	whiteY := int(math.Abs(float64(1 - y)))
	blackX := int(math.Abs(float64(n - x)))
	blackY := int(math.Abs(float64(n - y)))

	if (whiteX + whiteY) <= (blackX + blackY) {
		return "White"
	} else {
		return "Black"
	}
}

package main

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

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

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	n, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	x, _ = strconv.Atoi(scanner.Text())

	scanner.Scan()
	y, _ = strconv.Atoi(scanner.Text())

	dw := min(abs(x-1), abs(y-1))
	db := min(abs(x-n), abs(y-n))

	if dw <= db {
		fmt.Println("White")
	} else {
		fmt.Println("Black")
	}
}

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

	return -a
}

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

	return b
}


One day Misha and Andrew were playing a very simple game. First, each player chooses an integer in the range from 1 to n. Let's assume that Misha chose number m, and Andrew chose number a.Then, by using a random generator they choose a random integer c in the range between 1 and n (any integer from 1 to n is chosen with the same probability), after which the winner is the player, whose number was closer to c. The boys agreed that if m and a are located on the same distance from c, Misha wins.Andrew wants to win very much, so he asks you to help him. You know the number selected by Misha, and number n. You need to determine which value of a Andrew must choose, so that the probability of his victory is the highest possible.More formally, you need to find such integer a (1 ≤ a ≤ n), that the probability that  is maximal, where c is the equiprobably chosen integer from 1 to n (inclusive).

The first line contains two integers n and m (1 ≤ m ≤ n ≤ 109) — the range of numbers in the game, and the number selected by Misha respectively.

Print a single number — such value a, that probability that Andrew wins is the highest. If there are multiple such values, print the minimum of them.

NoteIn the first sample test: Andrew wins if c is equal to 2 or 3. The probability that Andrew wins is 2 / 3. If Andrew chooses a = 3, the probability of winning will be 1 / 3. If a = 1, the probability of winning is 0.In the second sample test: Andrew wins if c is equal to 1 and 2. The probability that Andrew wins is 1 / 2. For other choices of a the probability of winning is less.

package main

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

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

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

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

type Int int64

func main() {
	defer w.Flush()
	var n, m Int
	for I(&n, &m) == nil {
		solve(n, m)
	}
}

func solve(n, m Int) {
	var ans Int
	if n == Int(1) {
		ans = 1
	} else if m-1 >= n-m {
		ans = m - 1
	} else {
		ans = m + 1
	}
	O(ans, "\n")
}

package main

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

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

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

	n, m := nextInt(), nextInt()

	if n == 1 {
		println(1)
		return
	}

	if m-1 < n-m {
		println(m + 1)
	} else {
		println(m - 1)
	}
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }

package main

import "fmt"

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

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

func chances(a, m, n int) int {
    cnt := 0
    for c := 1; c <= n; c++ {
        if abs(a - c) < abs(c - m) {
            cnt++
        }
    }
    return cnt
}*/

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

    /*
    best := 1
    best_chances := 0
    for a := 1; a <= n; a++ {
        cnt := chances(a, m, n)
        if cnt > best_chances {
            best = a
            best_chances = cnt
        }
    }
    fmt.Println(best) */

    if n == 1 {
        fmt.Println(1)
    } else if n - m > m - 1 {
        fmt.Println(m + 1)
    } else {
        fmt.Println(m - 1)
    }
}

// salom project main.go
package main

import (
	"fmt";

)

func main() {
	var m,n int64
	fmt.Scan(&n,&m)
	if ( m==1 )&&(n==1) {
	fmt.Print("1")
	return
	}
	m=m*2
	if m>n {
		fmt.Print(m/2-1)
	}else{
		fmt.Print(m/2+1)
	}
}

package main

import "fmt"

func main() {
    var (
        n int
        m int
    )
    fmt.Scan(&n)
    fmt.Scan(&m)

    a := m - 1
    if a < n - m {
        a = m + 1
    }
    if a == 0 {
        a = m
    }
    fmt.Println(a)
}

package main

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

var N, M int

func main() {
	fsc := NewFastScanner()
	N, M = fsc.NextInt(), fsc.NextInt()
	if N == 1 {
		fmt.Println(1)
		os.Exit(0)
	}
	var left, right int
	left = M - 1
	right = N - M
	// fmt.Println(left, right)
	if right > left {
		fmt.Println(M + 1)
	} else if right <= left {
		fmt.Println(M - 1)
	}

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import "fmt"

func main() {
	var n,m int;
	_,_ = fmt.Scanf("%d %d",&n,&m)
	var u = n-m;
	var l = m-1;
	if u==0 && l==0{
		fmt.Println(m)
	}else if(u > l){
		fmt.Println(m+1)
	}else{
		fmt.Println(m-1)
	}
}

package main

import "fmt"

func main() {
    var (
        n int
        m int
    )
    fmt.Scan(&n)
    fmt.Scan(&m)

    a := m - 1
    if a < n - m {
        a = m + 1
    }
    fmt.Println(a)
}

package main

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

var N, M int

func main() {
	fsc := NewFastScanner()
	N, M = fsc.NextInt(), fsc.NextInt()
	var left, right int
	left = M - 1
	right = N - M
	fmt.Println(left, right)
	if right > left {
		fmt.Println(M + 1)
	} else if right <= left {
		fmt.Println(M - 1)
	}

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

var N, M int

func main() {
	fsc := NewFastScanner()
	N, M = fsc.NextInt(), fsc.NextInt()
	var left, right int
	left = M - 1
	right = N - M
	if right >= left {
		fmt.Println(M + 1)
	} else if right < left {
		fmt.Println(M - 1)
	}

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

var N, M int

func main() {
	fsc := NewFastScanner()
	N, M = fsc.NextInt(), fsc.NextInt()
	var left, right int
	left = M - 1
	right = N - M
	if right > left {
		fmt.Println(M + 1)
	} else if right < left {
		fmt.Println(M - 1)
	} else {
		fmt.Println(M)
	}

}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

import "fmt"

func main() {
	var n,m int;
	_,_ = fmt.Scanf("%d %d",&n,&m)
	var u = n-m;
	var l = m-1;
	if n == m{
		fmt.Println(m)
	}else if(u > l){
		fmt.Println(m+1)
	}else{
		fmt.Println(m-1)
	}
}

package main

import "fmt"

func main() {
	var n,m int;
	_,_ = fmt.Scanf("%d %d",&n,&m)
	var u = n-m;
	var l = m-1;

	if(u > l){
		fmt.Println(m+1)
	}else{
		fmt.Println(m-1)
	}
}


The Duck songFor simplicity, we'll assume that there are only three types of grapes: green grapes, purple grapes and black grapes.Andrew, Dmitry and Michal are all grapes' lovers, however their preferences of grapes are different. To make all of them happy, the following should happen: Andrew, Dmitry and Michal should eat at least $$$x$$$, $$$y$$$ and $$$z$$$ grapes, respectively. Andrew has an extreme affinity for green grapes, thus he will eat green grapes and green grapes only. On the other hand, Dmitry is not a fan of black grapes — any types of grapes except black would do for him. In other words, Dmitry can eat green and purple grapes. Michal has a common taste — he enjoys grapes in general and will be pleased with any types of grapes, as long as the quantity is sufficient.Knowing that his friends are so fond of grapes, Aki decided to host a grape party with them. He has prepared a box with $$$a$$$ green grapes, $$$b$$$ purple grapes and $$$c$$$ black grapes.However, Aki isn't sure if the box he prepared contains enough grapes to make everyone happy. Can you please find out whether it's possible to distribute grapes so that everyone is happy or Aki has to buy some more grapes?It is not required to distribute all the grapes, so it's possible that some of them will remain unused.

The first line contains three integers $$$x$$$, $$$y$$$ and $$$z$$$ ($$$1 \le x, y, z \le 10^5$$$) — the number of grapes Andrew, Dmitry and Michal want to eat. The second line contains three integers $$$a$$$, $$$b$$$, $$$c$$$ ($$$1 \le a, b, c \le 10^5$$$) — the number of green, purple and black grapes in the box.

If there is a grape distribution that allows everyone to be happy, print "YES", otherwise print "NO".

NoteIn the first example, there is only one possible distribution:Andrew should take $$$1$$$ green grape, Dmitry should take $$$3$$$ remaining green grapes and $$$3$$$ purple grapes, and Michal will take $$$2$$$ out of $$$3$$$ available black grapes.In the second test, there is no possible distribution, since Andrew is not be able to eat enough green grapes. :(

package main

import (
	"fmt"
)

func main() {
	var x, y, z, a, b, c, res int

	fmt.Scanln(&x, &y, &z)
	fmt.Scanln(&a, &b, &c)

	if a >= x {
		a = a - x
		if a+b >= y {
			a = a - y
			if a+b+c >= z {
				res = 1
			} else {
				res = 2
			}
		} else {
			res = 2
		}
	} else {
		res = 2
	}
	if res == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}

package main

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

func main() {
	var x, y, z, a, b, c int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &x, &y, &z, &a, &b, &c)
	ans := findAns(x, y, z, a, b, c)
	fmt.Println(ans)
}

func findAns(x, y, z, a, b, c int) string {
	if x > a {
		return "NO"
	}
	a = a - x
	if y > a+b {
		return "NO"
	}
	if y+z > a+b+c {
		return "NO"
	}
	return "YES"
}

package main

import "fmt"

func main() {
	var x, y, z, a, b, c int
	fmt.Scan(&x, &y, &z, &a, &b, &c)
	if a >= x && a+b >= x+y && a+b+c >= x+y+z {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import (
 "fmt"
)

func main() {
    var x,y,z,a,b,c int;
    fmt.Scan(&x,&y,&z,&a,&b,&c);
		y += x; b+= a;
		z += y; c+= b;
		if a >= x && b >= y && c>=z {
			fmt.Println("YES");
		} else {
			fmt.Println("NO");
		}
}

package main

import "fmt"

func main() {
	var adr, dmt, mcl int
	fmt.Scan(&adr, &dmt, &mcl)

	var g, p, b int
	fmt.Scan(&g, &p, &b)

	g -= adr
	p = p + g - dmt
	b = b + p - mcl

	if g < 0 || p < 0 || b < 0 {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")

}

package main

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

func main() {
	defer out.Flush()
	var x, y, z, g, p, b int
	for hasNext() {
		scan(&x, &y, &z, &g, &p, &b)
		if x > g || y > g+p-x || z > g+p+b-x-y {
			println("NO")
		} else {
			println("YES")
		}
	}
}

// Fast IO Template
var in, out = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(out, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(out, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(out, a...) }
func scan(a ...interface{})             { fmt.Fscan(in, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(in, f, a...) }
func scanln(a ...interface{})           { fmt.Fscanln(in, a...) }
func hasNext() bool {
	for b, _ := in.Peek(1); len(b) > 0 && (b[0] == 10 || b[0] == 13); b, _ = in.Peek(1) {
		in.Discard(1)
	}
	b, _ := in.Peek(1)
	return len(b) == 1
}

package main

import (
	"fmt"
	"io"
)

func main() {
	var x, y, z, g, p, b int
	for {
		if _, err := fmt.Scan(&x, &y, &z, &g, &p, &b); err == io.EOF {
			break
		}
		if x > g || y > g+p-x || z > g+p+b-x-y {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}

package main

import "fmt"

func main() {
	var x, y, z int32 = 0, 0, 0
	var a, b, c int32 = 0, 0, 0
	fmt.Scanf("%d %d %d\n", &x, &y, &z)
	fmt.Scanf("%d %d %d", &a, &b, &c)
	if x <= a && y <= a-x+b && z <= a+b+c-x-y {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}
}

package main

import "fmt"

func main() {
	var x, y, z, a, b, c int32
	fmt.Scanf("%d %d %d\n", &x, &y, &z)
	fmt.Scanf("%d %d %d", &a, &b, &c)

	if (a < x) || (a+b < x+y) || (a+b+c < x+y+z) {
		fmt.Printf("NO\n")
		return
	}
	fmt.Printf("YES\n")
	return
}

package main

import "fmt"

func eval(a, d, m, g, p, b int) bool {
	if a > g {
		return false
	}
	g -= a
	if d > (g + p) {
		return false
	}
	rest := g + p - d
	if m > (rest + b) {
		return false
	}
	return true
}

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

	var g, p, b int
	fmt.Scanf("%d %d %d\n", &g, &p, &b)

	if eval(a, d, m, g, p, b) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import (
    "fmt"
)

func check(x, y, z, a, b, c int) bool {
    if a < x {
        return false
    }
    if c > z {
        return x+y <= a+b
    }
    return x+y+z <= a+b+c
}

func main() {
    var x, y, z, a, b, c int
    for {
        _, err := fmt.Scanf("%d %d %d\n%d %d %d", &x, &y, &z, &a, &b, &c)
        if err != nil {
            return
        }
        if check(x, y, z, a, b, c) {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	tmp := readInt64Slice(reader, 3)
	x, y, z := tmp[0], tmp[1], tmp[2]
	tmp = readInt64Slice(reader, 3)
	a, b, c := tmp[0], tmp[1], tmp[2]
	a -= x
	if a < 0 {
		fmt.Println("NO")
		os.Exit(0)
	}
	b += a
	b -= y
	if b < 0 {
		fmt.Println("NO")
		os.Exit(0)
	}
	c += b
	c -= z
	if c < 0 {
		fmt.Println("NO")
		os.Exit(0)
	}
	fmt.Println("YES")
}

func readOneInt64(r *bufio.Reader) (n int64) {
	bytes, _ := r.ReadBytes('\n')
	n, _ = strconv.ParseInt(string(bytes[:len(bytes)-2]), 10, 64)
	return
}

func readInt64Slice(r *bufio.Reader, n int) (slice []int64) {
	var bytes []byte
	slice = make([]int64, n)
	n--
	for i := 0; i < n; i++ {
		bytes, _ = r.ReadBytes(' ')
		slice[i], _ = strconv.ParseInt(string(bytes[:len(bytes)-1]), 10, 64)
	}
	slice[n] = readOneInt64(r)
	return
}

func readOneString(r *bufio.Reader) []byte {
	bytes, _ := r.ReadBytes('\n')
	return bytes[:len(bytes)-2]
}

package main

import "fmt"

func main() {
	var x, y, z, a, b, c int32
	fmt.Scan(&x, &y, &z, &a, &b, &c)
	var answer string = "YES"
	if a -= x; a < 0 {
		answer = "NO"
	}
	if b = a + b - y; b < 0 {
		answer = "NO"
	}
	if c = b + c - z; c < 0 {
		answer = "NO"
	}
	fmt.Printf("%v", answer)
}

package main

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

func main() {
	sc := NewScanner()
	A, B, C := sc.NextInt(), sc.NextInt(), sc.NextInt()
	X, Y, Z := sc.NextInt(), sc.NextInt(), sc.NextInt()

	X -= A
	if X < 0 {
		fmt.Println("NO")
		return
	}

	if B < X {
		X -= B
		B = 0
	} else {
		B -= X
		X = 0
	}
	if B < Y {
		Y -= B
		B = 0
	} else {
		B -= Y
		Y = 0
	}
	if B > 0 {
		fmt.Println("NO")
		return
	}

	if C > X+Y+Z {
		fmt.Println("NO")
		return
	}
	fmt.Println("YES")

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
}

func scanString() string {
	scanner.Scan()
	return scanner.Text()
}

func scanBytes() []byte {
	scanner.Scan()
	return scanner.Bytes()
}

func scanInt64() int64 {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v
}

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

func scanInts(n int) []int {
	l := make([]int, n)
	for i := 0; i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.Atoi(scanner.Text())
	}

	return l
}

func scanInts64(n int64) []int64 {
	l := make([]int64, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		l[i], _ = strconv.ParseInt(scanner.Text(), 10, 64)
	}

	return l
}

func scanBool() bool {
	scanner.Scan()
	v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return v == 1
}

func scanBools(n int64) []bool {
	l := make([]bool, n)
	for i := int64(0); i < n; i++ {
		scanner.Scan()
		v, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		l[i] = v == 1
	}

	return l
}

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

type ByAge []int

func (a ByAge) Len() int           { return len(a) }
func (a ByAge) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByAge) Less(i, j int) bool { return a[i] > a[j] }

var glasn = map[byte]bool{
	'a': true,
	'e': true,
	'i': true,
	'o': true,
	'u': true,
}

func main() {
	x, y, z := scanInt(), scanInt(), scanInt()
	a, b, c := scanInt(), scanInt(), scanInt()

	if a < x {
		fmt.Println("NO")
		return
	}

	a -= x

	if a+b < y {
		fmt.Println("NO")
		return
	}

	left := (a + b - y) + c

	if left < z {
		fmt.Println("NO")
		return
	}

	fmt.Println("YES")
}

func skipZero(a []uint64) []uint64 {
	for len(a) > 0 && a[0] == 0 {
		a = a[1:]
	}

	return a
}

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

	return -a
}

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

	return b
}

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

	return b
}

package main

import "fmt"

func solve(x int, y int, z int, a int, b int, c int) int {
	if x > a || x+y > a+b || x+y+z > a+b+c {
		return 1
	}
	return 0
}

func main() {
	var x, y, z, a, b, c int
	fmt.Scan(&x, &y, &z, &a, &b, &c)
	var ans int
	ans = solve(x, y, z, a, b, c)
	fmt.Println([]string{"YES", "NO"}[ans])
}

package main

import "fmt"

func solve(x int, y int, z int, a int, b int, c int) int {
  if a >= x && a+b >= x+y && a+b+c >= x+y+z {
    return 1
  }
  return 0
}

func main() {
	var x, y, z, a, b, c int
	fmt.Scan(&x, &y, &z, &a, &b, &c)
  if solve(x, y, z, a, b, c) == 1 {
    fmt.Println("YES")
	} else {
    fmt.Println("NO")
	}
}

package main

import "fmt"

func main() {
	var x, y, z, a, b, c int32
	fmt.Scanf("%d %d %d\n", x, y, z)
	fmt.Scanf("%d %d %d", a, b, c)
	if (a < x) || (a+b < x+y) || (a+b+c < x+y+z) {
		fmt.Printf("NO")
		return
	}
	fmt.Printf("YES")
	return
}

package main

import (
    "fmt"
)

func check(x, y, z, a, b, c int) bool {
    if a < x {
        return false
    }
    if c < z {
        return x+y <= a+b
    }
    return x+y+z <= a+b+c
}

func main() {
    var x, y, z, a, b, c int
    for {
        _, err := fmt.Scanf("%d %d %d\n%d %d %d", &x, &y, &z, &a, &b, &c)
        if err != nil {
            return
        }
        if check(x, y, z, a, b, c) {
            fmt.Println("YES")
        } else {
            fmt.Println("NO")
        }
    }
}

package main

import "fmt"

func solve(x int, y int, z int, a int, b int, c int) int {
  if a >= x {
    return 0
  }
  if a+b >= x+y {
    return 0
  }
  if a+b+c >= x+y+z {
    return 0
  }
  return 1
}

func main() {
	var x, y, z, a, b, c int
	fmt.Scan(&x, &y, &z, &a, &b, &c)
	if solve(x,y,z,a,b,c) == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

func solve(x int, y int, z int, a int, b int, c int) int {
  if a >= x || a+b >= x+y || a+b+c >= x+y+z {
    return 0
  }
  return 1
}

func main() {
	var x, y, z, a, b, c int
	fmt.Scan(&x, &y, &z, &a, &b, &c)
	if solve(x,y,z,a,b,c) == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

import "fmt"

func solve(x int, y int, z int, a int, b int, c int) int {
  if a >= x || a+b >= x+y || a+b+c >= x+y+z {
    return 0
  }
  return 1
}

func main() {
	var x, y, z, a, b, c int
	fmt.Scan(&x, &y, &z, &a, &b, &c)
  if solve(x, y, z, a, b, c) == 1 {
    fmt.Println("YES")
	} else {
    fmt.Println("NO")
	}
}

package main

import "fmt"

func solve(x int, y int, z int, a int, b int, c int) int {
  if a >= x || a+b >= x+y || a+b+c >= x+y+z {
    return 1
  }
  return 0
}

func main() {
	var x, y, z, a, b, c int
	fmt.Scan(&x, &y, &z, &a, &b, &c)
	if solve(x,y,z,a,b,c) == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Johnny has a younger sister Anne, who is very clever and smart. As she came home from the kindergarten, she told his brother about the task that her kindergartener asked her to solve. The task was just to construct a triangle out of four sticks of different colours. Naturally, one of the sticks is extra. It is not allowed to break the sticks or use their partial length. Anne has perfectly solved this task, now she is asking Johnny to do the same.The boy answered that he would cope with it without any difficulty. However, after a while he found out that different tricky things can occur. It can happen that it is impossible to construct a triangle of a positive area, but it is possible to construct a degenerate triangle. It can be so, that it is impossible to construct a degenerate triangle even. As Johnny is very lazy, he does not want to consider such a big amount of cases, he asks you to help him.

The first line of the input contains four space-separated positive integer numbers not exceeding 100 — lengthes of the sticks.

Output TRIANGLE if it is possible to construct a non-degenerate triangle. Output SEGMENT if the first case cannot take place and it is possible to construct a degenerate triangle. Output IMPOSSIBLE if it is impossible to construct any triangle. Remember that you are to use three sticks. It is not allowed to break the sticks or use their partial length.

package main

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

var cs map[int]int = make(map[int]int)

func Init() {}
func Solve(io *FastIO) {
	a := io.NextIntArray(4)
	var b []int
	res := float64(0)
	for i := range a {
		b = make([]int, 0)
		for j := range a {
			if j != i {
				b = append(b, a[j])
			}
		}
		res = math.Max(check(b[0], b[1], b[2], 0), res)
	}
	switch int(res) {
	case 0:
		io.Println("IMPOSSIBLE")
	case 1:
		io.Println("SEGMENT")
	case 2:
		io.Println("TRIANGLE")
	}
}
func check(a, b, c, co int) float64 {
	if co > 2 {
		return float64(2)
	}
	s := b + c
	var res float64
	if s == a {
		res = float64(1)
	} else if s > a {
		res = check(b, c, a, co+1)
	} else {
		res = float64(0)
	}
	return res
}

type FastIO struct {
	//by megaspazz
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}
func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = res*10 + int(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = int64(-1)
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = res*10 + int64(c-'0')
		c = io.NextChar()
	}
	return res * sgn
}
func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}
func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextInt()
	}
	return arr
}
func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}
func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size+offset)
	for i := 0; i < size; i++ {
		arr[i+offset] = io.NextLong()
	}
	return arr
}
func (io *FastIO) NextString() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}
func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}
func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}
func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}
func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}
func IsLineBreakChar(c byte) bool {
	switch c {
	case 0, '\n', '\r':
		return true
	default:
		return false
	}
}
func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}
	Init()
	Solve(&io)
	io.FlushOutput()
}

package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var a, b, c, d int

	fmt.Fscanf(reader, "%d %d %d %d", &a, &b, &c, &d)

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

	if a+b > c || b+c > d {
		fmt.Printf("TRIANGLE")
	} else if a+b == c || b+c == d {
		fmt.Printf("SEGMENT")
	} else {
		fmt.Printf("IMPOSSIBLE")
	}

}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var numbers = make([]int, 4)
	fmt.Scan(&numbers[0], &numbers[1], &numbers[2], &numbers[3])
	sort.Ints(numbers)
	if numbers[2] < (numbers[0]+numbers[1]) || numbers[3] < (numbers[2]+numbers[1]) {
		fmt.Println("TRIANGLE")
	} else if numbers[2] == (numbers[0]+numbers[1]) || numbers[3] == (numbers[2]+numbers[1]) {
		fmt.Println("SEGMENT")
	} else {
		fmt.Println("IMPOSSIBLE")
	}

}

package main

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

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

	A := readNNums(reader, 4)

	fmt.Println(solve(A))
}

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

func solve(A []int) string {
	sort.Ints(A)

	if A[3] < A[2]+A[1] {
		return "TRIANGLE"
	}
	if A[2] < A[0]+A[1] {
		return "TRIANGLE"
	}

	if A[3] == A[1]+A[2] || A[3] == A[0]+A[1] || A[3] == A[0]+A[2] || A[2] == A[0]+A[1] {
		return "SEGMENT"
	}

	return "IMPOSSIBLE"
}

package main
import (
	"fmt"
	"sort"
)
func main() {
	v:=make([]int,4)
	for i:=0;i<4;i++ {
		fmt.Scan(&v[i])
	}
	sort.Ints(v)
	if v[0]+v[1]>v[2] || v[1]+v[2]>v[3] {
		fmt.Println("TRIANGLE")
	} else if v[0]+v[1]==v[2] || v[1]+v[2]==v[3] {
		fmt.Println("SEGMENT")
	} else {
		fmt.Println("IMPOSSIBLE")
	}

}

//
// What we need to do is apply "Heron's Formula" for the area
// of a triangle with known length of sides.
//
// For convience, compute half perimeter:
// s = (a + b + c) / 2
//
// Then A = sqrt(s * (s - a) * (s - b) (s - c))
//
// If A is imaginary, the sides aren't longth enough to form
// a triangle. If A is zero, it forms a degenerate triangle
//
// A degenerate triangle is one where len(AB) + len(BC) = len(AC)
//
package main

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

func solve() {
	a := float64(readInt())
	b := float64(readInt())
	c := float64(readInt())
	d := float64(readInt())

	combs := [...]float64{a, b, c, d}
	degenerate := false

	eps := 0.0001
	for i, va := range combs {
		for j := i + 1; j < len(combs); j++ {
			vb := combs[j]
			for k := j + 1; k < len(combs); k++ {
				vc := combs[k]
				a = area(va, vb, vc)

				if a > eps {
					fmt.Println("TRIANGLE")
					return
				}
				if math.Abs(a) < eps {
					degenerate = true
				}
			}
		}
	}

	if degenerate {
		fmt.Println("SEGMENT")
		return
	}
	fmt.Println("IMPOSSIBLE")
}

func area(a, b, c float64) float64 {
	neg := false

	s := (a + b + c) / 2.0
	area := s * (s - a) * (s - b) * (s - c)

	if area < 0 {
		neg = true
		area = -area
	}

	area = math.Sqrt(area)

	if neg {
		area = -area
	}
	return area
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

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

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

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

package main
import "fmt"

func max3(x, y, z int) (int, bool){
	if (x >= y) && (x >= z) && ((x - y - z) <= 0){
		return x - y - z, true
	}else if (y >= x) && (y >= z) && ((y - x - z) <= 0){
		return y - x - z, true
	}else if (z>=y)&&(z >= x)&&((z-y-x) <= 0){
		return z-y-x, true
	}else{
		return 0, false
	}
}

func main() {
	sticks := make([]int, 4)
	fmt.Scan(&sticks[0], &sticks[1], &sticks[2], &sticks[3])
	ans := "IMPOSSIBLE"
	for i := 0; i < 4; i++{
		if c, ok:= max3(sticks[i%4], sticks[(i+1)%4], sticks[(i+2)%4]); (c < 0) && ok {
			ans = "TRIANGLE"
			break
		}else if (c == 0) && ok{
			ans = "SEGMENT"
		}
	}

	fmt.Print(ans)
}

//http://codeforces.com/contest/6/problem/A
//A. Triangle

package main

import (
	"fmt"
)

func isTri(a, b, c int32) int32 {
	if a > c {
		c, a = a, c
	}
	if c < b {
		c, b = b, c
	}
	if b < a {
		b, a = a, b
	}
	if a+b > c {
		return 1
	}
	if a+b == c {
		return 0
	}
	return -1
}

func main() {
	var (
		res, t, a, b, c, d int32
	)

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&d)
	res = isTri(a, b, c)
	t = isTri(a, b, d)
	if t > res {
		res = t
	}
	t = isTri(a, c, d)
	if t > res {
		res = t
	}
	t = isTri(b, c, d)
	if t > res {
		res = t
	}

	if res > 0 {
		fmt.Println("TRIANGLE")
		return
	}
	if res < 0 {
		fmt.Println("IMPOSSIBLE")
		return
	}
	fmt.Println("SEGMENT")

}

package main

import (
	"fmt"
)

func main() {
	var l [4]int
	if _, err := fmt.Scanf("%d %d %d %d\n", &l[0], &l[1], &l[2], &l[3]); err != nil {
		return
	}

	segment := false

	var t [3]int
	for i := 0; i < 4; i++ {
		k := 0
		for j := 0; j < 4; j++ {
			if j != i {
				t[k] = l[j]
				k++
			}
		}
		s := triangle(t)
		if s == 1 { // triangle
			fmt.Println("TRIANGLE")
			return
		} else if s == 2 { // Degenerate triangle
			segment = true
		}
	}

	if segment {
		fmt.Println("SEGMENT")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

func triangle(t [3]int) int {
	sum := 0
	max := 0
	for i := 0; i < 3; i++ {
		sum += t[i]
		if t[i] > max {
			max = t[i]
		}
	}

	if sum-max == max {
		return 2
	} else if sum-max > max {
		return 1
	} else {
		return 0
	}
}

package main

import "fmt"

func f(a,b,c int) int {
    if ((a+b) > c) && ((a+c) > b) && ((b+c) > a) {
        return 2
    } else if ((a+b) >= c) && ((a+c) >= b) && ((b+c) >= a) {
        return 1
    } else {
        return 0
    }
}

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

func main() {
    var a,b,c,d int
    fmt.Scan(&a,&b,&c,&d)
    ans := max(f(a,b,c),f(a,b,d),f(a,c,d),f(b,c,d))
    if ans == 2 {
        fmt.Println("TRIANGLE")
    } else if ans == 1 {
        fmt.Println("SEGMENT")
    } else {
        fmt.Println("IMPOSSIBLE")
    }
}

package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"sort"
	"strconv"
	"strings"
	"text/scanner"
)

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

func main() {
	var inputs []int

	inputs = make([]int, 4)

	dat, err := ioutil.ReadAll(os.Stdin)
	check(err)
	var str_data string = string(dat);

	reader := strings.NewReader(str_data)

	var scn scanner.Scanner
	scn.Init(reader)

    scn.Scan()
	var text string = scn.TokenText();

	inputs[0], err = strconv.Atoi(text)
	check(err)

	scn.Scan()
	text = scn.TokenText();

	inputs[1], err = strconv.Atoi(text)
	check(err)

	scn.Scan()
	text = scn.TokenText();

	inputs[2], err = strconv.Atoi(text)
	check(err)

	scn.Scan()
	text = scn.TokenText();

	inputs[3], err = strconv.Atoi(text)
	check(err)

	sort.Ints(inputs)

	// first check to see if you can make a triangle with first input
	// otherwise, check for degenerate case
	if inputs[0] + inputs[1] > inputs[2] ||
	   inputs[0] + inputs[2] > inputs[3] ||
	   inputs[1] + inputs[2] > inputs[3] {
		fmt.Print("TRIANGLE")
	} else if inputs[0] + inputs[1] == inputs[2] ||
	   inputs[0] + inputs[2] == inputs[3] ||
	   inputs[1] + inputs[2] == inputs[3] {
	   	fmt.Print("SEGMENT")
	} else {
		fmt.Print("IMPOSSIBLE")
	}

}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var l1, l2, l3, l4 int

	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d %d %d %d", &l1, &l2, &l3, &l4)

		lines := [4]int{l1, l2, l3, l4}

		degenerate := false
		for i := 0; i < 4; i++ {
			for j := i + 1; j < 4; j++ {
				for k := j + 1; k < 4; k++ {
					if lines[i]+lines[j] > lines[k] &&
						lines[i]+lines[k] > lines[j] &&
						lines[j]+lines[k] > lines[i] {
						fmt.Println("TRIANGLE")
						return
					}
					if lines[i]+lines[j] == lines[k] ||
						lines[i]+lines[k] == lines[j] ||
						lines[j]+lines[k] == lines[i] {
						degenerate = true
					}
				}
			}
		}

		if degenerate {
			fmt.Println("SEGMENT")
		} else {
			fmt.Println("IMPOSSIBLE")
		}
	}
}

package main

import "fmt"
import "sort"

func triangle(L []int, diff int) bool {
	for i := 0; i < 4; i++ {
		for j := i + 1; j < 4; j++ {
			for k := j + 1; k < 4; k++ {
				if (L[i] + L[j] - L[k]) >= diff {
					return true
				}
			}
		}
	}
	return false
}

func main() {
	var L = make([]int, 4)
	_, _ = fmt.Scanf("%d %d %d %d", &L[0], &L[1], &L[2], &L[3])
	sort.Ints(L)
	if triangle(L, 1) {
		fmt.Println("TRIANGLE")
	} else if triangle(L, 0) {
		fmt.Println("SEGMENT")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

package main

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

var inf int = 0x3f3f3f3f
var reader *bufio.Reader

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

var n int
var a [4]int

func main() {
	n = 4
	for i := 0; i < 4; i++ {
		fmt.Fscan(reader, &a[i])
	}
	sort.Sort(sort.IntSlice(a[:]))
	if a[0]+a[1] > a[2] || a[1]+a[2] > a[3] {
		fmt.Println("TRIANGLE")
		return
	}
	if a[0]+a[1] == a[2] || a[1]+a[2] == a[3] {
		fmt.Println("SEGMENT")
		return
	}
	fmt.Println("IMPOSSIBLE")
}

package main

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

func main() {
	l := make([]int, 4)
	for i := 0; i < 4; i++ {
		l[i] = nextInt()
	}
	sort.Ints(l)
	triangle, segment := l[0] + l[1] > l[2] || l[1] + l[2] > l[3], l[0] + l[1] == l[2] || l[1] + l[2] == l[3]

	if triangle {
		printf("TRIANGLE\n")
	} else if segment {
		printf("SEGMENT")
	} else {
		printf("IMPOSSIBLE")
	}
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

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

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}

// 6A-mic
package main

import (
    "fmt"
    "sort"
)

func main() {
    l := make([]int, 4)
    fmt.Scan(&l[0], &l[1], &l[2], &l[3])
    sort.Sort(sort.IntSlice(l))
    if l[0]+l[1] > l[2] || l[1]+l[2] > l[3] {
        fmt.Println("TRIANGLE")
    } else if l[0]+l[1] == l[2] || l[1]+l[2] == l[3] {
        fmt.Println("SEGMENT")
    } else {
        fmt.Println("IMPOSSIBLE")
    }

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _, _ := reader.ReadLine()

	val := strings.Split(string(text), " ")
	var val2 [4]int64

	var val3 = make([]int, 4, 4)

	val2[0], _ = strconv.ParseInt(val[0], 10, 0)
	val2[1], _ = strconv.ParseInt(val[1], 10, 0)
	val2[2], _ = strconv.ParseInt(val[2], 10, 0)
	val2[3], _ = strconv.ParseInt(val[3], 10, 0)
	val3[0] = int(val2[0])
	val3[1] = int(val2[1])
	val3[2] = int(val2[2])
	val3[3] = int(val2[3])

	sort.Ints(val3)

	if val3[3] < val3[2]+val3[1] || val3[2] < val3[1]+val3[0] {
		fmt.Println("TRIANGLE")
	} else if val3[3] == val3[2]+val3[1] || val3[2] == val3[1]+val3[0] {
		fmt.Println("SEGMENT")
	} else {
		fmt.Println("IMPOSSIBLE")
	}

}

package main
import "fmt"

func max3(x, y, z int) (int, bool){
	if (x > y) && (x > z) && ((x - y - z) <= 0){
		return x - y - z, true
	}else if (y > x) && (y > z) && ((y - x - z) <= 0){
		return y - x - z, true
	}else if (z>y)&&(z > x)&&((z-y-x) <= 0){
		return z-y-x, true
	}else{
		return 0, false
	}
}

func main() {
	sticks := make([]int, 4)
	fmt.Scan(&sticks[0], &sticks[1], &sticks[2], &sticks[3])
	ans := "IMPOSSIBLE"
	for i := 0; i < 4; i++{
		if c, ok:= max3(sticks[i%4], sticks[(i+1)%4], sticks[(i+2)%4]); (c < 0) && ok {
			ans = "TRIANGLE"
			break
		}else if (c == 0) && ok{
			ans = "SEGMENT"
		}
	}

	fmt.Print(ans)
}

package main

import (
	"fmt"
)

func main() {
	var l [4]int
	if _, err := fmt.Scanf("%d %d %d %d\n", &l[0], &l[1], &l[2], &l[3]); err != nil {
		return
	}

	segment := false

	var t [3]int
	for i := 0; i < 4; i++ {
		k := 0
		for j := 0; j < 4; j++ {
			if j != i {
				t[k] = l[j]
				k++
			}
		}
		s := traingle(t)
		if s == 1 { // Traingle
			fmt.Println("TRAINGLE")
			return
		} else if s == 2 { // Degenerate Traingle
			segment = true
		}
	}

	if segment {
		fmt.Println("SEGMENT")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

func traingle(t [3]int) int {
	sum := 0
	max := 0
	for i := 0; i < 3; i++ {
		sum += t[i]
		if t[i] > max {
			max = t[i]
		}
	}

	if sum-max == max {
		return 2
	} else if sum-max > max {
		return 1
	} else {
		return 0
	}
}


Tarly has two different type of items, food boxes and wine barrels. There are f food boxes and w wine barrels. Tarly stores them in various stacks and each stack can consist of either food boxes or wine barrels but not both. The stacks are placed in a line such that no two stacks of food boxes are together and no two stacks of wine barrels are together.The height of a stack is defined as the number of items in the stack. Two stacks are considered different if either their heights are different or one of them contains food and other contains wine.Jon Snow doesn't like an arrangement if any stack of wine barrels has height less than or equal to h. What is the probability that Jon Snow will like the arrangement if all arrangement are equiprobably?Two arrangement of stacks are considered different if exists such i, that i-th stack of one arrangement is different from the i-th stack of the other arrangement.

The first line of input contains three integers f, w, h (0 ≤ f, w, h ≤ 105) — number of food boxes, number of wine barrels and h is as described above. It is guaranteed that he has at least one food box or at least one wine barrel.

Output the probability that Jon Snow will like the arrangement. The probability is of the form , then you need to output a single integer p·q - 1 mod (109 + 7).

NoteIn the first example f  =  1, w = 1 and h = 1, there are only two possible arrangement of stacks and Jon Snow doesn't like any of them.In the second example f = 1, w = 2 and h = 1, there are three arrangements. Jon Snow likes the (1) and (3) arrangement. So the probabilty is .

package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return int(int64(a) * int64(b) % n)
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	h += 1
	if a == 0 {
		return 1
	}
	if b == 0 {
		if a >= h {
			return 1
		}
		return 0
	}
	p := 0
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b - 1, kb - 1)
			c1 := cnk(a - ka * (h - 1) - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}

package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return int(int64(a) * int64(b) % n)
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	h += 1
	if a == 0 {
		return 1
	}
	if b == 0 {
		if a >= h {
			return 1
		}
		return 0
	}
	p := 0
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b - 1, kb - 1)
			c1 := cnk(a - ka * (h - 1) - 1, ka - 1)
			fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}

package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return a * b % n
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	h += 1
	if a == 0 {
		return 1
	}
	if b == 0 {
		if a >= h {
			return 1
		}
		return 0
	}
	p := 0
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b - 1, kb - 1)
			c1 := cnk(a - ka * (h - 1) - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}

package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return a * b % n
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	p, q := 1, 1
	for i := 0; i < k; i++ {
		p = mul(p, n - i)
		q = mul(q, i + 1)
	}
	return mul(p, inv(q))
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	p := 0
	h += 1
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b + kb - 1, kb - 1)
			c1 := cnk(a - ka * h + ka - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}

package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return a * b % n
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	p := 0
	h += 1
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b + kb - 1, kb - 1)
			c1 := cnk(a - ka * h + ka - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}

package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return a * b % n
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	p := 0
	h += 1
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b - 1, kb - 1)
			c1 := cnk(a - ka * (h - 1) - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}


Calendars in widespread use today include the Gregorian calendar, which is the de facto international standard, and is used almost everywhere in the world for civil purposes. The Gregorian reform modified the Julian calendar's scheme of leap years as follows: Every year that is exactly divisible by four is a leap year, except for years that are exactly divisible by 100; the centurial years that are exactly divisible by 400 are still leap years. For example, the year 1900 is not a leap year; the year 2000 is a leap year.   In this problem, you have been given two dates and your task is to calculate how many days are between them. Note, that leap years have unusual number of days in February.Look at the sample to understand what borders are included in the aswer.

The first two lines contain two dates, each date is in the format yyyy:mm:dd (1900 ≤ yyyy ≤ 2038 and yyyy:mm:dd is a legal date).

Print a single integer — the answer to the problem.

package main

import (
	"bufio"
	"os"
	"strconv"
	"time"
	"unicode/utf8"
)

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
	var ans, fst int = 0, 0
	var neg bool = false
	sc.Scan()
	if sc.Bytes()[0] == minus {
		fst = 1
		neg = true
	}
	for _, j := range sc.Bytes()[fst:] {
		ans = ans*10 + int(j-zero)
	}
	if neg == true {
		ans = -ans
	}
	return ans
}

func printInt(n int) {
	w.WriteString(strconv.Itoa(n) + " ")
}

//two functions from go source:
func isSpace(r rune) bool {
	if r <= '\u00FF' {
		// Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs.
		switch r {
		case ' ', '\t', '\n', '\v', '\f', '\r', ':':
			return true
		case '\u0085', '\u00A0':
			return true
		}
		return false
	}
	// High-valued ones.
	if '\u2000' <= r && r <= '\u200a' {
		return true
	}
	switch r {
	case '\u1680', '\u180e', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000':
		return true
	}
	return false
}

func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// Skip leading spaces.
	start := 0
	for width := 0; start < len(data); start += width {
		var r rune
		r, width = utf8.DecodeRune(data[start:])
		if !isSpace(r) {
			break
		}
	}
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	// Scan until space, marking end of word.
	for width, i := 0, start; i < len(data); i += width {
		var r rune
		r, width = utf8.DecodeRune(data[i:])
		if isSpace(r) {
			return i + width, data[start:i], nil
		}
	}
	// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	// Request more data.
	return 0, nil, nil
}

func main() {

	w = bufio.NewWriter(os.Stdout)
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(ScanWords)
	tyme1, tyme2 := time.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC),
		time.Date(nextInt(), time.Month(nextInt()), nextInt(), 0, 0, 0, 0, time.UTC)
	ans := int(tyme2.Sub(tyme1).Hours() / 24)
	if ans < 0 {
		ans = -ans
	}
	printInt(ans)
	w.Flush()
	//YOU FORGOT TO FLUSH!
}