Bashar was practicing for the national programming contest. Because of sitting too much in front of the computer without doing physical movements and eating a lot Bashar became much fatter. Bashar is going to quit programming after the national contest and he is going to become an actor (just like his father), so he should lose weight.In order to lose weight, Bashar is going to run for $$$k$$$ kilometers. Bashar is going to run in a place that looks like a grid of $$$n$$$ rows and $$$m$$$ columns. In this grid there are two one-way roads of one-kilometer length between each pair of adjacent by side cells, one road is going from the first cell to the second one, and the other road is going from the second cell to the first one. So, there are exactly $$$(4 n m - 2n - 2m)$$$ roads.Let's take, for example, $$$n = 3$$$ and $$$m = 4$$$. In this case, there are $$$34$$$ roads. It is the picture of this case (arrows describe roads):Bashar wants to run by these rules:  He starts at the top-left cell in the grid;  In one move Bashar may go up (the symbol 'U'), down (the symbol 'D'), left (the symbol 'L') or right (the symbol 'R'). More formally, if he stands in the cell in the row $$$i$$$ and in the column $$$j$$$, i.e. in the cell $$$(i, j)$$$ he will move to:   in the case 'U' to the cell $$$(i-1, j)$$$;  in the case 'D' to the cell $$$(i+1, j)$$$;  in the case 'L' to the cell $$$(i, j-1)$$$;  in the case 'R' to the cell $$$(i, j+1)$$$;   He wants to run exactly $$$k$$$ kilometers, so he wants to make exactly $$$k$$$ moves;  Bashar can finish in any cell of the grid;  He can't go out of the grid so at any moment of the time he should be on some cell;  Bashar doesn't want to get bored while running so he must not visit the same road twice. But he can visit the same cell any number of times. Bashar asks you if it is possible to run by such rules. If it is possible, you should tell him how should he run.You should give him $$$a$$$ steps to do and since Bashar can't remember too many steps, $$$a$$$ should not exceed $$$3000$$$. In every step, you should give him an integer $$$f$$$ and a string of moves $$$s$$$ of length at most $$$4$$$ which means that he should repeat the moves in the string $$$s$$$ for $$$f$$$ times. He will perform the steps in the order you print them.For example, if the steps are $$$2$$$ RUD, $$$3$$$ UUL then the moves he is going to move are RUD $$$+$$$ RUD $$$+$$$ UUL $$$+$$$ UUL $$$+$$$ UUL $$$=$$$ RUDRUDUULUULUUL.Can you help him and give him a correct sequence of moves such that the total distance he will run is equal to $$$k$$$ kilometers or say, that it is impossible?

The only line contains three integers $$$n$$$, $$$m$$$ and $$$k$$$ ($$$1 \leq n, m \leq 500$$$, $$$1 \leq k \leq 10 ^{9}$$$), which are the number of rows and the number of columns in the grid and the total distance Bashar wants to run.

If there is no possible way to run $$$k$$$ kilometers, print "NO" (without quotes), otherwise print "YES" (without quotes) in the first line. If the answer is "YES", on the second line print an integer $$$a$$$ ($$$1 \leq a \leq 3000$$$) — the number of steps, then print $$$a$$$ lines describing the steps. To describe a step, print an integer $$$f$$$ ($$$1 \leq f \leq 10^{9}$$$) and a string of moves $$$s$$$ of length at most $$$4$$$. Every character in $$$s$$$ should be 'U', 'D', 'L' or 'R'. Bashar will start from the top-left cell. Make sure to move exactly $$$k$$$ moves without visiting the same road twice and without going outside the grid. He can finish at any cell. We can show that if it is possible to run exactly $$$k$$$ kilometers, then it is possible to describe the path under such output constraints.

NoteThe moves Bashar is going to move in the first example are: "RRLL".It is not possible to run $$$1000000000$$$ kilometers in the second example because the total length of the roads is smaller and Bashar can't run the same road twice.The moves Bashar is going to move in the third example are: "RRDDLLRR".The moves Bashar is going to move in the fifth example are: "RRRLLLDRRRDULLLD". It is the picture of his run (the roads on this way are marked with red and numbered in the order of his running):

package main

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

type node struct {
	diff int
	time int
}

type ByTime []node

func (a ByTime) Len() int           { return len(a) }
func (a ByTime) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByTime) Less(i, j int) bool { return a[i].time < a[j].time }

var p []int
var c []int
var children [][]int
var invalid bool

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	//fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, m, k := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &m, &k)
		total := 4*n*m - 2*n - 2*m
		if total < k {
			fmt.Fprintf(out, "NO\n")
			return
		}
		out1 := make([]int, 0)
		out2 := make([]string, 0)
		cur := 0
		// First line ->
		if cur+(m-1) >= k {
			out1 = append(out1, k-cur)
			out2 = append(out2, "R")
			output(out, out1, out2)
			return
		}
		out1 = append(out1, m-1)
		out2 = append(out2, "R")
		cur += m - 1
		// First line <-
		if cur+(m-1) >= k {
			out1 = append(out1, k-cur)
			out2 = append(out2, "L")
			output(out, out1, out2)
			return
		}
		out1 = append(out1, m-1)
		out2 = append(out2, "L")
		cur += m - 1
		for i := 0; i < n-1; i++ {
			cur++
			out1 = append(out1, 1)
			out2 = append(out2, "D")
			if cur >= k {
				output(out, out1, out2)
				return
			}
			if cur+3*(m-1) >= k {
				round := (k - cur) / 3
				if round > 0 {
					out1 = append(out1, round)
					out2 = append(out2, "RUD")
				}
				if (k-cur)%3 == 1 {
					out1 = append(out1, 1)
					out2 = append(out2, "R")
				} else if (k-cur)%3 == 2 {
					out1 = append(out1, 1)
					out2 = append(out2, "RU")
				}
				output(out, out1, out2)
				return
			}
			out1 = append(out1, m-1)
			out2 = append(out2, "RUD")
			cur += (m - 1) * 3
			if cur+(m-1) >= k {
				round := k - cur
				out1 = append(out1, round)
				out2 = append(out2, "L")
				output(out, out1, out2)
				return
			}
			out1 = append(out1, m-1)
			out2 = append(out2, "L")
			cur += m - 1
		}
		out1 = append(out1, k-cur)
		out2 = append(out2, "U")
		output(out, out1, out2)
	}
	return
}

func output(w io.Writer, out1 []int, out2 []string) {
	n := len(out1)
	tmpN := n
	for i := 0; i < len(out1); i++ {
		if out1[i] == 0 {
			tmpN--
		}
	}
	fmt.Fprintf(w, "YES\n")
	fmt.Fprintf(w, "%d\n", tmpN)
	for i := 0; i < n; i++ {
		if out1[i] > 0 {
			fmt.Fprintf(w, "%d %s\n", out1[i], out2[i])
		}
	}
	return
}

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 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 NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	return scanner.Bytes()
}

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

type Segment struct {
	Count int
	Path  string
}

func addSegment(char byte, cnt int, k *int) []*Segment {
	if *k == 0 || cnt == 0 {
		return []*Segment{}
	}
	if *k > cnt {
		*k -= cnt
	} else {
		cnt = *k
		*k = 0
	}

	return []*Segment{&Segment{cnt, string(char)}}
}

func buildHorizontalPath(n, m int, k *int) []*Segment {
	path := make([]*Segment, 0)
	for i := 0; i+1 < n; i++ {
		path = append(path, addSegment('R', m-1, k)...)
		path = append(path, addSegment('L', m-1, k)...)
		path = append(path, addSegment('D', 1, k)...)
	}
	path = append(path, addSegment('R', m-1, k)...)
	// the remaining part is 'L' * (m - 1)
	return path
}

func buildVerticalPath(n, m int, k *int) []*Segment {
	path := make([]*Segment, 0)
	for i := m - 1; i > 0; i-- {
		path = append(path, addSegment('U', n-1, k)...)
		path = append(path, addSegment('D', n-1, k)...)
		path = append(path, addSegment('L', 1, k)...)
	}
	path = append(path, addSegment('U', n-1, k)...)
	return path
}

func main() {
	f := os.Stdin
	out := os.Stdout
	// f, 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(f, 1000010)

	n := NextInt()
	m := NextInt()
	k := NextInt()

	path := buildHorizontalPath(n, m, &k)
	path = append(path, buildVerticalPath(n, m, &k)...)
	if k > 0 {
		fmt.Fprintln(out, "NO")
	} else {
		fmt.Fprintln(out, "YES")
		fmt.Fprintln(out, len(path))
		for _, segment := range path {
			fmt.Fprintln(out, segment.Count, segment.Path)
		}
	}
}

package main

import (
	"fmt"
)

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

	if 4*n*m-2*n-2*m < k {
		fmt.Println("NO")
		return
	}

	cc, p := (&PathFinder{}).findPath(n, m, k)

	fmt.Println("YES")
	fmt.Println(len(cc))
	for i := 0; i < len(cc); i++ {
		fmt.Printf("%d %s\n", cc[i], p[i])
	}
}

type PathFinder struct {
	count []int
	path  []string
}

func (p *PathFinder) findPath(n, m, k int) ([]int, []string) {
	p.path = nil
	p.count = nil

	k -= p.goDown(n, k)

	for i := n - 1; i >= 0; i-- {
		k -= p.goRight(m, i, k)
		k -= p.goLeft(m, k)
		k -= p.goUp(i, k)
	}

	return p.count, p.path
}

func (p *PathFinder) goDown(n, k int) int {
	if k == 0 || n == 1 {
		return 0
	}
	p.count = append(p.count, min(k, n-1))
	p.path = append(p.path, "D")

	return min(k, n-1)
}

func (p *PathFinder) goUp(r, k int) int {
	if k == 0 || r == 0 {
		return 0
	}
	p.count = append(p.count, 1)
	p.path = append(p.path, "U")
	return 1
}

func (p *PathFinder) goRight(m, r, k int) int {
	if k == 0 || m == 1 {
		return 0
	}

	if r == 0 {
		p.count = append(p.count, min(k, m-1))
		p.path = append(p.path, "R")
		return min(k, m-1)
	}

	if 3*(m-1) >= k {
		cc := k / 3
		if cc > 0 {
			p.count = append(p.count, cc)
			p.path = append(p.path, "RUD")
		}

		rem := k % 3
		if rem > 0 {
			p.count = append(p.count, 1)
			if rem == 1 {
				p.path = append(p.path, "R")
			} else {
				p.path = append(p.path, "RU")
			}
		}

		return k
	}

	p.count = append(p.count, m-1)
	p.path = append(p.path, "RUD")

	return 3 * (m - 1)
}

func (p *PathFinder) goLeft(m, k int) int {
	if k == 0 || m == 1 {
		return 0
	}
	p.count = append(p.count, min(k, m-1))
	p.path = append(p.path, "L")

	return min(k, m-1)
}

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

package main

import (
	"fmt"
)

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

	cc, p := (&PathFinder{}).findPath(n, m, k)

	tot := 0
	for i := 0; i < len(cc); i++ {
		tot += len(p[i]) * cc[i]
	}

	if k <= 4*n*m-2*n-2*m && tot < k {
		panic("Impossible")
	}

	if tot < k {
		fmt.Println("NO")
		return
	}

	fmt.Println("YES")
	fmt.Println(len(cc))
	for i := 0; i < len(cc); i++ {
		fmt.Printf("%d %s\n", cc[i], p[i])
	}
}

type PathFinder struct {
	count []int
	path  []string
}

func (p *PathFinder) findPath(n, m, k int) ([]int, []string) {
	k -= p.goDown(n, k)

	for i := n - 1; i >= 0; i-- {
		k -= p.goRight(m, i, k)
		k -= p.goLeft(m, k)
		k -= p.goUp(i, k)
	}

	return p.count, p.path
}

func (p *PathFinder) goDown(n, k int) int {
	if k == 0 || n == 1 {
		return 0
	}
	p.count = append(p.count, min(k, n-1))
	p.path = append(p.path, "D")

	return min(k, n-1)
}

func (p *PathFinder) goUp(r, k int) int {
	if k == 0 || r == 0 {
		return 0
	}
	p.count = append(p.count, 1)
	p.path = append(p.path, "U")
	return 1
}

func (p *PathFinder) goRight(m, r, k int) int {
	if k == 0 || m == 1 {
		return 0
	}

	if r == 0 {
		p.count = append(p.count, min(k, m-1))
		p.path = append(p.path, "R")
		return min(k, m-1)
	}

	if 3*(m-1) >= k {
		cc := k / 3
		if cc > 0 {
			p.count = append(p.count, cc)
			p.path = append(p.path, "RUD")
		}

		rem := k % 3
		if rem > 0 {
			p.count = append(p.count, 1)
			if rem == 1 {
				p.path = append(p.path, "R")
			} else {
				p.path = append(p.path, "RU")
			}
		}

		return k
	}

	p.count = append(p.count, m-1)
	p.path = append(p.path, "RUD")

	return 3 * (m - 1)
}

func (p *PathFinder) goLeft(m, k int) int {
	if k == 0 || m == 1 {
		return 0
	}
	p.count = append(p.count, min(k, m-1))
	p.path = append(p.path, "L")

	return min(k, m-1)
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
var dp [405][405]int
var f [405][26]int
func solve() {
}
type Ans struct {
	num int
	str string
}
func main() {
	n, m, k := ReadInt(), ReadInt(), ReadInt()
	if k > (4 * n * m - 2 * n - 2 * m) {
		fmt.Println("NO")
		return
	}
	jie := []Ans{}
	cat := 0
	fmt.Println("YES")
	if m == 1 {
		if k < n - 1 {
			cat = 1
			jie = append(jie, Ans{k, "D"})
		} else {
			cat = 2
			jie = append(jie, Ans{n - 1, "D"})
			jie = append(jie, Ans{k - (n - 1), "U"})
		}
	} else  if n == 1 {
		if k < m - 1 {
			cat = 1
			jie = append(jie, Ans{k,"R"})
		} else {
			cat = 2
			jie = append(jie, Ans{m - 1,"R"})
			jie = append(jie, Ans{k - (m - 1),"L"})
		}
	} else {
		for i := 1; i <= n && k > 0; i++ {
			if i != n {
				cat++
				if k < m - 1 {
					jie = append(jie, Ans{k,"R"})
					k = 0
				} else {
					jie = append(jie, Ans{m - 1,"R"})
					k -= (m - 1)
				}
				if k > 0 {
					cat++
					if k < (m - 1) * 3 {
						num := k / 3
						if num > 0 {
							k -= num * 3
							jie = append(jie, Ans{num,"DUL"})
							if k != 0 {
								cat++
							}
						}
						switch k {
							case 1 : jie = append(jie, Ans{1,"D"})
							case 2 : jie = append(jie, Ans{1,"DU"})
						}
						k = 0

					} else {
						jie = append(jie, Ans{m - 1,"DUL"})
						k -= (m - 1) * 3
					}
				}
				if k > 0 {
					k--
					cat++
					jie = append(jie, Ans{1,"D"})
				}
			} else {
				cat++
				if k < m - 1 {
					jie = append(jie, Ans{k,"R"})
					k = 0
				} else {
					jie = append(jie, Ans{m - 1, "R"})
					k -= (m - 1)
				}
				if k > 0 {
					cat++
					if k < m - 1 {
						jie = append(jie, Ans{k, "L"})
						k = 0
					} else {
						jie = append(jie, Ans{m - 1, "L"})
						k -= (m - 1)
					}
				}
				if k > 0 {
					cat++
					jie = append(jie, Ans{k, "U"})
					k = 0
				}
			}
		}
	}
	fmt.Println(cat)
	for _, ans := range jie {
		fmt.Println(ans.num, ans.str)
	}
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

package main

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

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

	var n, m, k int
	Fscan(in, &n, &m, &k)
	if k > 4*n*m-2*n-2*m {
		Fprint(out, "NO")
		return
	}

	type pair struct {
		times int
		op    string
	}
	ans := []pair{}
	makeAns := func(ops []string, maxTimes, left int) int {
		for _, op := range ops {
			if left <= len(op)*maxTimes {
				if left > 0 {
					if len(op) == 1 {
						ans = append(ans, pair{left, op})
					} else {
						a, b := left/3, left%3
						if a > 0 {
							ans = append(ans, pair{a, op})
						}
						if b > 0 {
							ans = append(ans, pair{1, op[:b]})
						}
					}
				}
				return 0
			}
			ans = append(ans, pair{maxTimes, op})
			left -= len(op) * maxTimes
		}
		return left
	}
	printAns := func() {
		Fprintln(out, "YES")
		Fprintln(out, len(ans))
		for _, a := range ans {
			Fprintln(out, a.times, a.op)
		}
	}

	if n == 1 {
		makeAns([]string{"R", "L"}, m-1, k)
		printAns()
		return
	}
	var cycleNum, left int
	if cycleSize := 4*(n-1) + 1; k <= cycleSize*(m-1) {
		cycleNum, left = k/cycleSize, k%cycleSize
		k = 0
	} else {
		cycleNum, left = m-1, 0
		k -= cycleSize * (m - 1)
	}
	for i := 0; i < cycleNum; i++ {
		ans = append(ans, pair{n - 1, "D"}, pair{n - 1, "RLU"}, pair{1, "R"})
	}
	makeAns([]string{"D", "RLU"}, n-1, left)
	k = makeAns([]string{"D", "U"}, n-1, k)
	if k > 0 {
		ans = append(ans, pair{k, "L"})
	}
	printAns()
}

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

package main

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

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

	var n, m, k int
	Fscan(in, &n, &m, &k)
	roads := 4*n*m - 2*n - 2*m
	if k > roads {
		Fprint(out, "NO")
		return
	}

	type pair struct {
		times int
		op    string
	}
	ans := []pair{}
	printAns := func() {
		Fprintln(out, "YES")
		Fprintln(out, len(ans))
		for _, an := range ans {
			Fprintln(out, an.times, an.op)
		}
	}

	if n == 1 {
		if k <= m-1 {
			ans = append(ans, pair{k, "R"})
			k = 0
		} else {
			ans = append(ans, pair{m - 1, "R"})
			k -= m - 1
		}
		if k > 0 {
			ans = append(ans, pair{k, "L"})
		}
		printAns()
		return
	}
	cycleSize := 4*(n-1) + 1
	allCycleSize := cycleSize * (m - 1)
	cycleNum, left := 0, 0
	if k <= allCycleSize {
		cycleNum, left = k/cycleSize, k%cycleSize
		k = 0
	} else {
		cycleNum, left = m-1, 0
		k -= allCycleSize
	}

	for i := 0; i < cycleNum; i++ {
		ans = append(ans,
			pair{n - 1, "D"},
			pair{n - 1, "RLU"},
			pair{1, "R"},
		)
	}

	if left > 0 {
		if left <= n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "D"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n - 1, "D"})
			left -= n - 1
		}
		if left <= 3*(n-1) {
			if left > 0 {
				a, b := left/3, left%3
				if a > 0 {
					ans = append(ans, pair{a, "RLU"})
				}
				if b > 0 {
					ans = append(ans, pair{1, "RLU"[:b]})
				}
			}
			left = 0
		} else {
			ans = append(ans, pair{n - 1, "RLU"})
			left -= 3 * (n - 1)
		}
		if left > 0 {
			ans = append(ans, pair{left, "U"})
		}
	}

	if k > 0 {
		left = k
		if left <= n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "D"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n - 1, "D"})
			left -= n - 1
		}
		if left <= n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "U"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n - 1, "U"})
			left -= n - 1
		}
		if left > 0 {
			ans = append(ans, pair{left, "L"})
		}
	}
	printAns()
}

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

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > 3*(m-1) {
			k -= 3 * (m - 1)
			res = append(res, Step{m - 1, "RDU"})
		} else {
			if k >= 3 {
				res = append(res, Step{k / 3, "RDU"})
			}
			if k%3 == 1 {
				res = append(res, Step{1, "R"})
			} else if k%3 == 2 {
				res = append(res, Step{1, "RD"})
			}
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			if k > 0 {
				res = append(res, Step{k, "L"})
			}
			return res
		}

		if k > 0 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "R"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "R"})
		}
		return res
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "L"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "L"})
		}
		return res
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "U"})
		}
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type node struct {
	diff int
	time int
}

type ByTime []node

func (a ByTime) Len() int           { return len(a) }
func (a ByTime) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByTime) Less(i, j int) bool { return a[i].time < a[j].time }

var p []int
var c []int
var children [][]int
var invalid bool

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	//fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, m, k := 0, 0, 0
		fmt.Fscanf(in, "%d %d %d\n", &n, &m, &k)
		total := 4*n*m - 2*n - 2*m
		if total < k {
			fmt.Fprintf(out, "NO\n")
			return
		}
		out1 := make([]int, 0)
		out2 := make([]string, 0)
		cur := 0
		// First line ->
		if cur+(m-1) >= k {
			out1 = append(out1, k-cur)
			out2 = append(out2, "R")
			output(out, out1, out2)
			return
		}
		out1 = append(out1, m-1)
		out2 = append(out2, "R")
		cur += m - 1
		// First line <-
		if cur+(m-1) >= k {
			out1 = append(out1, k-cur)
			out2 = append(out2, "L")
			output(out, out1, out2)
			return
		}
		out1 = append(out1, m-1)
		out2 = append(out2, "L")
		cur += m - 1
		for i := 0; i < n-1; i++ {
			cur++
			out1 = append(out1, 1)
			out2 = append(out2, "D")
			if cur >= k {
				output(out, out1, out2)
				return
			}
			if cur+3*(m-1) >= k {
				round := (k - cur) / 3
				if round > 0 {
					out1 = append(out1, round)
					out2 = append(out2, "RUD")
				}
				if (k-cur)%3 == 1 {
					out1 = append(out1, 1)
					out2 = append(out2, "R")
				} else if (k-cur)%3 == 2 {
					out1 = append(out1, 2)
					out2 = append(out2, "RU")
				}
				output(out, out1, out2)
				return
			}
			out1 = append(out1, m-1)
			out2 = append(out2, "RUD")
			cur += (m - 1) * 3
			if cur+(m-1) >= k {
				round := k - cur
				out1 = append(out1, round)
				out2 = append(out2, "L")
				output(out, out1, out2)
				return
			}
			out1 = append(out1, m-1)
			out2 = append(out2, "L")
			cur += m - 1
		}
		out1 = append(out1, k-cur)
		out2 = append(out2, "U")
		output(out, out1, out2)
	}
	return
}

func output(w io.Writer, out1 []int, out2 []string) {
	n := len(out1)
	tmpN := n
	for i := 0; i < len(out1); i++ {
		if out1[i] == 0 {
			tmpN--
		}
	}
	fmt.Fprintf(w, "YES\n")
	fmt.Fprintf(w, "%d\n", tmpN)
	for i := 0; i < n; i++ {
		if out1[i] > 0 {
			fmt.Fprintf(w, "%d %s\n", out1[i], out2[i])
		}
	}
	return
}

package main

import (
	"fmt"
)

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

	cc, p := (&PathFinder{}).findPath(n, m, k)

	tot := 0
	for i := 0; i < len(cc); i++ {
		tot += len(p[i]) * cc[i]
	}

	if k <= 4*n*m-2*n-2*m && tot < k {
		panic("Impossible")
	}

	if tot < k {
		fmt.Println("NO")
		return
	}

	fmt.Println("YES")
	fmt.Println(len(cc))
	for i := 0; i < len(cc); i++ {
		fmt.Printf("%d %s\n", cc[i], p[i])
	}
}

type PathFinder struct {
	count []int
	path  []string
}

func (p *PathFinder) findPath(n, m, k int) ([]int, []string) {
	k -= p.goDown(n, k)

	for i := n - 1; i >= 0; i-- {
		k -= p.goRight(m, i, k)
		k -= p.goLeft(m, k)
		k -= p.goUp(i, k)
	}

	return p.count, p.path
}

func (p *PathFinder) goDown(n, k int) int {
	if k == 0 || n == 1 {
		return 0
	}
	p.count = append(p.count, min(k, n-1))
	p.path = append(p.path, "D")

	return min(k, n-1)
}

func (p *PathFinder) goUp(r, k int) int {
	if k == 0 || r == 0 {
		return 0
	}
	p.count = append(p.count, 1)
	p.path = append(p.path, "U")
	return 1
}

func (p *PathFinder) goRight(m, r, k int) int {
	if k == 0 || m == 1 {
		return 0
	}

	if r == 0 {
		p.count = append(p.count, min(k, m-1))
		p.path = append(p.path, "R")
		return min(k, m-1)
	}

	if 3*(m-1) >= k {
		cc := k / 3
		if cc > 0 {
			p.count = append(p.count, cc)
			p.path = append(p.path, "RUD")
		}

		rem := k % 3
		if rem > 0 {
			p.count = append(p.count, 1)
			if k == 1 {
				p.path = append(p.path, "R")
			} else {
				p.path = append(p.path, "RU")
			}
		}

		return k
	}

	p.count = append(p.count, m-1)
	p.path = append(p.path, "RUD")

	return 3 * (m - 1)
}

func (p *PathFinder) goLeft(m, k int) int {
	if k == 0 || m == 1 {
		return 0
	}
	p.count = append(p.count, min(k, m-1))
	p.path = append(p.path, "L")

	return min(k, m-1)
}

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

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"sync"
)
var dp [405][405]int
var f [405][26]int
func solve() {
}
type Ans struct {
	num int
	str string
}
func main() {
	n, m, k := ReadInt(), ReadInt(), ReadInt()
	if k > (4 * n * m - 2 * n - 2 * m) {
		fmt.Println("NO")
		return
	}
	jie := []Ans{}
	cat := 0
	fmt.Println("YES")
	if m == 1 {
		if k < n - 1 {
			cat = 1
			jie = append(jie, Ans{k, "D"})
		} else {
			cat = 2
			jie = append(jie, Ans{n - 1, "D"})
			jie = append(jie, Ans{k - (n - 1), "U"})
		}
	} else  if n == 1 {
		if k < m - 1 {
			cat = 1
			jie = append(jie, Ans{k,"R"})
		} else {
			cat = 2
			jie = append(jie, Ans{m - 1,"R"})
			jie = append(jie, Ans{k - (m - 1),"L"})
		}
	} else {
		for i := 1; i <= n && k > 0; i++ {
			if i != n {
				cat++
				if k < m - 1 {
					jie = append(jie, Ans{k,"R"})
					k = 0
				} else {
					jie = append(jie, Ans{m - 1,"R"})
					k -= (m - 1)
				}
				if k > 0 {
					cat++
					if k < (m - 1) * 3 {
						num := k / 3
						if num > 0 {
							k -= num * 3
							jie = append(jie, Ans{num,"DUl"})
							if k != 0 {
								cat++
							}
						}
						switch k {
							case 1 : jie = append(jie, Ans{1,"D"})
							case 2 : jie = append(jie, Ans{1,"DU"})
						}
						k = 0

					} else {
						jie = append(jie, Ans{m - 1,"DUL"})
						k -= (m - 1) * 3
					}
				}
				if k > 0 {
					k--
					cat++
					jie = append(jie, Ans{1,"D"})
				}
			} else {
				cat++
				if k < m - 1 {
					jie = append(jie, Ans{k,"R"})
					k = 0
				} else {
					jie = append(jie, Ans{m - 1, "R"})
					k -= (m - 1)
				}
				if k > 0 {
					cat++
					if k < m - 1 {
						jie = append(jie, Ans{k, "L"})
						k = 0
					} else {
						jie = append(jie, Ans{m - 1, "L"})
						k -= (m - 1)
					}
				}
				if k > 0 {
					cat++
					jie = append(jie, Ans{k, "U"})
					k = 0
				}
			}
		}
	}
	fmt.Println(cat)
	for _, ans := range jie {
		fmt.Println(ans.num, ans.str)
	}
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
var out chan string
var in *bufio.Scanner
var outWg *sync.WaitGroup
func ReadString() string {
	in.Scan()
	return in.Text()
}
func ReadStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ReadString()
	}
	return s
}
func ReadInt() int {
	intStr := ReadString()
	i, _ := strconv.ParseInt(intStr, 10, 32)
	return int(i)
}
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
func init() {
	//set input
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(2e+5))
	in.Split(bufio.ScanWords)

	//set output
	out = make(chan string, 16)
	outWg = &sync.WaitGroup{}
	outWg.Add(1)

	writer := bufio.NewWriterSize(os.Stdout, int(2e+5))
	go func(write *bufio.Writer) {
		defer outWg.Done()
		defer write.Flush()

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

package main

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

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

	var n, m, k int
	Fscan(in, &n, &m, &k)
	if k > 4*n*m-2*n-2*m {
		Fprint(out, "NO")
		return
	}

	type pair struct {
		times int
		op    string
	}
	ans := []pair{}
	printAns := func() {
		Fprintln(out, "YES")
		Fprintln(out, len(ans))
		for _, a := range ans {
			Fprintln(out, a.times, a.op)
		}
	}
	makeAns := func(ops []string, maxTimes, left int) {
		for _, op := range ops {
			if left <= len(op)*maxTimes {
				if left > 0 {
					if len(op) == 1 {
						ans = append(ans, pair{left, op})
					} else {
						a, b := left/3, left%3
						if a > 0 {
							ans = append(ans, pair{a, op})
						}
						if b > 0 {
							ans = append(ans, pair{1, op[:b]})
						}
					}
				}
				return
			}
			ans = append(ans, pair{maxTimes, op})
			left -= len(op) * maxTimes
		}
	}

	if n == 1 {
		makeAns([]string{"R", "L"}, m-1, k)
		printAns()
		return
	}

	cycleSize := 4*(n-1) + 1
	allCycleSize := cycleSize * (m - 1)
	cycleNum, left := 0, 0
	if k <= allCycleSize {
		cycleNum, left = k/cycleSize, k%cycleSize
		k = 0
	} else {
		cycleNum, left = m-1, 0
		k -= allCycleSize
	}
	for i := 0; i < cycleNum; i++ {
		ans = append(ans, pair{n - 1, "D"}, pair{n - 1, "RLU"}, pair{1, "R"})
	}
	makeAns([]string{"D", "RLU"}, n-1, left)
	makeAns([]string{"D", "U", "L"}, n-1, k)
	printAns()
}

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

package main

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

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

	var n, m, k int
	Fscan(in, &n, &m, &k)

	roads := 4*n*m - 2*n - 2*m
	if k > roads {
		Fprint(out, "NO")
		return
	}

	type pair struct {
		cnt int
		op  string
	}
	ans := []pair{}

	cycleSize := 4*(n-1) + 1
	allCycleSize := cycleSize * (m - 1)
	cycleNum, left := 0, 0
	if k <= allCycleSize {
		cycleNum, left = k/cycleSize, k%cycleSize
		k = 0
	} else {
		cycleNum, left = m-1, 0
		k-=allCycleSize
	}

	// do cycle
	for i := 0; i < cycleNum; i++ {
		ans = append(ans,
			pair{n - 1, "D"},
			pair{n - 1, "RLU"},
			pair{1, "R"},
		)
	}

	// do left length
	if left > 0 {
		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "D"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "D"})
			left -=n-1
		}

		if left <=3*(n-1) {
			if left > 0 {
				a,b := left/3,left%3
				if a>0{
					ans = append(ans, pair{a, "RLU"})
				}
				if b > 0 {
					ans = append(ans,pair{1, "RLU"[:b]})
				}
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "RLU"})
			left -=3*(n-1)
		}

		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "U"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "U"})
			left -=n-1
			// ?? panic
		}
	}

	if k > 0 {
		left = k
		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "D"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "D"})
			left -=n-1
		}

		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "U"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "U"})
			left -=n-1
		}

		if left > 0 {
			ans = append(ans, pair{left, "L"})
		}
	}

	if len(ans) > 3000 {
		Fprintln(out, "NO")
		return
	}

	Fprintln(out, "YES")

	Fprintln(out, len(ans))
	for _, an := range ans {
		Fprintln(out, an.cnt, an.op)
	}
}

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

package main

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

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

	var n, m, k int
	Fscan(in, &n, &m, &k)
	if k > 4*n*m-2*n-2*m {
		Fprint(out, "NO")
		return
	}

	type pair struct {
		times int
		op    string
	}
	ans := []pair{}
	makeAns := func(ops []string, maxTimes, left int) {
		for i, op := range ops {
			if i == len(ops)-1 {
				ans = append(ans, pair{left, op})
				return
			}
			if left <= len(op)*maxTimes {
				if left > 0 {
					if len(op) == 1 {
						ans = append(ans, pair{left, op})
					} else {
						a, b := left/3, left%3
						if a > 0 {
							ans = append(ans, pair{a, op})
						}
						if b > 0 {
							ans = append(ans, pair{1, op[:b]})
						}
					}
				}
				return
			}
			ans = append(ans, pair{maxTimes, op})
			left -= len(op) * maxTimes
		}
	}
	printAns := func() {
		Fprintln(out, "YES")
		Fprintln(out, len(ans))
		for _, a := range ans {
			Fprintln(out, a.times, a.op)
		}
	}

	if n == 1 {
		makeAns([]string{"R", "L"}, m-1, k)
		printAns()
		return
	}
	var cycleNum, left int
	if cycleSize := 4*(n-1) + 1; k <= cycleSize*(m-1) {
		cycleNum, left = k/cycleSize, k%cycleSize
		k = 0
	} else {
		cycleNum, left = m-1, 0
		k -= cycleSize * (m - 1)
	}
	for i := 0; i < cycleNum; i++ {
		ans = append(ans, pair{n - 1, "D"}, pair{n - 1, "RLU"}, pair{1, "R"})
	}
	makeAns([]string{"D", "RLU"}, n-1, left)
	makeAns([]string{"D", "U", "L"}, n-1, k)
	printAns()
}

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

package main

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

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

	var n, m, k int
	Fscan(in, &n, &m, &k)

	roads := 4*n*m - 2*n - 2*m
	if k > roads {
		Fprint(out, "NO")
		return
	}
	Fprintln(out, "YES")

	type pair struct {
		cnt int
		op  string
	}
	ans := []pair{}

	cycleSize := 4*(n-1) + 1
	allCycleSize := cycleSize * (m - 1)
	cycleNum, left := 0, 0
	if k <= allCycleSize {
		cycleNum, left = k/cycleSize, k%cycleSize
		k = 0
	} else {
		cycleNum, left = m-1, 0
		k-=allCycleSize
	}

	// do cycle
	for i := 0; i < cycleNum; i++ {
		ans = append(ans,
			pair{n - 1, "D"},
			pair{n - 1, "RLU"},
			pair{1, "R"},
		)
	}

	// do left length
	if left > 0 {
		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "D"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "D"})
			left -=n-1
		}

		if left <=3*(n-1) {
			if left > 0 {
				a,b := left/3,left%3
				if a>0{
					ans = append(ans, pair{a, "RLU"})
				}
				if b > 0 {
					ans = append(ans,pair{1, "RLU"[:b]})
				}
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "RLU"})
			left -=3*(n-1)
		}

		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "U"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "U"})
			left -=n-1
			// ?? panic
		}
	}

	if k > 0 {
		left = k
		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "D"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "D"})
			left -=n-1
		}

		if left <=n-1 {
			if left > 0 {
				ans = append(ans, pair{left, "U"})
			}
			left = 0
		} else {
			ans = append(ans, pair{n-1, "U"})
			left -=n-1
		}

		if left > 0 {
			ans = append(ans, pair{left, "L"})
		}
	}

	Fprintln(out, len(ans))
	for _, an := range ans {
		Fprintln(out, an.cnt, an.op)
	}
}

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

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > 3*(m-1) {
			k -= 3 * (m - 1)
			res = append(res, Step{m - 1, "RDU"})
		} else {
			if k > 3 {
				res = append(res, Step{k / 3, "RDU"})
			}
			if k%3 == 1 {
				res = append(res, Step{1, "R"})
			} else if k%3 == 2 {
				res = append(res, Step{2 / k, "RD"})
			}
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}

		if k > 1 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "R"})
	} else {
		res = append(res, Step{k, "R"})
		return res
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "L"})
	} else {
		res = append(res, Step{k, "L"})
		return res
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		res = append(res, Step{k, "U"})
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > 3*(m-1) {
			k -= 3 * (m - 1)
			res = append(res, Step{m - 1, "RDU"})
		} else {
			if k >= 3 {
				res = append(res, Step{k / 3, "RDU"})
			}
			if k%3 == 1 {
				res = append(res, Step{1, "R"})
			} else if k%3 == 2 {
				res = append(res, Step{2 / k, "RD"})
			}
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			if k > 0 {
				res = append(res, Step{k, "L"})
			}
			return res
		}

		if k > 0 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "R"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "R"})
		}
		return res
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "L"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "L"})
		}
		return res
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "U"})
		}
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > 3*(m-1) {
			k -= 3 * (m - 1)
			res = append(res, Step{m - 1, "RDU"})
		} else {
			if k >= 3 {
				res = append(res, Step{k / 3, "RDU"})
			}
			if k%3 == 1 {
				res = append(res, Step{1, "R"})
			} else if k%3 == 2 {
				res = append(res, Step{2 / k, "RD"})
			}
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}

		if k > 1 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "R"})
	} else {
		res = append(res, Step{k, "R"})
		return res
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "L"})
	} else {
		res = append(res, Step{k, "L"})
		return res
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		res = append(res, Step{k, "U"})
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > 3*(m-1) {
			k -= m - 1
			res = append(res, Step{m - 1, "RDU"})
		} else {
			if k > 3 {
				res = append(res, Step{k / 3, "RDU"})
			}
			if k%3 == 1 {
				res = append(res, Step{1, "R"})
			} else if k%3 == 2 {
				res = append(res, Step{2 / k, "RD"})
			}
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}

		if k > 1 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "R"})
	} else {
		res = append(res, Step{k, "R"})
		return res
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "L"})
	} else {
		res = append(res, Step{k, "L"})
		return res
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		res = append(res, Step{k, "U"})
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > 3*(m-1) {
			k -= 3 * (m - 1)
			res = append(res, Step{m - 1, "RDU"})
		} else {
			if k >= 3 {
				res = append(res, Step{k / 3, "RDU"})
			}
			if k%3 == 1 {
				res = append(res, Step{1, "R"})
			} else if k%3 == 2 {
				res = append(res, Step{2 / k, "RD"})
			}
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}

		if k >= 1 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "R"})
	} else {
		res = append(res, Step{k, "R"})
		return res
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "L"})
	} else {
		res = append(res, Step{k, "L"})
		return res
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		res = append(res, Step{k, "U"})
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}

		if k > 1 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "R"})
	} else {
		res = append(res, Step{k, "R"})
		return res
	}

	for i := 0; i < m-1; i++ {
		if k > n-1 {
			k -= n - 1
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}

		if k > n-1 {
			k -= n - 1
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}

		if k > 1 {
			k--
			res = append(res, Step{1, "L"})
		} else {
			return res
		}
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		res = append(res, Step{k, "U"})
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}

		if k > 1 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "R"})
	} else {
		res = append(res, Step{k, "R"})
		return res
	}

	for i := 0; i < m-1; i++ {
		if k > n-1 {
			k -= n - 1
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}

		if k > n-1 {
			k -= n - 1
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}

		if k > 1 {
			k--
			res = append(res, Step{1, "L"})
		} else {
			return res
		}
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		res = append(res, Step{k, "U"})
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}

package main

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

type Step struct {
	n int
	d string
}

func solve(n, m, k int) []Step {
	res := make([]Step, 0)
	if k > 4*n*m-2*n-2*m {
		return res
	}

	if n == 1 {
		if k > m-1 {
			res = append(res, Step{m - 1, "R"})
		} else {
			res = append(res, Step{k, "R"})
			return res
		}
		if k > m-1 {
			res = append(res, Step{m - 1, "L"})
		} else {
			res = append(res, Step{k, "L"})
			return res
		}
		return res
	}
	if m == 1 {
		if k > n-1 {
			res = append(res, Step{n - 1, "D"})
		} else {
			res = append(res, Step{k, "D"})
			return res
		}
		if k > n-1 {
			res = append(res, Step{n - 1, "U"})
		} else {
			res = append(res, Step{k, "U"})
			return res
		}
		return res
	}

	for i := 0; i < n-1; i++ {
		if k > 3*(m-1) {
			k -= 3 * (m - 1)
			res = append(res, Step{m - 1, "RDU"})
		} else {
			if k >= 3 {
				res = append(res, Step{k / 3, "RDU"})
			}
			if k%3 == 1 {
				res = append(res, Step{1, "R"})
			} else if k%3 == 2 {
				res = append(res, Step{2, "RD"})
			}
			return res
		}

		if k > m-1 {
			k -= m - 1
			res = append(res, Step{m - 1, "L"})
		} else {
			if k > 0 {
				res = append(res, Step{k, "L"})
			}
			return res
		}

		if k > 0 {
			k--
			res = append(res, Step{1, "D"})
		} else {
			return res
		}
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "R"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "R"})
		}
		return res
	}

	if k > m-1 {
		k -= m - 1
		res = append(res, Step{m - 1, "L"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "L"})
		}
		return res
	}

	if k > n-1 {
		k -= n - 1
		res = append(res, Step{n - 1, "U"})
	} else {
		if k > 0 {
			res = append(res, Step{k, "U"})
		}
		return res
	}
	return res
}

func main() {
	out := bufio.NewWriter(os.Stdout)
	var n, m, k int
	fmt.Scanln(&n, &m, &k)
	res := solve(n, m, k)
	if len(res) == 0 {
		fmt.Println("NO")
		return
	}
	fmt.Fprintln(out, "YES")
	fmt.Fprintln(out, len(res))
	for _, step := range res {
		fmt.Fprintln(out, step.n, step.d)
	}
	out.Flush()

}


For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got one hour! Solve it!  Wheatley decided to try to make a test chamber. He made a nice test chamber, but there was only one detail absent — cubes.For completing the chamber Wheatley needs $$$n$$$ cubes. $$$i$$$-th cube has a volume $$$a_i$$$.Wheatley has to place cubes in such a way that they would be sorted in a non-decreasing order by their volume. Formally, for each $$$i>1$$$, $$$a_{i-1} \le a_i$$$ must hold.To achieve his goal, Wheatley can exchange two neighbouring cubes. It means that for any $$$i>1$$$ you can exchange cubes on positions $$$i-1$$$ and $$$i$$$.But there is a problem: Wheatley is very impatient. If Wheatley needs more than $$$\frac{n \cdot (n-1)}{2}-1$$$ exchange operations, he won't do this boring work.Wheatly wants to know: can cubes be sorted under this conditions?

Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The second line contains $$$n$$$ positive integers $$$a_i$$$ ($$$1 \le a_i \le 10^9$$$) — volumes of cubes. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.

NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".

package main

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

var in *bufio.Reader
var out *bufio.Writer

func printf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, x, a...)
}

func scanf(x string, a ...interface{}) (n int, err error) {
	return fmt.Fscanf(in, x, a...)
}

func scan(a ...interface{}) (n int, err error) {
	return fmt.Fscan(in, a...)
}

var err error

func next() (n string) {
	scan(&n)
	return n
}

func nextInt() (n int) {
	scan(&n)
	return n
}

func nextLong() (n int64) {
	scan(&n)
	return n
}

func nextDouble() (n float64) {
	scan(&n)
	return n
}

func solve() {
	n := nextInt()
	arr := make([]int, n)
	for i := range arr {
		arr[i] = nextInt()
	}
	for i := 1; i < n; i++ {
		if arr[i] >= arr[i-1] {
			printf("YES\n")
			return
		}
	}
	printf("NO\n")
}

func main() {
	in = bufio.NewReaderSize(os.Stdin, 8192)
	out = bufio.NewWriterSize(os.Stdout, 8192)
	if false {
		name := "in"
		file1, err := os.Open(name + ".in")
		if err != nil {
			log.Fatal(err)
		}
		file2, err := os.Create(name + ".out")
		if err != nil {
			log.Fatal(err)
		}
		in = bufio.NewReaderSize(file1, 8192)
		out = bufio.NewWriterSize(file2, 8192)
	}
	defer out.Flush()
	// start := time.Now()

	for t, i := nextInt(), 1; t > 0; t, i = t-1, i+1 {
		// printf("Case #%d:\n", i)
		solve()
	}

	// printf("%v\n", time.Now().Sub(start))
}

package main

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

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

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

	for o := 0; o < t; o++ {
		var (
			pre = 1000000009
			n = 0
			x = 0
			ans = "NO"
		)
		fmt.Fscan(in, &n)

		for i := 0; i < n; i++ {
			fmt.Fscan(in, &x)
			if pre <= x {
				ans = "YES"
			}
			pre = x
		}

		fmt.Println(ans)
	}

}

package main

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

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

	tc := readNum(reader)
	var buf bytes.Buffer
	for tc > 0 {
		tc--
		n := readNum(reader)
		A := readNNums(reader, n)
		res := solve(n, A)
		if res {
			buf.WriteString("YES\n")
		} else {
			buf.WriteString("NO\n")
		}
	}
	fmt.Print(buf.String())
}

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') && bs[x] != '-' {
			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(n int, A []int) bool {
	for i := 1; i < n; i++ {
		if A[i] >= A[i-1] {
			return true
		}
	}
	return false
	//P := make([]Pair, n)
	//for i := 0; i < n; i++ {
	//	P[i] = Pair{A[i], i}
	//}
	//
	//sort.Sort(Pairs(P))
	//var cnt int64
	//for i := 0; i < n; i++ {
	//	cur := P[i]
	//	j := cur.second
	//	if i < j {
	//		cnt += int64(j - i)
	//	}
	//}
	//tot := int64(n)*int64(n-1)/2 - 1
	//return cnt <= tot
}

type Pair struct {
	first, second int
}

type Pairs []Pair

func (ps Pairs) Len() int {
	return len(ps)
}

func (ps Pairs) Less(i, j int) bool {
	return ps[i].first < ps[j].first || ps[i].first == ps[j].first && ps[i].second < ps[j].second
}

func (ps Pairs) Swap(i, j int) {
	ps[i], ps[j] = ps[j], ps[i]
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	for t := in(); t > 0; t-- {
		n := in()
		a := make([]int, n)

		for i := range a {
			a[i] = in()
		}

		okay := true

		for i := 0; i < n-1; i++ {
			if a[i] <= a[i+1] {
				okay = false
				break
			}
		}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var n int
		fmt.Fscan(in, &n)
		prev := 0
		ans := "NO"
		for j := 0; j < n; j++ {
			var x int
			fmt.Fscan(in, &x)
			if j > 0 && prev <= x {
				ans = "YES"
			}
			prev = x
		}
		fmt.Println(ans)
	}
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

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

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.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 suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

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
}

func main() {
	defer writer.Flush()
	t := sint64()
	for ; t > 0; t-- {
		n := sint64()
		a := make([]int64, n)
		for i := range a {
			a[i] = sint64()
		}
		printf("%s\n", sol(n, a))
	}
}

func sol(n int64, a []int64) string {
	for i := int64(1); i < n; i++ {
		if a[i] >= a[i-1] {
			return "YES"
		}
	}
	return "NO"
}

package main

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

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(in, &t)
	for o := 0; o < t; o++ {
		var n int
		minx := 1000000001
		fmt.Fscan(in, &n)
		for i := 0; i < n; i++ {
			var x int
			fmt.Fscan(in, &x)
			if minx <= x {
				fmt.Println("YES")
				goto end
			}
			minx = Min(minx, x)
		}
		fmt.Println("NO")
		end:
	}

}

package main

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

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


Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working on a project, the i-th of them makes exactly ai bugs in every line of code that he writes. Let's call a sequence of non-negative integers v1, v2, ..., vn a plan, if v1 + v2 + ... + vn = m. The programmers follow the plan like that: in the beginning the first programmer writes the first v1 lines of the given task, then the second programmer writes v2 more lines of the given task, and so on. In the end, the last programmer writes the remaining lines of the code. Let's call a plan good, if all the written lines of the task contain at most b bugs in total.Your task is to determine how many distinct good plans are there. As the number of plans can be large, print the remainder of this number modulo given positive integer mod.

The first line contains four integers n, m, b, mod (1 ≤ n, m ≤ 500, 0 ≤ b ≤ 500; 1 ≤ mod ≤ 109 + 7) — the number of programmers, the number of lines of code in the task, the maximum total number of bugs respectively and the modulo you should use when printing the answer. The next line contains n space-separated integers a1, a2, ..., an (0 ≤ ai ≤ 500) — the number of bugs per line for each programmer.

Print a single integer — the answer to the problem modulo mod.

package main

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

var in = bufio.NewReader(os.Stdin)
var dp [2][501] /*line*/ [501] /*bug*/ int32

func main() {
	var n, m, b, mod int
	if _, err := fmt.Fscan(in, &n, &m, &b, &mod); err != nil {
		panic(err)
	}
	t := 0
	dp[1-t][0][0] = 1
	for i := 0; i < n; i++ {
		var a int
		if _, err := fmt.Fscan(in, &a); err != nil {
			panic(err)
		}
		for j := 0; j <= m; j++ {
			for k := 0; k <= b; k++ {
				dp[t][j][k] = -1
			}
		}
		for j := m; j >= 0; j-- {
			for k := b; k >= 0; k-- {
				if dp[t][j][k] != -1 {
					continue
				}
				jj := j
				kk := k
				for jj > 0 && kk-a >= 0 {
					jj--
					kk -= a
				}
				dp[t][jj][kk] = dp[1-t][jj][kk]
				jj++
				kk += a
				for jj <= j {
					dp[t][jj][kk] = (dp[t][jj-1][kk-a] + dp[1-t][jj][kk]) % int32(mod)
					jj++
					kk += a
				}
			}
		}
		t = 1 - t
	}
	ans := 0
	for i := 0; i <= b; i++ {
		ans = (ans + int(dp[1-t][m][i])) % mod
	}
	fmt.Println(ans)
}

package main

import (
	"fmt"
)

var dp [2][501] /*line*/ [501] /*bug*/ int32

func main() {
	var n, m, b, mod int
	if _, err := fmt.Scan(&n, &m, &b, &mod); err != nil {
		panic(err)
	}
	t := 0
	dp[1-t][0][0] = 1
	for i := 0; i < n; i++ {
		var a int
		if _, err := fmt.Scan(&a); err != nil {
			panic(err)
		}
		for j := 0; j <= m; j++ {
			for k := 0; k <= b; k++ {
				dp[t][j][k] = -1
			}
		}
		for j := m; j >= 0; j-- {
			for k := b; k >= 0; k-- {
				if dp[t][j][k] != -1 {
					continue
				}
				jj := j
				kk := k
				for jj > 0 && kk-a >= 0 {
					jj--
					kk -= a
				}
				dp[t][jj][kk] = dp[1-t][jj][kk]
				jj++
				kk += a
				for jj <= j {
					dp[t][jj][kk] = (dp[t][jj-1][kk-a] + dp[1-t][jj][kk]) % int32(mod)
					jj++
					kk += a
				}
			}
		}
		t = 1 - t
	}
	ans := 0
	for i := 0; i <= b; i++ {
		ans = (ans + int(dp[1-t][m][i])) % mod
	}
	fmt.Println(ans)
}

package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

var debug = true

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func main() {
	defer writer.Flush()

	var n, m, b, mod int
	scanf("%d %d %d %d\n", &n, &m, &b, &mod)
	var f [505][505]int
	var mark [505][505]int
	f[0][0] = 1
	mark[0][0] = 1
	a := getLine2Ints(n)
	for k := 0; k < n; k++ {
		if a[k] == 0 {
			f[0][0] = 0
			f[1][0]++
			mark[1][0] = 1
		}
		for i := 1; i <= m; i++ {
			for j := a[k]; j <= b; j++ {
				if mark[i-1][j-a[k]] != 0 {
					f[i][j] = (f[i-1][j-a[k]] + f[i][j]) % mod
					mark[i][j] = 1
				}
			}
		}
		f[0][0] = 1
	}
	sum := 0
	for i := 0; i <= b; i++ {
		sum = (sum + f[m][i]) % mod
	}
	printf("%d\n", sum)
}

package main

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

const N = 505

var dp [2][N][N]int

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

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

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

	for i := 0; i <= b; i++ {
		dp[n%2][m][i] = 1
	}

	for i := n - 1; i >= 0; i-- {
		for l := m; l >= 0; l-- {
			for x := b; x >= 0; x-- {
				nxt := (1 - (i % 2))
				dp[i%2][l][x] = dp[nxt][l][x]
				if l+1 <= m && x+a[i] <= b {
					dp[i%2][l][x] += dp[i%2][l+1][x+a[i]]
					dp[i%2][l][x] %= mod
				}
			}
		}
	}

	fmt.Println(dp[0][0][0])
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n, m, b, mod, v, s int
	Fscan(in, &n, &m, &b, &mod)
	dp := make([][]int, m+1)
	for i := range dp {
		dp[i] = make([]int, b+1)
	}
	dp[0][0] = 1
	for ; n > 0; n-- {
		Fscan(in, &v)
		for j := 1; j <= m; j++ {
			for k := v; k <= b; k++ {
				dp[j][k] = (dp[j][k] + dp[j-1][k-v]) % mod
			}
		}
	}
	for k := 0; k <= b; k++ {
		s = (s + dp[m][k]) % mod
	}
	Print(s)
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF543A(_r io.Reader, out io.Writer) {
	in := bufio.NewReader(_r)
	var n, m, b, mod, s int
	Fscan(in, &n, &m, &b, &mod)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	dp := make([][]int, m+1)
	for i := range dp {
		dp[i] = make([]int, b+1)
	}
	for j := 0; j <= m && j*a[0] <= b; j++ {
		dp[j][j*a[0]] = 1
	}
	for i := 1; i < n; i++ {
		for j := 1; j <= m; j++ {
			for k := a[i]; k <= b; k++ {
				dp[j][k] = (dp[j][k] + dp[j-1][k-a[i]]) % mod
			}
		}
	}
	for k := 0; k <= b; k++ {
		s = (s + dp[m][k]) % mod
	}
	Fprint(out, s)
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	var n, m, b, mod, s int
	Fscan(in, &n, &m, &b, &mod)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	dp := make([][]int, m+1)
	for i := range dp {
		dp[i] = make([]int, b+1)
	}
	for j := 0; j <= m && j*a[0] <= b; j++ {
		dp[j][j*a[0]] = 1
	}
	for i := 1; i < n; i++ {
		for j := 1; j <= m; j++ {
			for k := a[i]; k <= b; k++ {
				dp[j][k] = (dp[j][k] + dp[j-1][k-a[i]]) % mod
			}
		}
	}
	for k := 0; k <= b; k++ {
		s = (s + dp[m][k]) % mod
	}
	Print(s)
}

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	M := io.NextInt()
	B := io.NextInt()
	MOD := io.NextLong()
	A := io.NextIntArray(N)

	dp := MakeLongMatrix(M + 1, B + 1)
	dp[0][0] = 1
	for i := 0; i < N; i++ {
		for ln := 0; ln < M; ln++ {
			for b := 0; b + A[i] <= B; b++ {
				dp[ln + 1][b + A[i]] += dp[ln][b]
				dp[ln + 1][b + A[i]] %= MOD
			}
		}
	}

	sum := int64(0)
	for b := 0; b <= B; b++ {
		sum += dp[M][b]
		sum %= MOD
	}
	io.Println(sum)
}

func MakeLongMatrix(rows, cols int) [][]int64 {
	mat := make([][]int64, rows)
	for i := range mat {
		mat[i] = make([]int64, cols)
	}
	return mat
}

type FastIO struct {
	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 sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

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 (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	M := io.NextInt()
	B := io.NextInt()
	MOD := io.NextInt()
	A := io.NextIntArray(N)

	dp := MakeIntMatrix(M + 1, B + 1)
	dp[0][0] = 1
	for i := 0; i < N; i++ {
		for ln := 0; ln < M; ln++ {
			for b := 0; b + A[i] <= B; b++ {
				dp[ln + 1][b + A[i]] += dp[ln][b]
				dp[ln + 1][b + A[i]] %= MOD
			}
		}
	}

	sum := 0
	for b := 0; b <= B; b++ {
		sum += dp[M][b]
		sum %= MOD
	}
	io.Println(sum)
}

func MakeIntMatrix(rows, cols int) [][]int {
	mat := make([][]int, rows)
	for i := range mat {
		mat[i] = make([]int, cols)
	}
	return mat
}

type FastIO struct {
	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 sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

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