package main

import (
	_ "bufio"
	"fmt"
)

/*
// scanf tutorial
func main() {
	// reader
	//reader := bufio.NewReader(io.reader)
	fmt.Println("reading input")
	var (
		t int
		p int
		q string
		r bool
		//s []int
	)
	fmt.Scanf("%d\n", &t)
	fmt.Printf("t is %d\n", t)
	for i := 0; i < t; i++ {
		//fmt.Printf("true")
		fmt.Scanf("%d %s %t\n", &p, &q, &r)
		fmt.Printf("entered %T is %v\nentered %T is %v\nentered %T is %v\n", p, p, q, q, r, r)
	}
	// fmt.Scanf("%d %s %t", &p, &q, &r)
	// fmt.Scanf("%d", &p)
	// fmt.Scanf("%s", &q)
	// fmt.Scanf("%t", &r)
	// fmt.Scanf("%v", &s)

}
*/
func calculate(n, m int) string {
	if n == 1 || m == 1 {
		return "YES"
	}

	if n > 2 || m > 2 {
		return "NO"
	}

	return "YES"
}

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

	for i := 0; i < test; i++ {
		fmt.Scanf("%d %d\n", &n, &m)
		fmt.Println(calculate(n, m))
	}
}

// https://serhatgiydiren.github.io

package main

import "fmt"
import "os"
import "bufio"

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

func solve(test_id int) {
 var n,m int
 fmt.Fscanf(reader, "%d %d\n", &n, &m)
 if n > m {
  n , m = m , n
 }
 if n == 1 || ( n == 2 && m == 2 ) {
  fmt.Fprintf(writer,"YES\n")
 } else {
  fmt.Fprintf(writer,"NO\n")
 }
}

func solve_cases() {
 defer writer.Flush()
 t := 1
 fmt.Fscanf(reader, "%d\n", &t)
 for i := 0 ; i < t ; i++ {
  solve(i)
 }
}

func main() {
 solve_cases()
}

package main

import "fmt"

func main() {
	var n int64
	var result = []bool{}
	fmt.Scanf("%d\n", &n)
	for j := int64(0); j < n; j++ {
		var n1, n2 int64
		fmt.Scanf("%d %d\n", &n1, &n2)
		// fmt.Println(n1, n2)
		bindings := (n2-1)*n1 + (n1-1)*n2
		result = append(result, bindings <= n1*n2)
	}

	for _, rr := range result {
		if rr {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	_ "bufio"
	"fmt"
)

/*
// scanf tutorial
func main() {
	// reader
	//reader := bufio.NewReader(io.reader)
	fmt.Println("reading input")
	var (
		t int
		p int
		q string
		r bool
		//s []int
	)
	fmt.Scanf("%d\n", &t)
	fmt.Printf("t is %d\n", t)
	for i := 0; i < t; i++ {
		//fmt.Printf("true")
		fmt.Scanf("%d %s %t\n", &p, &q, &r)
		fmt.Printf("entered %T is %v\nentered %T is %v\nentered %T is %v\n", p, p, q, q, r, r)
	}
	// fmt.Scanf("%d %s %t", &p, &q, &r)
	// fmt.Scanf("%d", &p)
	// fmt.Scanf("%s", &q)
	// fmt.Scanf("%t", &r)
	// fmt.Scanf("%v", &s)

}
*/

// accepted solution
/*
func calculate(n, m int) string {
	if n == 1 || m == 1 {
		return "YES"
	}

	if n > 2 || m > 2 {
		return "NO"
	}

	return "YES"
}
*/

func calculate(n, m int) string {
	if n*m != 4 && n >= 2 && m >= 2 {
		return "No"
	} else {
		return "YES"
	}
}

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

	for i := 0; i < test; i++ {
		fmt.Scanf("%d %d\n", &n, &m)
		fmt.Println(calculate(n, m))
	}
}

package main

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

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

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

	for i := 0; i < t; i++ {
		var n, m int
		fmt.Fscan(r, &n, &m)
		if (n == 2 && m == 2) || n == 1 || m == 1 {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextUInt64() uint64 {
	impl.Scan()
	bb := impl.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

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

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

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

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n, m := reader.NextInt64(), reader.NextInt64()
		if n == 1 || m == 1 || (n == 2 && m == 2) {
			writer.Printf("YES\n")
		} else {
			writer.Printf("NO\n")
		}
	}
}

package main

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

func main() {
	var t, x, y int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &x, &y)
		if x == 1 || y == 1 || (x == 2 && y == 2) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    ts, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(ts))
	for i := 0; i < t; i++ {
		inp, _ := reader.ReadString('\n')
		s := strings.Split(inp, " ")
		ns, ms := strings.TrimSpace(s[0]), strings.TrimSpace(s[1])
		n, _ := strconv.Atoi(ns)
		m, _ := strconv.Atoi(ms)
		if n == 1 || m == 1 || (n == 2 && m == 2) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

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

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

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)
	T := NextInt()

	for t := 0; t < T; t++ {
		n, m := NextInt(), NextInt()
		if n == 1 || m == 1 {
			fmt.Fprintln(out, "YES")
			continue
		}
		if n > 2 || m > 2 {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
	}

}

// https://codeforces.com/contest/1345/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n, m int64
	fmt.Fscan(input, &n, &m)
	if n == 1 || m == 1 {
		fmt.Println("YES")
		return
	}

	if n*m > 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

import "fmt"

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

func main() {
   var a,b, t, i int
   fmt.Scan(&t)
   for i=0;i<t;i++{
   	fmt.Scan(&a,&b)
   	if min(a,b) == 1 || max(a,b) == 2{
   		fmt.Println("Yes")
   	}else{
   		fmt.Println("No")
   	}
   }
}

package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()

	t := scanner.Text()

	testCases, err := strconv.Atoi(t)

	if err != nil {
		panic(err)
	}

	for j := 0; j < int(testCases); j ++ {

		scanner.Scan()

		a := scanner.Text()

		parts := strings.Fields(a)

		n, _ := strconv.Atoi(parts[0])

		m, _ := strconv.Atoi(parts[1])

		res := solve(n, m)

		fmt.Println(res)
	}
}

func solve(n, m int) string {

	if n == 1 || m == 1 {
		return "YES"
	}

	if n >= 3 || m >= 3 {
		return "NO"
	}

	return "YES"
}

/*
URL:
https://codeforces.com/contest/1345/problem/0
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t    int
	n, m int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		n, m = ReadInt2()
		solve(n, m)
	}
}

func solve(n, m int) {
	if n == 1 || m == 1 {
		fmt.Println("YES")
		return
	}

	if n == 2 && m == 2 {
		fmt.Println("YES")
		return
	}

	fmt.Println("NO")
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

func solve() {
	n, m := readInt(), readInt()

	if n == 1 || m == 1 || (n == 2 && m == 2) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func main() {
	k := readInt()
	for i := 0; i < k; i++ {
		solve()
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

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

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

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

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

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}

package main

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

func main() {
	for t := ScanInt(); t > 0; t-- {
		n, m := ScanInt(), ScanInt()
		if solve(n, m) {
			P("YES")
		} else {
			P("NO")
		}
	}

	close(O)
	oWg.Wait()
}
func solve(n, m int) bool {
	if n <= 1 || m <= 1 || (n == 2 && m == 2) {
		return true
	}

	return false
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main
import (
    "fmt"
)
func main() {
    var k,m,n int;
    fmt.Scanf("%d", &k);
    for i := 0;i<k;i++ {
        fmt.Scan(&m, &n);
        if (m == 1 || n == 1 || (m==2 && n==2)) {
            fmt.Printf("YES\n")
        }else{
            fmt.Printf("NO\n")
        }
    }
}

package main

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

func main() {
	var t, n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &n)
		for j := 0; j < n; j++ {
			fmt.Printf("%d ", j+1)
		}
		fmt.Println()
	}
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    ts, _ := reader.ReadString('\n')
	t, _ := strconv.Atoi(strings.TrimSpace(ts))
	for i := 0; i < t; i++ {
		ns, _ := reader.ReadString(' ')
		n, _ := strconv.Atoi(strings.TrimSpace(ns))
		ms, _ := reader.ReadString(' ')
		m, _ := strconv.Atoi(strings.TrimSpace(ms))
		if n == 1 || m == 1 || (n == 2 && m == 2) {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}
func NextInt64() int64 {
	bytes := NextBytes()
	i, err := Atoi64(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func Atoi64(b []byte) (int64, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int64
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int64(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func reverseInts(a []int) {
	for l, r := 0, len(a)-1; l < r; l, r = l+1, r-1 {
		a[l], a[r] = a[r], a[l]
	}
}

func unique(a []int) int {
	newLen := 0
	n := len(a)
	for i := 0; i < n; i++ {
		if newLen == 0 || a[i] != a[newLen-1] {
			a[newLen] = a[i]
			newLen++
		}
	}
	return newLen
}

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

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

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)
	T := NextInt()

	for t := 0; t < T; t++ {
		n, m := NextInt(), NextInt()
		if n == 1 || m == 1 {
			fmt.Fprintln(out, "YES")
			continue
		}
		if n > 2 && m > 2 {
			fmt.Fprintln(out, "NO")
			continue
		}
		fmt.Fprintln(out, "YES")
	}

}

// https://codeforces.com/contest/1345/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n, m int
	fmt.Fscan(input, &n, &m)
	if n == 1 && m == 1 {
		fmt.Println("YES")
		return
	}

	if n*m > 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

// https://codeforces.com/contest/1345/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input io.Reader

func main() {
	var (
		T int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
	var n, m int
	fmt.Fscan(input, &n, &m)
	if n == 1 || m == 1 {
		fmt.Println("YES")
		return
	}

	if n*m > 4 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

import "fmt"

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

func main() {
   var a,b, t, i int
   fmt.Scan(&t)
   for i=0;i<t;i++{
   	fmt.Scan(&a,&b)
   	if min(a,b) == 1 && max(a,b) == 2{
   		fmt.Println("Yes")
   	}else{
   		fmt.Println("No")
   	}
   }
}

package main

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

func main() {
	n, m := readInt(), readInt()

	if n == 1 || m == 1 || (n == 2 && m == 2) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

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

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

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), math.MaxInt32)
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

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

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

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

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

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}

package main

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

func main() {
	for t := ScanInt(); t > 0; t-- {
		n, m := ScanInt(), ScanInt()
		if solve(n, m) {
			P("YES")
		} else {
			P("NO")
		}
	}

	close(O)
	oWg.Wait()
}
func solve(n, m int) bool {
	if n <= 2 || m <= 2 {
		return true
	}

	return false
}

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

var O chan string
var in *bufio.Scanner
var oWg *sync.WaitGroup
var P func(a ...interface{}) (n int, err error)

func init() {
	P = fmt.Println

	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)

	O = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)

	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

		for line := range O {
			writer.WriteString(line + "\n")
		}
	}()
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanInt() int     { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInt64() int64 { i, _ := strconv.ParseInt(ScanWord(), 10, 64); return i }
func ScanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt()
	}
	return arr
}
func ScanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

/*********************** Utils ***********************/

func S(v interface{}) string { return fmt.Sprintf("%v", v) }
func SArr(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func SArr64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func MnMx(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int64) int64 { mn, _ := MnMx(args...); return mn }
func Mx(args ...int64) int64 { _, mx := MnMx(args...); return mx }
func LCM(a, b int64) int64   { return a / GCD(a, b) * b }
func GCD(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main
import (
    "fmt"
)
func main() {
    var k,m,n int;
    fmt.Scanf("%d", &k);
    for i := 0;i<k;i++ {
        fmt.Scanf("%d %d", &m, &n);
        if (m == 1 || n == 1 || (m==2 && n==2)) {
            fmt.Printf("YES\n")
        }else{
            fmt.Printf("NO\n")
        }
    }
}

package main
import (
    "fmt"
)
func main() {
    var k,m,n int;
    fmt.Scanf("%d", &k);
    for i := 0;i<k;i++ {
        fmt.Scanf("%d %d", &m, &n);
        fmt.Print("%d %d\n", m, n);
        if (m == 1 || n == 1 || (m==2 && n==2)) {
            fmt.Printf("YES\n")
        }else{
            fmt.Printf("NO\n")
        }
    }
}

// https://serhatgiydiren.github.io

package main

import "fmt"
import "os"
import "bufio"

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

func solve(test_id int) {
 var n,m int
 fmt.Fscanf(reader, "%d %d\n", &n, &m)
 if n > m {
  n , m = m , n
 }
 if n == 1 {
  fmt.Fprintf(writer,"YES\n")
 } else if n > 2 || m > 5 {
  fmt.Fprintf(writer,"NO\n")
 } else {
  fmt.Fprintf(writer,"YES\n")
 }
}

func solve_cases() {
 defer writer.Flush()
 t := 1
 fmt.Fscanf(reader, "%d\n", &t)
 for i := 0 ; i < t ; i++ {
  solve(i)
 }
}

func main() {
 solve_cases()
}

// https://serhatgiydiren.github.io

package main

import "fmt"
import "os"
import "bufio"

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

func solve(test_id int) {
 var n,m int
 fmt.Fscanf(reader, "%d %d\n", &n, &m)
 if n > m {
  n , m = m , n
 }
 if n > 2 || m > 5 {
  fmt.Fprintf(writer,"NO\n")
 } else {
  fmt.Fprintf(writer,"YES\n")
 }
}

func solve_cases() {
 defer writer.Flush()
 t := 1
 fmt.Fscanf(reader, "%d\n", &t)
 for i := 0 ; i < t ; i++ {
  solve(i)
 }
}

func main() {
 solve_cases()
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanf("%d %d\n", &n1, &n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		if bindings <= n1*n2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d%c", &n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanf("%d %d%c", &n1, &n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		if bindings <= n1*n2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanf("%d %d", &n1, &n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		if bindings <= n1*n2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}

}

package main

import "fmt"

func main() {
	var n int
	var result = []bool{}
	fmt.Scanf("%d\n", &n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanf("%d %d\n", &n1, &n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		result = append(result, bindings <= n1*n2)
	}

	for _, rr := range result {
		if rr {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	var result = []bool{}
	fmt.Scan(&n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanln(&n1, &n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		result = append(result, bindings <= n1*n2)
	}

	for _, rr := range result {
		if rr {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanln(&n1, &n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		if bindings <= n1*n2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var n int64
	var result = []bool{}
	fmt.Scanf("%d\n", &n)
	for j := int64(0); j < n; j++ {
		var n1, n2 int64
		fmt.Scanf("%d %d\n", &n1, &n2)
		fmt.Println(n1, n2)
		bindings := (n2-1)*n1 + (n1-1)*n2
		result = append(result, bindings <= n1*n2)
	}

	for _, rr := range result {
		if rr {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	var result = []bool{}
	fmt.Scanf("%d\n", &n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanf("%d %d\n", &n1, &n2)
		fmt.Println(n1, n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		result = append(result, bindings <= n1*n2)
	}

	for _, rr := range result {
		if rr {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d%n", &n)
	for j := 0; j < n; j++ {
		var n1, n2 int
		fmt.Scanf("%d %d%n", &n1, &n2)
		var bindings = (n2-1)*n1 + (n1-1)*n2
		if bindings <= n1*n2 {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

import (
	_ "bufio"
	"fmt"
)

/*
// scanf tutorial
func main() {
	// reader
	//reader := bufio.NewReader(io.reader)
	fmt.Println("reading input")
	var (
		t int
		p int
		q string
		r bool
		//s []int
	)
	fmt.Scanf("%d\n", &t)
	fmt.Printf("t is %d\n", t)
	for i := 0; i < t; i++ {
		//fmt.Printf("true")
		fmt.Scanf("%d %s %t\n", &p, &q, &r)
		fmt.Printf("entered %T is %v\nentered %T is %v\nentered %T is %v\n", p, p, q, q, r, r)
	}
	// fmt.Scanf("%d %s %t", &p, &q, &r)
	// fmt.Scanf("%d", &p)
	// fmt.Scanf("%s", &q)
	// fmt.Scanf("%t", &r)
	// fmt.Scanf("%v", &s)

}
*/

// accepted solution
/*
func calculate(n, m int) string {
	if n == 1 || m == 1 {
		return "YES"
	}

	if n > 2 || m > 2 {
		return "NO"
	}

	return "YES"
}
*/

func calculate(n, m int) string {
	if n > 2 && m > 2 {
		return "No"
	} else {
		return "YES"
	}
}

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

	for i := 0; i < test; i++ {
		fmt.Scanf("%d %d\n", &n, &m)
		fmt.Println(calculate(n, m))
	}
}

package main

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

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

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

	for i := 0; i < t; i++ {
		var n, m int
		fmt.Fscan(r, &n, &m)
		if n == 2 || n == 1 || m == 2 || m == 1 {
			fmt.Fprintln(w, "YES")
		} else {
			fmt.Fprintln(w, "NO")
		}
	}
}


package main

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

func main(){
	var n int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	a := make([]int, n)
	for i:=0; i<n; i++ {
		r.Scan()
		a[i], _ = strconv.Atoi(r.Text())
	}
	sort.Ints(a)
	prev := a[0]
	for j:=0; j<n; j++ {
		if a[j] != prev {
			w.WriteString(strconv.Itoa(a[j])+"\n")
			w.Flush()
			return
		}
		prev = a[j]
	}
	w.WriteString("NO\n")
	w.Flush()
}

package main

import "fmt"
import "log"

func main() {
	var n int
	nargs, err := fmt.Scan(&n);
	if err != nil {
		log.Fatal(err);
	}
	if nargs != 1 {
		log.Fatal("bad n", nargs);
	}
	if n < 2 {
		fmt.Println("NO");
		return;
	}

	var num, min1, min2 int
	idx := 0;
	for i := 0; i < n; i++ {
		nargs, err = fmt.Scan(&num);
		if err != nil {
			log.Fatal(err);
		}
		if nargs != 1 {
			log.Fatal("bad n", nargs);
		}

		switch idx {
		case 0:
			min1 = num;
			idx++;
			break;
		case 1:
			if num < min1 {
				min2 = min1;
				min1 = num;
				idx++;
			} else if (num > min1) {
				min2 = num;
				idx++;
			}
			break;
		default:
			if num == min1 {
				// Skip it...
				break;
			}
			if num < min1 {
				min2 = min1;
				min1 = num;
			} else if (num < min2) {
				min2 = num;
			}
		}
	}
	if (idx < 2) {
		fmt.Println("NO");
	} else {
		fmt.Println(min2);
	}
}

// asd1
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n int
    var i int
    //min :=1000000000
    fmt.Scan(&n)
    a := make([]int,n)
    for i=0;i<n;i++{
        fmt.Scan(&a[i])
    }
    sort.Ints(a)
    for j:=1;j<n;j++{
        if a[0] != a[j]{
            fmt.Println(a[j])
            return
        }
    }
    fmt.Println("NO")

}

package main

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

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

	number := 0
	if scanner.Scan() {
		line := scanner.Text()

		fmt.Sscanf(line, "%d", &number)
	}

	if scanner.Scan() {
		line := scanner.Text()

		tokens := strings.Fields(line)
		numbers := make(sort.IntSlice, number)

		for i := 0; i < number; i++ {
			numbers[i], _ = strconv.Atoi(tokens[i])
		}

		sort.Sort(numbers)

		for i := 0; i < number; i++ {
			if numbers[i] != numbers[0] {
				fmt.Println(numbers[i])
				return
			}
		}
		fmt.Println("NO")
	}
}

// 22A
package main

import (
	"fmt"
)

func main() {
	var n, i, a int
	var arr [300]int
	sum := 0
	fmt.Scan(&n)
	for i = 0; i < n; i++ {
		fmt.Scan(&a)
		arr[a+100]++
	}
	for i = 0; i < 300; i++ {
		if arr[i] != 0 {
			sum++
		}
		if sum == 2 {
			fmt.Print(i - 100)
			return
		}
	}
	fmt.Println("NO")
	return
}

// 22A-mic
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a []int
	var n, x, i int
	fmt.Scan(&n)
	for i = 1; i <= n; i++ {
		fmt.Scan(&x)
		a = append(a, x)
	}
	if len(a) == 1 {
		goto fail
	}
	sort.Sort(sort.IntSlice(a))
	for i = 1; i < n; i++ {
		if a[0] != a[i] {
			fmt.Println(a[i])
			return
		}
	}
	goto fail
fail:
	{
		fmt.Println("NO")
	}
}

package main

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

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

const Max = 100 + 1

func main() {
        defer w.Flush()

        var n, tmp int
        a, b := Max, Max
        fmt.Fscanf(r, "%d\n", &n)
        for i := 0; i < n; i++ {
                fmt.Fscanf(r, "%d ", &tmp)
                if tmp < a {
                        b = a
                        a = tmp
                } else if tmp < b && tmp != a {
                        b = tmp
                }
        }

        if b == Max {
                fmt.Fprintf(w, "NO")
        } else {
                fmt.Fprintf(w, "%v", b)
        }
}

package main

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

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

	var n, t int
	a, b := 101, 101
	fmt.Fscan(r, &n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &t)
		if i == 0 {
			a = t
		} else {
			if t < a {
				a, b = t, a
			} else if t < b && t != a {
				b = t
			}
		}

	}
	if b == 101{
		fmt.Fprintln(w, "NO")
	} else {
		fmt.Fprintln(w, b)
	}
}

package main

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

func main() {
	b := make([]bool, 201, 201)
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0;i < n; i ++ {
		var x int
		fmt.Fscanf(reader, "%d ", &x)
		b[x + 100] = true
	}
	first := false
	for i := 0;i <= 200;i ++ {
		if b[i] {
			if !first {
				first = true
			} else {
				fmt.Printf("%d", i - 100)
				return
			}
		}
	}
	fmt.Printf("NO")
	return
}

package main

import "fmt"
import "log"

func main() {
	var n int
	nargs, err := fmt.Scan(&n);
	if err != nil {
		log.Fatal(err);
	}
	if nargs != 1 {
		log.Fatal("bad n", nargs);
	}
	if n < 2 {
		fmt.Println("NO");
		return;
	}

	var num, min1, min2 int
	idx := 0;
	for i := 0; i < n; i++ {
		nargs, err = fmt.Scan(&num);
		if err != nil {
			log.Fatal(err);
		}
		if nargs != 1 {
			log.Fatal("bad n", nargs);
		}

		switch idx {
		case 0:
			min1 = num;
			idx++;
			break;
		case 1:
			if num < min1 {
				min2 = min1;
				min1 = num;
				idx++;
			} else if (num > min1) {
				min2 = num;
				idx++;
			}
			break;
		default:
			if num == min1 {
				// Skip it...
				break;
			}
			if num < min1 {
				min2 = min1;
				min1 = num;
			} else if (num < min2) {
				min2 = num;
			}
		}
	}
	fmt.Println(min2);
}

package main

import "fmt"
import "log"

func main() {
	var n int
	nargs, err := fmt.Scan(&n);
	if err != nil {
		log.Fatal(err);
	}
	if nargs != 1 {
		log.Fatal("bad n", nargs);
	}
	if n < 2 {
		fmt.Println("NO");
		return;
	}

	var num, min1, min2 int
	for i := 0; i < n; i++ {
		nargs, err = fmt.Scan(&num);
		if err != nil {
			log.Fatal(err);
		}
		if nargs != 1 {
			log.Fatal("bad n", nargs);
		}

		switch i {
		case 0:
			min1 = num;
			break;
		case 1:
			if num < min1 {
				min2 = min1;
				min1 = num;
			} else {
				min2 = num;
			}
			break;
		default:
			if num < min1 {
				min2 = min1;
				min1 = num;
			} else if (num < min2) {
				min2 = num;
			}
		}
	}
	fmt.Println(min2);
}

package main

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

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

	number := 0
	if scanner.Scan() {
		line := scanner.Text()

		fmt.Sscanf(line, "%d", &number)
	}

	if scanner.Scan() {
		line := scanner.Text()

		tokens := strings.Fields(line)
		numbers := make(sort.IntSlice, number)

		for i := 0; i < number; i++ {
			numbers[i], _ = strconv.Atoi(tokens[i])
		}

		sort.Sort(numbers)

		for i := 0; i < number; i++ {
			if numbers[i] != numbers[0] {
				fmt.Println(numbers[i])
				break
			}
		}
	}
}

// 22A
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	a := make([]int, 105)
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.IntSlice(a))
	for i := 1; i < n; i++ {
		if a[i] != a[0] {
			fmt.Println(a[i])
			return
		}
	}
	fmt.Println("NO")
}

// 22A
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, i int
	a := make([]int, 105)
	fmt.Scan(&n)
	for i = 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.IntSlice(a))
	i = 2
	for a[i] == a[i-1] {
		i++
	}
	if i > n || n == 1 {
		fmt.Println(a[i])
	} else {
		fmt.Println("NO")
	}
}

package main

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

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

const Max = 100 + 1

func main() {
        defer w.Flush()

        var n, tmp int
        a, b := Max, Max
        fmt.Fscanf(r, "%d\n", &n)
        for i := 0; i < n; i++ {
                fmt.Fscanf(r, "%d ", &tmp)
                if tmp < a {
                        b = a
                        a = tmp
                } else if tmp < b && tmp != a {
                        b = tmp
                }
        }
        fmt.Println(a, b)

        if b == Max {
                fmt.Fprintf(w, "NO")
        } else {
                fmt.Fprintf(w, "%v", b)
        }
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1003C(_r io.Reader, out io.Writer) {
	const eps = 1e-8
	in := bufio.NewReader(_r)

	var n, d int
	Fscan(in, &n, &d)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	l, r := 1.0, 5e3
o:
	for t := int(math.Log2((r - l) / eps)); t > 0; t-- {
		x := (l + r) / 2
		s := make([]float64, n+1)
		for i, v := range a {
			s[i+1] = s[i] + float64(v) - x
		}
		minI := 0
		for i, v := range s[:n+1-d] {
			if v < s[minI] {
				minI = i
			}
			if s[i+d] >= s[minI] {
				l = x
				continue o
			}
		}
		r = x
	}
	Fprintf(out, "%.8f", (l+r)/2)
}

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

package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	temps := make([]int, n)
	var max, sred float64
	max = 0
	var sum int
	for i := 0; i < n; i++ {
		fmt.Scan(&temps[i])
	}
	for i := 0; i < n; i++ {
		sum = 0
		for j := i; j < n; j++ {
			sum += temps[j]
			if j - i + 1 >= k {
				sred = float64(sum) / float64(j - i + 1)
				if max < sred {
					max = sred
				}
			}
		}
	}
	fmt.Print(max)
}

package main

import."fmt"
import"bufio"
import"os"

func main(){
	var n,k int
	Scan(&n,&k)
	a:=make([]int,n)
	in:=bufio.NewReader(os.Stdin)
	for i:=0;i<n;i++{
		Fscan(in,&a[i])
	}

	if k==1{
		max:=a[0]
		for i:=1;i<n;i++{
			if max<a[i]{
				max=a[i]
			}
		}
		Print(max)
		return
	}
	max:=.0
	for i:=k;i<=n;i++{
		sum:=0
		for j:=0;j<i;j++{
			sum+=a[j]
		}
		ave:=float64(sum)/float64(i)
		if max<ave{
			max=ave
		}
		for j:=1;j<n-i+1;j++{
			sum-=a[j-1]
			sum+=a[j+i-1]
			ave=float64(sum)/float64(i)
			if max<ave{
				max=ave
			}
		}
	}
	Printf("%.8f",max)
}

package main

import (
	"fmt"
	"math"
)

var (
	n, k int
	a, s [5005]float64
	ans float64
)
func main() {
	fmt.Scan(&n, &k)
	for i := 1; i <= n; i++ {
		fmt.Scan(&a[i])
		s[i] = s[i - 1] + a[i]
	}
	for i := 1; i <= n; i++ {
		for j := 0; j <= i - k; j++ {
			ans = math.Max(ans, (s[i] - s[j]) / float64(i - j))
		}
	}
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	temps := make([]int, n)
	var max, sred float64
	max = 0
	var sum int
	for i := 0; i < n; i++ {
		fmt.Scan(&temps[i])
	}
	for i := 0; i < n; i++ {
		for j := i + k; j < n; j++ {
			sum = 0
			for c := i; c < j; c++ {
				sum += temps[c]
			}
			sred = float64(sum) / float64(j - i)
			if max < sred {
				max = sred
			}
		}
	}
	fmt.Print(max)
}

package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	temps := make([]int, n)
	var max, sred float64
	max = 0
	var sum int
	for i := 0; i < n; i++ {
		fmt.Scan(&temps[i])
	}
	for i := 0; i < n; i++ {
		for j := i + k; j < n; j++ {
			sum = 0
			for c := i; c < j; c++ {
				sum += temps[c]
			}
			sred = float64(sum) / float64(j)
			if max < sred {
				max = sred
			}
		}
	}
	fmt.Print(max)
}


package main

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

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

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

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

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

	var q int
	fmt.Fscanf(input, "%d\n", &q)
	cmd := make([]int, q)
	p := make([]int, q)
	x := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Fscanf(input, "%d", &cmd[i])
		switch cmd[i] {
		case 1:
			fmt.Fscanf(input, "%d %d\n", &p[i], &x[i])
		case 2:
			fmt.Fscanf(input, "%d\n", &x[i])
		}
	}

	ans := make([]int, n)
	for i := range ans {
		ans[i] = -1
	}
	var payoff int
	for i := q - 1; i >= 0; i-- {
		switch cmd[i] {
		case 1:
			if ans[p[i]-1] == -1 {
				ans[p[i]-1] = max(x[i], payoff)
			}
		case 2:
			payoff = max(x[i], payoff)
		}
	}
	for i := range ans {
		if ans[i] == -1 {
			ans[i] = max(payoff, a[i])
		}
		fmt.Printf("%d", ans[i])
		if i < n-1 {
			fmt.Printf(" ")
		} else {
			fmt.Printf("\n")
		}
	}
}

package main

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

var segTree = make([]int, 1000000)

func getTarget(index, target, left, right, maxLazy int) int {
	var value int
	if segTree[index] > maxLazy {
		value = segTree[index]
	} else {
		value = maxLazy
	}
	if left == right {
		return value
	} else {
		mid := (left + right) / 2
		if target <= mid {
			return getTarget(index * 2 + 1, target, left, mid, value)
		} else {
			return getTarget(index * 2 + 2, target, mid + 1, right, value)
		}
	}
}

func setTarget(index, target, value, left, right, lazy int) {
	if left == right {
		segTree[index] = value
		return
	} else {
		if segTree[index] > lazy {
			lazy = segTree[index]
		}
		segTree[index] = 0
		mid := (left + right) / 2
		if target <= mid {
			setLazy(index * 2 + 2, lazy)
			setTarget(index * 2 + 1, target, value, left, mid, lazy)
			return
		} else {
			setLazy(index * 2 + 1, lazy)
			setTarget(index * 2 + 2, target, value, mid + 1, right, lazy)
			return
		}
	}
}

func setLazy(index, lazy int) {
	if index < len(segTree) && lazy > segTree[index] {
		segTree[index] = lazy
	}
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0;i < n;i ++ {
		var money int
		if i == n - 1 {
			fmt.Fscanf(reader, "%d\n", &money)
		} else {
			fmt.Fscanf(reader, "%d ", &money)
		}
		setTarget(0, i, money, 0, n - 1, 0)
	}
	var q int
	fmt.Fscanf(reader, "%d\n", &q)
	for i := 0;i < q;i ++ {
		var req, p, x int
		fmt.Fscanf(reader, "%d ", &req)
		if req == 1 {
			fmt.Fscanf(reader, "%d %d\n", &p, &x)
			setTarget(0, p - 1, x, 0, n - 1, 0)
		} else {
			fmt.Fscanf(reader, "%d\n", &x)
			setLazy(0, x)
		}
	}
	for i := 0;i < n;i ++ {
		fmt.Printf("%d ", getTarget(0, i, 0, n - 1, 0))
	}
}

// Author: sighduck
// URL: https://codeforces.com/problemset/problem/1198/B

package main

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

type ReceiptEvent struct {
	Person  int
	Balance int
}

type PayoutEvent struct {
	Min int
}

func Solve(n int, a []int, q int, queries []interface{}) []int {
	receipts := make([]int, n+1)
	payouts := make([]int, q+2)
	for i, query := range queries {
		switch query.(type) {
		case ReceiptEvent:
			r := query.(ReceiptEvent)
			receipts[r.Person] = i
			a[r.Person] = r.Balance
		case PayoutEvent:
			p := query.(PayoutEvent)
			payouts[i+1] = p.Min
		}
	}
	for i := q - 1; i >= 0; i-- {
		if payouts[i] < payouts[i+1] {
			payouts[i] = payouts[i+1]
		}
	}
	for i := 1; i <= n; i++ {
		if a[i] < payouts[receipts[i]+1] {
			a[i] = payouts[receipts[i]+1]
		}
	}
	return a[1:]
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	a := make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}
	fmt.Fscanf(reader, "\n")
	var q int
	fmt.Fscanf(reader, "%d\n", &q)
	queries := make([]interface{}, q)
	for i := 0; i < q; i++ {
		var queryType int
		fmt.Fscanf(reader, "%d", &queryType)
		if queryType == 1 {
			r := ReceiptEvent{}
			fmt.Fscanf(reader, "%d %d", &r.Person, &r.Balance)
			queries[i] = r
		} else {
			p := PayoutEvent{}
			fmt.Fscanf(reader, "%d", &p.Min)
			queries[i] = p
		}
		fmt.Fscanf(reader, "\n")
	}

	answer := Solve(n, a, q, queries)
	for _, elem := range answer {
		fmt.Fprintf(writer, "%d ", elem)
	}
	fmt.Fprintf(writer, "\n")
}

package main

import (
	"bufio"
	"os"
	"runtime"
	"strconv"
)

/* solution */

func solve() {

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

	q := readInt()
	social := make([]int, 0)

	for i := 0; i < q; i++ {
		op := readInt()
		if op == 1 {
			p, x := readInt()-1, readInt()
			balance[p] = x
			pointer[p] = len(social)
		} else {
			x := readInt()
			social = append(social, x)
		}
	}

	for i := len(social) - 2; i >= 0; i-- {
		if social[i+1] > social[i] {
			social[i] = social[i+1]
		}
	}

	for i := 0; i < n; i++ {
		if pointer[i] < len(social) && social[pointer[i]] > balance[i] {
			printInt(social[pointer[i]])
		} else {
			printInt(balance[i])
		}
	}

}

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
	} else {
		f = os.Stdin
	}
	defer f.Close()

	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	reader = bufio.NewScanner(f)
	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

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

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

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

package main

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

var segTree = make([]int, 1000000)

func getTarget(index, target, left, right, maxLazy int) int {
	var value int
	if segTree[index] > maxLazy {
		value = segTree[index]
	} else {
		value = maxLazy
	}
	if left == right {
		return value
	} else {
		mid := (left + right) / 2
		if target <= mid {
			return getTarget(index * 2 + 1, target, left, mid, value)
		} else {
			return getTarget(index * 2 + 2, target, mid + 1, right, value)
		}
	}
}

func setTarget(index, target, value, left, right, lazy int) {
	if left == right {
		fmt.Printf("index=%d target=%d left=%d right=%d\n", index, target, left, right)
		segTree[index] = value
		return
	} else {
		if segTree[index] > lazy {
			lazy = segTree[index]
		}
		segTree[index] = 0
		mid := (left + right) / 2
		if target <= mid {
			setLazy(index * 2 + 2, lazy)
			setTarget(index * 2 + 1, target, value, left, mid, lazy)
			return
		} else {
			setLazy(index * 2 + 1, lazy)
			setTarget(index * 2 + 2, target, value, mid + 1, right, lazy)
			return
		}
	}
}

func setLazy(index, lazy int) {
	if index < len(segTree) && lazy > segTree[index] {
		segTree[index] = lazy
	}
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0;i < n;i ++ {
		var money int
		if i == n - 1 {
			fmt.Fscanf(reader, "%d\n", &money)
		} else {
			fmt.Fscanf(reader, "%d ", &money)
		}
		setTarget(0, i, money, 0, n - 1, 0)
	}
	var q int
	fmt.Fscanf(reader, "%d\n", &q)
	for i := 0;i < q;i ++ {
		var req, p, x int
		fmt.Fscanf(reader, "%d ", &req)
		if req == 1 {
			fmt.Fscanf(reader, "%d %d\n", &p, &x)
			setTarget(0, p - 1, x, 0, n - 1, 0)
		} else {
			fmt.Fscanf(reader, "%d\n", &x)
			setLazy(0, x)
		}
	}
	for i := 0;i < n;i ++ {
		fmt.Printf("%d ", getTarget(0, i, 0, n - 1, 0))
	}
}

package main

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

var segTree = make([]int, 500000)

func getTarget(index, target, left, right, maxLazy int) int {
	var value int
	if segTree[index] > maxLazy {
		value = segTree[index]
	} else {
		value = maxLazy
	}
	if left == right {
		return value
	} else {
		mid := (left + right) / 2
		if target <= mid {
			return getTarget(index * 2 + 1, target, left, mid, value)
		} else {
			return getTarget(index * 2 + 2, target, mid + 1, right, value)
		}
	}
}

func setTarget(index, target, value, left, right, lazy int) {
	if left == right {
		segTree[index] = value
		return
	} else {
		if segTree[index] > lazy {
			lazy = segTree[index]
		}
		segTree[index] = 0
		mid := (left + right) / 2
		if target <= mid {
			setLazy(index * 2 + 2, lazy)
			setTarget(index * 2 + 1, target, value, left, mid, lazy)
			return
		} else {
			setLazy(index * 2 + 1, lazy)
			setTarget(index * 2 + 2, target, value, mid + 1, right, lazy)
			return
		}
	}
}

func setLazy(index, lazy int) {
	if lazy > segTree[index] {
		segTree[index] = lazy
	}
}

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

	var n int
	fmt.Fscanf(reader, "%d\r\n", &n)
	for i := 0;i < n;i ++ {
		var money int
		if i == n {
			fmt.Fscanf(reader, "%d\r\n", &money)
		} else {
			fmt.Fscanf(reader, "%d ", &money)
		}
		setTarget(0, i, money, 0, n - 1, 0)
	}
	var q int
	fmt.Fscanf(reader, "%d\r\n", &q)
	for i := 0;i < q;i ++ {
		var req, p, x int
		fmt.Fscanf(reader, "%d ", &req)
		if req == 1 {
			fmt.Fscanf(reader, "%d %d\r\n", &p, &x)
			setTarget(0, p - 1, x, 0, n - 1, 0)
		} else {
			fmt.Fscanf(reader, "%d\r\n", &x)
			setLazy(0, x)
		}
	}
	for i := 0;i < n;i ++ {
		fmt.Printf("%d ", getTarget(0, i, 0, n - 1, 0))
	}
}

package main

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

var segTree = make([]int, 500000)

func getTarget(index, target, left, right, maxLazy int) int {
	var value int
	if segTree[index] > maxLazy {
		value = segTree[index]
	} else {
		value = maxLazy
	}
	if left == right {
		return value
	} else {
		mid := (left + right) / 2
		if target <= mid {
			return getTarget(index * 2 + 1, target, left, mid, value)
		} else {
			return getTarget(index * 2 + 2, target, mid + 1, right, value)
		}
	}
}

func setTarget(index, target, value, left, right, lazy int) {
	if left == right {
		segTree[index] = value
		return
	} else {
		if segTree[index] > lazy {
			lazy = segTree[index]
		}
		segTree[index] = 0
		mid := (left + right) / 2
		if target <= mid {
			setLazy(index * 2 + 2, lazy)
			setTarget(index * 2 + 1, target, value, left, mid, lazy)
			return
		} else {
			setLazy(index * 2 + 1, lazy)
			setTarget(index * 2 + 2, target, value, mid + 1, right, lazy)
			return
		}
	}
}

func setLazy(index, lazy int) {
	if lazy > segTree[index] {
		segTree[index] = lazy
	}
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	for i := 0;i < n;i ++ {
		var money int
		if i == n {
			fmt.Fscanf(reader, "%d\n", &money)
		} else {
			fmt.Fscanf(reader, "%d ", &money)
		}
		setTarget(0, i, money, 0, n - 1, 0)
	}
	var q int
	fmt.Fscanf(reader, "%d\n", &q)
	for i := 0;i < q;i ++ {
		var req, p, x int
		fmt.Fscanf(reader, "%d ", &req)
		if req == 1 {
			fmt.Fscanf(reader, "%d %d\n", &p, &x)
			setTarget(0, p - 1, x, 0, n - 1, 0)
		} else {
			fmt.Fscanf(reader, "%d\n", &x)
			setLazy(0, x)
		}
	}
	for i := 0;i < n;i ++ {
		fmt.Printf("%d ", getTarget(0, i, 0, n - 1, 0))
	}
}

package main

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

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

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

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

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

	cmd := make([]int, n)
	p := make([]int, n)
	x := make([]int, n)

	var q int
	fmt.Fscanf(input, "%d\n", &q)
	for i := 0; i < q; i++ {
		fmt.Fscanf(input, "%d", &cmd[i])
		switch cmd[i] {
		case 1:
			fmt.Fscanf(input, "%d %d\n", &p[i], &x[i])
		case 2:
			fmt.Fscanf(input, "%d\n", &x[i])
		}
	}

	ans := make([]int, n)
	for i := range ans {
		ans[i] = -1
	}
	var payoff int
	for i := q - 1; i >= 0; i-- {
		switch cmd[i] {
		case 1:
			if ans[p[i]] == -1 {
				ans[p[i]] = max(x[i], payoff)
			}
		case 2:
			payoff = max(x[i], payoff)
		}
	}
	for i := range ans {
		if ans[i] == -1 {
			ans[i] = max(payoff, a[i])
		}
		fmt.Printf("%d", ans[i])
		if i < n-1 {
			fmt.Printf(" ")
		} else {
			fmt.Printf("\n")
		}
	}
}


package main
import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)
func abs(x int)int {
	if x<0 {
		x*=(-1)
	}
	return x
}
func main() {
	var n,m,d,res int
	var a [10010]int
	fmt.Scan(&n,&m,&d)
	res=(1<<30)
	n*=m
	input:= bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	for i:=0;i<n;i++ {
		input.Scan()
		aa,_:=strconv.Atoi(input.Text())
		a[i]=aa
	}
	for i:=1;i<n;i++ {
		if ((a[i]-a[0])%d)!=0 {
			res=-1
		}
	}
	flag:=true
	if res<0 {
		fmt.Println(res)
		flag=false
	}

	for k:=0;k<n;k++ {
		//var t int
		//t=a[k]
		c:=0
		for i:=0;i<n;i++ {
			c+=abs(a[i]-a[k])
		}
		if (c/d)<res {
			res=c/d
		}
	}
	if flag==true {
		fmt.Println(res)
	}
}

package main

import (
	"fmt"
	"sort"
)

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

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

	a := make([]int, n*m, n*m)
	for i, k := 0, 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &a[k])
			k++
		}
		fmt.Scanf("\n")
	}

	for i := 1; i < n * m; i++ {
		if a[0] % d != a[i] % d {
			fmt.Println(-1)
			return
		}
	}

	sort.Ints(a)

	var mm int
	if (n * m) % 2 == 1 {
		mm = a[n * m / 2]
	} else {
		mm = (a[n * m / 2] + a[n * m / 2 - 1]) / 2
	}

	var r int
	for i := 0; i < n * m; i++ {
		r += abs(a[i] - mm)
	}

	fmt.Println(r/d)
}

package main

import (
	"fmt"
	"sort"
)

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

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

	a := make([]int, n*m, n*m)
	for i, k := 0, 0; i < n; i++ {
		for j := 0; j < m; j++ {
			fmt.Scanf("%d", &a[k])
			k++
		}
		fmt.Scanf("\n")
	}

	for i := 1; i < n * m; i++ {
		if a[0] % d != a[i] % d {
			fmt.Println(-1)
			return
		}
	}

	sort.Ints(a)

	var mm int
	if (n * m) % 2 == 1 {
		mm = a[n * m / 2]
	} else {
		mm = (a[n * m / 2] + a[n * m / 2 - 1]) / 2
	}

	var r int
	for i := 0; i < n * m; i++ {
		r += abs(a[i] - mm)
	}

    fmt.Println(a)
	fmt.Println(r/d)
}

package main

import (
	"fmt"
	"sort"
)

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

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

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

	for i := 1; i < n * m; i++ {
		if a[0] % d != a[i] % d {
			fmt.Println(-1)
			return
		}
	}

	sort.Ints(a)

	var mm int
	if (n * m) % 2 == 1 {
		mm = a[n * m / 2]
	} else {
		mm = (a[n * m / 2] + a[n * m / 2 - 1]) / 2
	}

	var r int
	for i := 0; i < n * m; i++ {
		r += abs(a[i] - mm)
	}

	fmt.Println(r/d)
}

package main

import (
	"fmt"
	"sort"
)

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

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

	a := make([]int, n*m, n*m)
	for i := 0; i < n*m; i++ {
		fmt.Scanf("%d", &a[i])
		if i > 0 && i % n == 0 {
			fmt.Scanf("\n")
		}
	}

	for i := 1; i < n * m; i++ {
		if a[0] % d != a[i] % d {
			fmt.Println(-1)
			return
		}
	}

	sort.Ints(a)
	var mm int
	if (n * m) % 2 == 1 {
		mm = a[n * m / 2]
	} else {
		mm = (a[n * m / 2] + a[n * m / 2 - 1]) / 2
	}

	var r int
	for i := 0; i < n * m; i++ {
		r += abs(a[i] - mm)
	}

	fmt.Println(r/d)
}

package main

import (
	"fmt"
	"sort"
)

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

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

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

	for i := 1; i < n * m; i++ {
		if a[0] % d != a[i] % d {
			fmt.Println(-1)
			return
		}
	}

	sort.Ints(a)
	var mm int
	if (n * m) % 2 == 1 {
		mm = a[n * m / 2]
	} else {
		mm = (a[n * m / 2] + a[n * m / 2 - 1]) / 2
	}

	var r int
	for i := 0; i < n * m; i++ {
		r += abs(a[i] - mm)
	}

	fmt.Println(r/d)
}

package main

import (
	"fmt"
	"sort"
)

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

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

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

	for i := 1; i < n * m; i++ {
		if a[0] % d != a[i] % d {
			fmt.Println(-1)
			return
		}
	}

	sort.Ints(a)

	fmt.Println(a)

	var mm int
	if (n * m) % 2 == 1 {
		mm = a[n * m / 2]
	} else {
		mm = (a[n * m / 2] + a[n * m / 2 - 1]) / 2
	}

	var r int
	for i := 0; i < n * m; i++ {
		r += abs(a[i] - mm)
	}

	fmt.Println(r/d)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func f(a []int, low int) int {
	if len(a) == 0 {
		return 0
	}
	mi := int(1e9)
	for _, v := range a {
		mi = min(mi, v)
	}
	c, p := mi-low, 0
	for i, v := range a {
		if v == mi {
			c += f(a[p:i], mi)
			p = i + 1
		}
	}
	c += f(a[p:], mi)
	return min(c, len(a))
}

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	Print(f(a, 0))
}

package main

import (
    "fmt"
    "os"
    )

func main() {
	var fence = ReadInput()
	fmt.Print(Minimum(fence))
}

func ReadInput() []int {
	var n int
	fmt.Fscan(os.Stdin, &n)
	var fence = make([]int, n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(os.Stdin, &x)
		fence[i] = x
	}

	return fence
}

func MinimumV2(fence []int) int {
	if len(fence) == 0 {
		return 0
	}

	if len(fence) == 1 {
		return 1
	}

	newFence := sub(fence, 1)

	// exclude zero
	segments := Split(newFence, 0, false)

	var horiz = 1
	for _, s := range segments {
		horiz += MinimumV2(s)
	}
	var vert = 1 + MinimumV2(fence[1:])

	return findMin(vert, horiz)
}

func sub(items []int, value int) []int {
	var ret = make([]int, len(items))
	for i, v := range items {
		ret[i] = v - value
	}

	return ret
}

// Split splits values by value into slice of integer slice
func Split(values []int, value int, copy bool) [][]int {
	var ret [][]int
	var left, right = -1, -1

	for i, v := range values {
		if v != value {
			if left == -1 {
				left = i
			}
			right = i + 1
			continue
		}

		if v == value { // should split
			if left != -1 && right != -1 {
				if copy {
					ret = append(ret, copySlice(values, left, right))
				} else {
					ret = append(ret, values[left:right])
				}

				// reset left, right
				left, right = -1, -1
			}
		}
	}

	// append the rest
	if left != -1 {
		if copy {
			ret = append(ret, copySlice(values, left, len(values)))
		} else {
			ret = append(ret, values[left:])
		}
	}

	return ret
}

func copySlice(values []int, left, right int) []int {
	var l = right - left
	if l < 0 {
		panic("right must greater than or equals left")
	}

	if l == 0 {
		return nil
	}

	if right > len(values) {
		panic("right greater size of values")
	}

	var ret = make([]int, right-left)
	copy(ret, values[left:right])
	return ret
}

func findMin(items ...int) int {
	if len(items) == 0 {
		return 0
	}
	var min = items[0]
	for _, v := range items {
		if min > v {
			min = v
		}
	}
	return min
}

func Minimum(fence []int) int {
	if len(fence) == 0 {
		return 0
	}

	if len(fence) == 1 {
		return 1
	}

	// find min
	var mins []int
	var min = fence[0]
	for i, v := range fence {
		if min > v {
			// change min
			min = v
			// reset mins
			mins = nil
		} else if min == v {
			mins = append(mins, i) // store index of min
		}
	}

	// how many vertical lines which is equal to min?
	segments := Split(fence, min, false)
	var ret = len(fence)
	var sum = min
	for _, s := range segments {
		sum += Minimum(sub(s, min))
	}

	return findMin(ret, sum)
}

package main

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

func findMedian(slice []int, left int, right int) (int, int) {
	min := slice[left]
	median := left
	for i := left; i < right; i++ {
		if min >= slice[i] {
			min = slice[i]
			median = i
		}
	}
	return median, min
}

func solve(planks []int, left int, right int, painted int) int {
	median, min := findMedian(planks, left, right)
	currentBrush := min - painted

	var leftBrush, rightBrush int
	if median == left {
		leftBrush = 0
	} else {
		leftBrush = solve(planks, left, median, min)
	}

	if median == right-1 {
		rightBrush = 0
	} else {
		rightBrush = solve(planks, median+1, right, min)
	}

	if currentBrush+leftBrush+rightBrush >= right-left {
		return right - left
	}

	return currentBrush + leftBrush + rightBrush

}

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

	var n int
	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d", &n)
	}

	if scanner.Scan() {
		line := scanner.Text()

		tokens := strings.Fields(line)

		planks := make([]int, n)
		for i := 0; i < n; i++ {
			planks[i], _ = strconv.Atoi(tokens[i])
		}

		fmt.Println(solve(planks, 0, n, 0))
	}
}

package main

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

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

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

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

	fmt.Println(Strokes(a))
}

func Strokes(a []int) int {
	if len(a) == 0 {
		return 0
	}

	mini := a[0]
	for i := 0; i < len(a); i++ {
		mini = min(mini, a[i])
	}

	numStrokes := mini
	for i := 0; i < len(a); i++ {
		a[i] -= mini
	}
	for i := 0; i < len(a); i++ {
		if a[i] == 0 {
			continue
		}
		j := i
		for j < len(a) && a[j] > 0 {
			j++
		}
		numStrokes += Strokes(a[i:j])
		i = j
	}

	return min(len(a), numStrokes)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF448C(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var f func([]int, int) int
	f = func(a []int, low int) int {
		if len(a) == 0 {
			return 0
		}
		mi := int(1e9)
		for _, v := range a {
			mi = min(mi, v)
		}
		c, p := mi-low, 0
		for i, v := range a {
			if v == mi {
				c += f(a[p:i], mi)
				p = i + 1
			}
		}
		c += f(a[p:], mi)
		return min(c, len(a))
	}
	var n int
	Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	Fprint(out, f(a, 0))
}

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

package main

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

func findMedian(slice []int, left int, right int) (int, int) {
	min := slice[left]
	median := left
	for i := left; i < right; i++ {
		if min >= slice[i] {
			min = slice[i]
			median = i
		}
	}
	return median, min
}

func solve(planks []int, left int, right int, painted int) int {
	median, min := findMedian(planks, left, right)

	var leftBrush, rightBrush int
	currentBrush := min - painted
	if currentBrush >= right-left {
		return right - left
	}

	if median == left {
		leftBrush = 0
	} else {
		leftBrush = solve(planks, left, median, min)
	}

	if median == right-1 {
		rightBrush = 0
	} else {
		rightBrush = solve(planks, median+1, right, min)
	}

	return currentBrush + leftBrush + rightBrush

}

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

	var n int
	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d", &n)
	}

	if scanner.Scan() {
		line := scanner.Text()

		tokens := strings.Fields(line)

		planks := make([]int, n)
		for i := 0; i < n; i++ {
			planks[i], _ = strconv.Atoi(tokens[i])
		}

		fmt.Println(solve(planks, 0, n, 0))
	}
}

package main

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

func findMedian(slice []int, left int, right int) (int, int) {
	min := slice[left]
	median := left
	for i := left; i < right; i++ {
		if min >= slice[i] {
			min = slice[i]
			median = i
		}
	}
	return median, min
}

func solve(planks []int, left int, right int, painted int) int {
	median, min := findMedian(planks, left, right)

	var leftBrush, rightBrush int
	currentBrush := min - painted

	if currentBrush >= right-left {
		return right - left
	}

	if median == left {
		if planks[left]-painted > right-left {
			leftBrush = right - left
		} else {
			leftBrush = planks[left] - painted
		}
	} else {
		leftBrush = solve(planks, left, median, min)
	}

	if median == right-1 {
		rightBrush = 0
	} else {
		rightBrush = solve(planks, median+1, right, min)
	}

	// fmt.Printf("Left: %d, Right: %d, Median: %d, CurrentBrush: %d, LeftBrush: %d, RightBrush: %d\n",
	// 	left, right, median, currentBrush, leftBrush, rightBrush)
	return currentBrush + leftBrush + rightBrush

}

/**
1 3 3 2 2 3 3 2 1 1

+1

painted = 1, min = 1, currentBrush =
3 3 2 2 3 3 2 1 1

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

	var n int
	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d", &n)
	}

	if scanner.Scan() {
		line := scanner.Text()

		tokens := strings.Fields(line)

		planks := make([]int, n)
		for i := 0; i < n; i++ {
			planks[i], _ = strconv.Atoi(tokens[i])
		}

		fmt.Println(solve(planks, 0, n, 0))
	}
}

package main

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

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

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

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

	fmt.Println(Strokes(a))
}

func Strokes(a []int) int {
	mini, count := a[0], 1
	for i := 0; i < len(a); i++ {
		if a[i] == mini {
			count++
		} else if a[i] < mini {
			mini, count = a[i], 1
		}
	}

	if mini >= count {
		return len(a)
	}

	numStrokes := mini
	for i := 0; i < len(a); i++ {
		a[i] -= mini
	}
	for i := 0; i < len(a); i++ {
		if a[i] == 0 {
			continue
		}
		j := i
		for j < len(a) && a[j] > 0 {
			j++
		}
		numStrokes += Strokes(a[i:j])
		i = j
	}

	return numStrokes
}

package main

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

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

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

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

	fmt.Println(Strokes(a))
}

func Strokes(a []int) int {
	mini, count := a[0], 1
	for i := 0; i < len(a); i++ {
		if a[i] == mini {
			count++
		} else if a[i] < mini {
			mini, count = a[i], 1
		}
	}

	if mini > count {
		return len(a)
	}

	numStrokes := mini
	for i := 0; i < len(a); i++ {
		a[i] -= mini
	}
	for i := 0; i < len(a); i++ {
		if a[i] == 0 {
			continue
		}
		j := i
		for j < len(a) && a[j] > 0 {
			j++
		}
		numStrokes += Strokes(a[i:j])
		i = j
	}

	return numStrokes
}

package main

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

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

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

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

	fmt.Println(Strokes(a))
}

func Strokes(a []int) int {
	if len(a) == 0 {
		return 0
	}

	mini, count := a[0], 1
	for i := 1; i < len(a); i++ {
		if a[i] == mini {
			count++
		} else if a[i] < mini {
			mini, count = a[i], 1
		}
	}

	if mini > count {
		return len(a)
	}

	numStrokes := mini
	for i := 0; i < len(a); i++ {
		a[i] -= mini
	}
	for i := 0; i < len(a); i++ {
		if a[i] == 0 {
			continue
		}
		j := i
		for j < len(a) && a[j] > 0 {
			j++
		}
		numStrokes += Strokes(a[i:j])
		i = j
	}

	return numStrokes
}


// 284B-mic
package main

import (
    "fmt"
)

func main() {
    var s string
    var n, k, c int
    l := 1
    v := 0
    fmt.Scan(&n)
    fmt.Scan(&s)
    for i := 0; i < n; i++ {
        if s[i] == 'A' {
            k++
        } else if s[i] == 'I' {
            c++
        }
    }
    if c == 0 {
        fmt.Printf("%d\n", k)
    } else if c == 1 {
        fmt.Printf("%d\n", l)
    } else {
        fmt.Printf("%d\n", v)
    }
}

package main

import (
	"fmt"
)

var ps = fmt.Printf
var ss = fmt.Scanf

const mod int = 1000000007

func main() {
	a := 0
	status := false
	var s string
	ss("%d\n%s\n", &a, &s)
	A, I := 0, 0
	for i := 0; i < a; i++ {
		if s[i] == 'A' {
			A++
		} else if s[i] == 'I' {
			status = true
			I++
		}
	}
	if status == false {
		ps("%d\n", A)
	} else {
		if I == 1 {
			ps("1\n")
		} else {
			ps("0\n")
		}
	}
}

package main

import "fmt"
//import "bufio"

func main(){
	var n int
	fmt.Scan(&n)
	var sapi string
	fmt.Scan(&sapi)
	var a, i, f int = 0, 0, 0
	for j:=0; j<n; j++ {
		if string(sapi[j]) == "A" {
			a += 1
		} else if string(sapi[j]) == "I" {
			i += 1
		} else {
			f += 1
		}
	}
//	fmt.Println(a, i, f)
	if a > 0 && i < 1 {
		fmt.Println(a)
	} else if i > 0 && i <= 1 {
		fmt.Println(i)
	} else {
		fmt.Println(0)
	}
}

package main
import (
	"fmt"
	//"sort"
	"unicode/utf8"
)
func main() {
	var n int
	var s string
	a,b:=0,0
	fmt.Scan(&n,&s)
	len:=utf8.RuneCountInString(s)
	for i:=0;i<len;i++ {
		if s[i]=='A' {
			a++
		} else if s[i]=='I' {
			b++
		}
	}
	if b>1 {
		fmt.Println("0")
	} else if b==1 {
		fmt.Println("1")
	} else {
		fmt.Println(a)
	}

}

package main

import "fmt"

func main() {
    var n int
    var s string
    fmt.Scan(&n)
    fmt.Scan(&s)
    A, I := 0, 0
    for _, v := range s {
        if v == 'A' {
            A++
        } else if v == 'I' {
            I++
        }
    }
    if I == 0 { fmt.Println(A) } else { fmt.Println(1/I) }
}

// 284B
package main

import (
	"fmt"
)

func main() {
	var n int
	var ln string
	fmt.Scan(&n)
	fmt.Scan(&ln)
	A, I := 0, 0
	for _, v := range ln {
		if v == 'A' {
			A++
		} else if v == 'I' {
			I++
		}
	}
	if I == 0 {
		fmt.Println(A)
	} else {
		fmt.Println(1 / I)
	}
}

package main

import (
	"fmt"
)

var ps = fmt.Printf
var ss = fmt.Scanf

const mod int = 1000000007

func main() {
	var s string
	ss("%s\n", &s)
	A := 0
	for i := 0; i < len(s); i++ {
		if s[i] == 'A' {
			A++
		}
	}
	ps("%d", A)
}

package main

import (
	"fmt"
)

var ps = fmt.Printf
var ss = fmt.Scanf

const mod int = 1000000007

func main() {
	 a:=0
	var s string
	ss("%d\n%s\n",&a, &s)
	A := 0
	for i := 0; i < a; i++ {
		if s[i] == 'A' {
			A++
		}
	}
	ps("%d", A)
}

package main

import "fmt"
//import "bufio"

func main(){
	var n int
	fmt.Scan(&n)
	var sapi string
	fmt.Scan(&sapi)
	var a, i, f int = 0, 0, 0
	for i:=0; i<n; i++ {
		if string(sapi[i]) == "A" {
			a += 1
		} else if string(sapi[i]) == "I" {
			i += 1
		} else {
			f += 1
		}
	}
	if a > 0 && i < 1 {
		fmt.Println(a)
	} else if a < 1 && i > 0 {
		fmt.Println(i)
	} else {
		fmt.Println(0)
	}
}

package main

import "fmt"

func main() {
    var n int
    var s string
    fmt.Scan(&n)
    fmt.Scan(&s)
    A, I := 0, 0
    for _, v := range s {
        if v == 'A' {
            A++
        } else if v == 'I' {
            I++
        }
    }
    if I == 0 { fmt.Println(A) } else { fmt.Println(1) }
}

// 284B-mic
package main

import (
	"fmt"
)

func main() {
	var s string
	var n, k, i int
	fmt.Scan(&n)
	fmt.Scan(&s)
	for i := 0; i < n; i++ {
		if s[i] == 'A' {
			k++
		} else if s[i] == 'I' {
			i++
		}
	}
	if i == 0 {
		fmt.Printf("%d\n", k)
	} else if i == 1 {
		fmt.Printf("1\n")
	} else {
		fmt.Printf("0\n")
	}
}


package main

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

var graph [][]int
var parent []int
var visited []int
var ex_edge [] int

func searchCycle(u int) []int {
    visited[u] = 1
    for _, v := range graph[u] {
        if ex_edge != nil && u == ex_edge[0] && v == ex_edge[1] {
            continue
        }

        if visited[v] == 0 {
            parent[v] = u
            cycle := searchCycle(v)
            if cycle != nil {
                return cycle
            }
        } else if visited[v] == 1 {
            cycle := []int{v}
            for u != v {
                cycle = append(cycle, u)
                u = parent[u]
            }
            cycle = append(cycle, u)
            return cycle
        }
    }
    visited[u] = 2
    return nil
}

func solve() bool {
    var cycle []int
    for u := 0; u < len(graph) && cycle == nil; u++ {
        if visited[u] == 0 {
            cycle = searchCycle(u)
        }
    }
    if cycle == nil {
        return true
    }
    for i := 1; i < len(cycle); i++ {
        ex_edge = []int{cycle[i], cycle[i - 1]}
        for u, _ := range visited {
            visited[u] = 0
        }
        found_cycle := false
        for u := 0; u < len(graph) && !found_cycle; u++ {
            if visited[u] == 0 && searchCycle(u) != nil {
                found_cycle = true
            }
        }
        if !found_cycle {
            return true
        }
    }
    return false
}

func main() {
    var n, m int
    input := bufio.NewReader(os.Stdin)
    fmt.Fscan(input, &n, &m)
    graph = make([][]int, n)
    parent = make([]int, n)
    visited = make([]int, n)
    for i := 0; i < m; i++ {
        var u, v int
        fmt.Fscan(input, &u, &v)
        graph[u - 1] = append(graph[u - 1], v - 1)
    }

    if solve() {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF915D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, m, v, w int
	Fscan(in, &n, &m)
	g := make([][]int, n)
	dd := make([]int, n)
	for i := 0; i < m; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		dd[w]++
	}

	for i, d := range dd {
		if d == 0 {
			continue
		}
		deg := make([]int, n)
		copy(deg, dd)
		deg[i]--
		q := []int{}
		for v, d := range deg {
			if d == 0 {
				q = append(q, v)
			}
		}
		c := 0
		for len(q) > 0 {
			v, q = q[0], q[1:]
			c++
			for _, w := range g[v] {
				deg[w]--
				if deg[w] == 0 {
					q = append(q, w)
				}
			}
		}
		if c == n {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func CF915D(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, m, v, w int
	Fscan(in, &n, &m)
	g := make([][]int, n)
	dd := make([]int, n)
	for i := 0; i < m; i++ {
		Fscan(in, &v, &w)
		v--
		w--
		g[v] = append(g[v], w)
		dd[w]++
	}

	deg := make([]int, n)
	for i, d := range dd {
		if d == 0 {
			continue
		}
		copy(deg, dd)
		deg[i]--
		q := []int{}
		for v, d := range deg {
			if d == 0 {
				q = append(q, v)
			}
		}
		c := 0
		for len(q) > 0 {
			v, q = q[0], q[1:]
			c++
			for _, w := range g[v] {
				deg[w]--
				if deg[w] == 0 {
					q = append(q, w)
				}
			}
		}
		if c == n {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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

package main

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

var graph [][]int
var parent []int
var visited []int
var ex_edge [] int

func searchCycle(u int) []int {
    visited[u] = 1
    for _, v := range graph[u] {
        if ex_edge != nil && u == ex_edge[0] && v == ex_edge[1] {
            continue
        }

        if visited[v] == 0 {
            parent[v] = u
            cycle := searchCycle(v)
            if cycle != nil {
                return cycle
            }
        } else if visited[v] == 1 {
            cycle := []int{v}
            for u != v {
                cycle = append(cycle, u)
                u = parent[u]
            }
            cycle = append(cycle, u)
            return cycle
        }
    }
    visited[u] = 2
    return nil
}

func solve() bool {
    var cycle []int
    for u := 0; u < len(graph) && cycle == nil; u++ {
        if visited[u] == 0 {
            cycle = searchCycle(u)
        }
    }
    if cycle == nil {
        return true
    }
    for i := 1; i < len(cycle); i++ {
        ex_edge = []int{cycle[i], cycle[i - 1]}
        for u, _ := range visited {
            visited[u] = 0
        }
        cycle = nil
        for u := 0; u < len(graph) && cycle == nil; u++ {
            if visited[u] == 0 {
                cycle = searchCycle(u)
            }
        }
        if cycle == nil {
            return true
        }
    }
    return false
}

func main() {
    var n, m int
    input := bufio.NewReader(os.Stdin)
    fmt.Fscan(input, &n, &m)
    graph = make([][]int, n)
    parent = make([]int, n)
    visited = make([]int, n)
    for i := 0; i < m; i++ {
        var u, v int
        fmt.Fscan(input, &u, &v)
        graph[u - 1] = append(graph[u - 1], v - 1)
    }

    if solve() {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main
import (
	"fmt"
)
func main() {
	var n,m,b int
	ma,c:=0,1
	fmt.Scan(&n)
	a:=make([]int,n)
	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
	}
	fmt.Scan(&m)
	for i:=0;i<m;i++ {
		fmt.Scan(&b)
		for j:=0;j<n;j++ {
			if b%a[j]==0 {
				x:=b/a[j]
				if x>ma {
					ma=x
					c=1
				} else if x==ma {
					c++
				}
				break
			}
		}
	}

	fmt.Println(c)
}

package main

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

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	n := scanInt(scanner)
	arr := make([]int, n)
	for i := range arr {
		arr[i] = scanInt(scanner)
	}
	bestRatio, bestCount := 0, 0
	m := scanInt(scanner)
	for i := 0; i < m; i++ {
		b := scanInt(scanner)
		for _, a := range arr {
			if b%a == 0 {
				if b/a == bestRatio {
					bestCount++
				} else if b/a > bestRatio {
					bestRatio = b/a
					bestCount = 1
				}
			}
		}
	}
	writer.WriteString(fmt.Sprintf("%d\n", bestCount))
}

package main

import "fmt"

func main() {
    var n,m int
    var a,b [55]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ { fmt.Scan(&a[i]) }
    fmt.Scan(&m)
    for i := 0; i < m; i++ { fmt.Scan(&b[i]) }
    max, cnt := 0, 0
    for i := 0; i < n; i++ {
        for j := 0; j < m; j++ {
            if (b[j]%a[i]) == 0 {
                r := b[j]/a[i]
                if max == r {
                    cnt++
                } else if max < r {
                    max = r
                    cnt = 1
                }
            }
        }
    }
    fmt.Println(cnt)
}

package main

import "fmt"

func main() {
    var n,m int                                 // membuat variabel n dan m dengan tipe data int
    var a,b [55]int                             // membuat variabel a dan b dengan tipe data array of int dengan ukuran 55
    fmt.Scan(&n)                                // menerima input n
    for i := 0; i < n; i++ { fmt.Scan(&a[i]) }  // looping sebanyak n kali dan menerima input ai
    fmt.Scan(&m)                                // menerima input m
    for i := 0; i < m; i++ { fmt.Scan(&b[i]) }  // looping sebanyak m kali dan menerima input bi
    max, cnt := 0, 0                            // membuat variabel max dan cnt dengan tipe data int dengan nilai awal 0
    for i := 0; i < n; i++ {                    // looping sebanyak n kali
        for j := 0; j < m; j++ {                // looping sebanyak m kali
            if (b[j]%a[i]) == 0 {               // jika bj habis dibagi ai
                r := b[j]/a[i]                  // membuat variabel r dengan tipe data int dengan nilai bj/ai
                if max == r {                   // jika max sama dengan r
                    cnt++                       // tambahkan nilai cnt sebesar 1
                } else if max < r {             // jika max lebih kecil dari r
                    max = r                     // max diisi dengan r
                    cnt = 1                     // cnt diisi dengan 1
                }
            }
        }
    }
    fmt.Println(cnt)                            // mencetak output nilai cnt
}