package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var S []rune

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		S = ReadRuneSlice()

		solve()
	}
}

func solve() {
	n := len(S)
	oneTopIdx := []int{}
	for i := 0; i < n-2; i++ {
		str := S[i : i+3]
		if string(str) == "one" {
			oneTopIdx = append(oneTopIdx, i)
		}
	}
	twoBtmIdx := []int{}
	for i := 0; i < n-2; i++ {
		str := S[i : i+3]
		if string(str) == "two" {
			twoBtmIdx = append(twoBtmIdx, i+2)
		}
	}

	memo := make(map[int]int)
	for _, idx := range oneTopIdx {
		memo[idx]++
	}
	for _, idx := range twoBtmIdx {
		memo[idx]++
	}

	answers := []int{}
	for _, idx := range oneTopIdx {
		if memo[idx] == 2 {
			answers = append(answers, idx+1)
		} else {
			answers = append(answers, idx+1+1)
		}
	}
	for _, idx := range twoBtmIdx {
		if memo[idx] == 2 {
			continue
		} else {
			answers = append(answers, idx+1-1)
		}
	}

	fmt.Println(len(answers))
	fmt.Println(PrintIntsLine(answers...))
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
*/

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

package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

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

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

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

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

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

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

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

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

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		b := readb()
		p := solve(b)
		println(len(p))
		sp := ""
		for _, v := range p {
			printf("%s%d", sp, v+1)
			sp = " "
		}
		println()
	}
}

func solve(s []byte) []int {
	n := len(s)

	ban := []string{"twone", "one", "two"}
	bani := []int{2, 1, 1}

	var ans []int
	for i := 0; i < n; i++ {
		for k, b := range ban {
			j := min(i+len(b), n)
			if string(s[i:j]) == b {
				s[i+bani[k]] = '_'
				ans = append(ans, i+bani[k])
				break
			}
		}
	}
	return ans
}

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

/********** 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 MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int
var S []rune

func main() {
	t = ReadInt()

	for tc := 0; tc < t; tc++ {
		S = ReadRuneSlice()

		solve()
	}
}

func solve() {
	n := len(S)
	oneTopIdx := []int{}
	for i := 0; i < n-2; i++ {
		str := S[i : i+3]
		if string(str) == "one" {
			oneTopIdx = append(oneTopIdx, i)
		}
	}
	twoBtmIdx := []int{}
	for i := 0; i < n-2; i++ {
		str := S[i : i+3]
		if string(str) == "two" {
			twoBtmIdx = append(twoBtmIdx, i+2)
		}
	}

	memo := make(map[int]int)
	for _, idx := range oneTopIdx {
		memo[idx] = 1
	}
	for _, idx := range twoBtmIdx {
		memo[idx] = 1
	}

	answers := []int{}
	for k := range memo {
		answers = append(answers, k+1)
	}

	fmt.Println(len(answers))
	fmt.Println(PrintIntsLine(answers...))
}

/*
- MODは最後にとりましたか？
- ループを抜けた後も処理が必要じゃありませんか？
- 和・積・あまりを求められたらint64が必要ではありませんか？
- いきなりオーバーフローはしていませんか？
*/

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

package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

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

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

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

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

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

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

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

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

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		b := readb()
		p := solve(b)
		println(len(p))
		sp := ""
		for _, v := range p {
			printf("%s%d", sp, v)
			sp = " "
		}
		println()
	}
}

func solve(s []byte) []int {
	n := len(s)

	ban := []string{"twone", "one", "two"}
	bani := []int{2, 1, 1}

	var ans []int
	for i := 0; i < n; i++ {
		for k, b := range ban {
			j := min(i+len(b), n)
			if string(s[i:j]) == b {
				s[i+bani[k]] = '_'
				ans = append(ans, i+bani[k])
				break
			}
		}
	}
	return ans
}


package main

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

func swap(p []int, n int) {
	for i := 0; i < 2*n; i += 2 {
		tmp := p[i]
		p[i] = p[i+1]
		p[i+1] = tmp
	}
}

func shift(p []int, n int) {
	for i := 0; i < n; i++ {
		tmp := p[i]
		p[i] = p[n+i]
		p[n+i] = tmp
	}
}

func cmp(p []int, a []int) bool {
	res := true
	for i := range p {
		if p[i] != a[i] {
			res = false
			break
		}
	}
	return res
}

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

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

	a := make([]int, 2*n)
	p := make([]int, 2*n)

	for i := 1; i <= 2*n; i++ {
		fmt.Fscan(r, &a[i-1])
		p[i-1] = i
	}

	N := 2*n
	if n % 2 == 0 { N = 4 }

	var c int
	for ; c < N && !cmp(p, a); c++ {
		if c % 2 == 0 {
			swap(p, n)
		} else {
			shift(p, n)
		}
	}

	if c < N {
		if c > N - c { c = N - c }
		fmt.Fprintln(w, c)
	} else {
		fmt.Fprintln(w, -1)
	}
}

package main

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

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

	var n, v int
	Fscan(in, &n)
	n *= 2
	const mx int = 2000
	st := [mx]int{}
	for i := 0; i < n; i++ {
		st[i] = i
	}
	ans := map[[mx]int]int{st: 0}
	q := [][mx]int{st}
	for d := 0; len(q) > 0; d++ {
		tmp := q
		q = nil
		for _, a := range tmp {
			b := a
			for i := 0; i < n; i += 2 {
				b[i], b[i+1] = b[i+1], b[i]
			}
			if _, has := ans[b]; !has {
				ans[b] = d + 1
				q = append(q, b)
			}
			b = [mx]int{}
			for i := 0; i < n/2; i++ {
				b[i+n/2] = a[i]
				b[i] = a[i+n/2]
			}
			if _, has := ans[b]; !has {
				ans[b] = d + 1
				q = append(q, b)
			}
		}
	}

	a := [mx]int{}
	for i := 0; i < n; i++ {
		Fscan(in, &v)
		a[i] = v - 1
	}

	res, has := ans[a]
	if !has {
		Fprintln(out, -1)
	} else {
		Fprintln(out, res)
	}
}

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

package main

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

const N int = 2000

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

	var n int
	Fscan(in, &n)

	a := [N]int{}
	for i := 0; i < 2*n; i++ {
		Fscan(in, &a[i])
	}

	isSorted := func(a *[N]int, n int) bool {
		for i := 0; i < 2*n-1; i++ {
			if a[i] > a[i+1] {
				return false
			}
		}
		return true
	}

	if isSorted(&a, n) {
		Fprintln(out, 0)
		return
	}

	// Try everything
	a1 := a
	lastMove := false
	move1 := 0
	isDoable := false
	for {
		move(&a1, n, lastMove)
		// Fprintln(out, a1)
		move1++
		lastMove = !lastMove
		if isSorted(&a1, n) {
			isDoable = true
			break
		}
		if a1 == a {
			break
		}
	}
	if !isDoable {
		Fprintln(out, -1)
		return
	}

	// Try other way to see if it is faster
	a2 := a
	lastMove = true
	move2 := 0
	// Fprintln(out)
	for {
		move(&a2, n, lastMove)
		// Fprintln(out, a2)
		move2++
		lastMove = !lastMove
		if isSorted(&a2, n) {
			isDoable = true
			break
		}
		if a2 == a {
			break
		}
	}

	if move2 < move1 {
		Fprintln(out, move2)
	} else {
		Fprintln(out, move1)
	}

}

func move(a *[N]int, n int, lastMove bool) {
	if lastMove {
		for i := 0; i < n; i++ {
			temp := a[i]
			a[i] = a[n+i]
			a[n+i] = temp
		}
	} else {
		for i := 0; i < 2*n; i += 2 {
			temp := a[i]
			a[i] = a[i+1]
			a[i+1] = temp
		}
	}
}

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

package main

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

func swap(p []int, n int) {
	for i := 0; i < 2*n; i += 2 {
		tmp := p[i]
		p[i] = p[i+1]
		p[i+1] = tmp
	}
}

func shift(p []int, n int) {
	for i := 0; i < n; i++ {
		tmp := p[i]
		p[i] = p[n+i]
		p[n+i] = tmp
	}
}

func cmp(p []int, a []int) bool {
	res := true
	for i := range p {
		if p[i] != a[i] {
			res = false
			break
		}
	}
	return res
}

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

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

	a := make([]int, 2*n)
	p := make([]int, 2*n)

	for i := 1; i <= 2*n; i++ {
		fmt.Fscan(r, &a[i-1])
		p[i-1] = i
	}

	N := 2*n
	if n % 2 == 0 { N = 4 }

	var c int
	for ; c < N-1 && !cmp(p, a); c++ {
		if c % 2 == 0 {
			swap(p, n)
		} else {
			shift(p, n)
		}
	}

	if c < N-1 {
		if c > N - c { c = N - c }
		fmt.Fprintln(w, c)
	} else {
		fmt.Fprintln(w, -1)
	}
}


package main

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

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

type AnsTuple struct {
	Index  int
	Direct string
}

var queue []AnsTuple

func recv(v []int, count int) bool {
	if count == len(v) - 1 {
		return true
	}
	u := [2]int{}
	un := [2]int{}
	normalizeIndex := 0
	normalizeIndex2 := 0

	for i := 0; i < len(v); i++ {
		if v[i] == 0 {
			continue
		}

		u[0] = i
		un[0] = normalizeIndex
		normalizeIndex2 = normalizeIndex
		for j := i + 1; j < len(v); j++ {
			if v[j] == 0 {
				continue
			}
			normalizeIndex2++
			if v[i] == v[j] {
				break
			}

			u[1] = j
			un[1] = normalizeIndex2
			if v[u[0]] < v[u[1]] {
				//println(fmt.Errorf("%+v", v).Error())

				a := v[u[0]]
				b := v[u[1]]
				v[u[1]] += a
				v[u[0]] = 0
				queue = append(queue, AnsTuple{Index:un[1], Direct:"L"})
				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]
				v[u[0]] = a
				v[u[1]] = b
				//println("back", fmt.Errorf("%+v", v).Error())

			} else {
				//println(fmt.Errorf("%+v", v).Error())
				//println(u[0], u[1])

				a := v[u[0]]
				b := v[u[1]]

				v[u[0]] += b
				v[u[1]] = 0
				queue = append(queue, AnsTuple{Index:un[0], Direct:"R"})

				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]

				v[u[0]] = a
				v[u[1]] = b

			}

		}
		normalizeIndex++
	}
	return false
}
func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()
	k := sc.NextInt()
	b := sc.NextIntArray()

	i := 0
	ans := make([]string, 0)
	for j := 0; j < k; j++ {
		sum := 0
		f := i
		for ; sum < b[j] && i < N; i++ {
			sum += a[i]
		}
		if sum != b[j] {
			fmt.Println("NO")
			return
		}
		if j == k - 1 && i != N {
			fmt.Println("NO")
			return
		}
		queue = make([]AnsTuple, 0)
		if !recv(a[f:i], 0) {
			fmt.Println("NO")
			return
		}
		for i := 0; i < len(queue); i++ {
			str := strconv.Itoa(queue[i].Index + j + 1)
			str += " "
			str += queue[i].Direct
			ans = append(ans, str)
		}

	}
	fmt.Println("YES")
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

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

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

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

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

	return mp
}

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

package main

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

type step struct {
    i int
    d string
}

func doSolve(a, b []int, di int) ([]step, bool) {
    res := make([]step, 0)
    if len(b) == 0 {
        return res, len(a) == 0
    }
    bs, j, sum, mx := b[0], 0, 0, 0
    for j < len(a) && sum < bs {
        sum += a[j]
        mx = max(a[j], mx)
        j++
    }

    ok := sum == bs
    if ok {
        for i := 0; i < j - 1; i++ {
            l, r := a[i], a[i + 1]
            if l != r {
                indx, d := -1, ""
                if (l == mx) {
                    indx, d = i + 1, "R"
                    a[i] += r
                } else if (r == mx) {
                    indx, d = i, "L"
                    a[i + 1] += l
                }

                if indx != -1 {
                    res = append(res, step{i: 2 * i + 1 - indx + di, d: d})
                    a = append(a[:indx], a[indx + 1:]...)
                    break
                }
            }
        }

        if j == 1 || len(res) > 0 {
            if j == 1 {
                di++
                b = b[1:]
                a = a[1:]
            }
            nextStep, nextOk := doSolve(a, b, di)
            ok = ok && nextOk
            res = append(res, nextStep...)
        } else {
            ok = false
        }
    }

    return res, ok
}

func solve() {
	n := readInt()
    a := readIntArray(n)
	k := readInt()
    b := readIntArray(k)

    steps, ok := doSolve(a, b, 0)
    if ok {
        fmt.Println("YES")
        for _, st := range steps {
            fmt.Println(st.i + 1, " " + st.d)
        }
    } else {
        fmt.Println("NO")
    }
}

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

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

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

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

// IO

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

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

func readIntArray(sz int) []int {
	a := make([]int, sz)
    for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
    return a
}

func readArray(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = readInt()
	}
	return res
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

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

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

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

	b := make([]int, m+1)
	for i := 1; i <= m; i++ {
		fmt.Fscanf(bufin, "%d\n", &b[i])
	}

	var rpos []int
	var rdir []byte

	for ; (m > 0) && (n > 0); m-- {
		i := n
		s := 0
		for ; (i >= 1) && (s < b[m]); i-- {
			s += a[i]
		}
		if s != b[m] {
			fmt.Fprintf(bufout, "NO\n")
			return
		}
		for i++; i < n; n-- {
			p := -1
			ms := -1
			for j := i; j < n; j++ {
				if (a[j] != a[j+1]) && (ms < a[j]+a[j+1]) {
					p = j
					ms = a[j] + a[j+1]
				}
			}
			if p == -1 {
				fmt.Fprintf(bufout, "NO\n")
				return
			}
			if a[p] < a[p+1] {
				rpos = append(rpos, p+1)
				rdir = append(rdir, 'L')
			} else {
				rpos = append(rpos, p)
				rdir = append(rdir, 'R')
			}
			a[p] += a[p+1]
			for j := p + 1; j < n; j++ {
				a[j] = a[j+1]
			}
		}
		n--
	}

	if (m > 0) || (n > 0) {
		fmt.Fprintf(bufout, "NO\n")
		return
	}

	fmt.Fprintf(bufout, "YES\n")
	s := len(rpos)
	for i := 0; i < s; i++ {
		fmt.Fprintf(bufout, "%d %c\n", rpos[i], rdir[i])
	}
}

package main

import "fmt"

type Item struct {
	leftSonLength int16
	leftEatRight bool
	isActionExist bool
}

const N = 501
var Arr [N][N]Item
var a [N]int32
var suma [N]int32
var b [N]int32
var n, k int16
var isAnswerExist bool

func readData() {
	fmt.Scan(&n)
	for i := int16(1); i <= n; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Scan(&k)
	for i := int16(1); i <= k; i++ {
		fmt.Scan(&b[i])
	}
}

func initData() {
	isAnswerExist = true
	for i := int16(1); i <= n; i++ {
		suma[i] = suma[i - 1] + a[i]
	}
}

func getSum(from int16, to int16) int32 {
	return suma[to] - suma[from - 1]
}
func actionExist(from int16, sum int32) int16 {
	for i := from; i <= n && getSum(from, i) <= sum; i++ {
		if getSum(from, i) == sum {
			return i + 1 - from
		}
	}
	return int16(-1)
}

func answerExist() bool {
	from := int16(1)
	for i := int16(1); i <= k; i++ {
		length := actionExist(from, b[i])
		if length == -1 || !Arr[from][length].isActionExist {
			return false
		}
		from += length
	}
	if from != n + 1 {
		return false
	} else {
		return true
	}
}

func dp() {
	for i := int16(1); i <= n; i++ {
		Arr[i][1].isActionExist = true
	}
	for l := int16(2); l <= n; l++ {
		for i := int16(1); i + l - 1 <= n; i++ {
			Arr[i][l].isActionExist = false
			for lson := int16(1); lson < l; lson++ {
				ri := i + lson
				rson := l - lson
				if Arr[i][lson].isActionExist && Arr[ri][rson].isActionExist {
					if getSum(i, i + lson - 1) > getSum(ri, ri + rson - 1) {
						Arr[i][l].leftEatRight = true
						Arr[i][l].leftSonLength = lson
						Arr[i][l].isActionExist = true
						break
					}
					if getSum(i, i + lson - 1) < getSum(ri, ri + rson - 1) {
						Arr[i][l].leftEatRight = false
						Arr[i][l].leftSonLength = lson
						Arr[i][l].isActionExist = true
						break
					}
				}
			}
		}
	}
	if !answerExist() {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		printAnswer()
	}
}

func printActions(preItems, from, length int16) {
	if length != 1 {
		printActions(preItems, from, Arr[from][length].leftSonLength)
		rightFrom := from + Arr[from][length].leftSonLength
		rightSonLength := length - Arr[from][length].leftSonLength
		printActions(preItems + 1, rightFrom, rightSonLength)
		if Arr[from][length].leftEatRight {
			fmt.Printf("%d R\n", preItems + 1)
		} else {
			fmt.Printf("%d L\n", preItems + 2)
		}
	}
}
func printAnswer() {
	from := int16(1)
	for i := int16(1); i <= k; i++ {
		length := actionExist(from, b[i])
		printActions(i - 1, from, length)
		from += length
	}
}

func main() {
	readData()
	initData()
	dp()
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

type group struct {
	beg, end int
}

func output(A []int, beg, end, offset int) {
	var nums = make([]int, end-beg)
	for i := beg; i < end; i++ {
		nums[i-beg] = A[i]
	}

	for len(nums) != 1 {
		var maxeatelm = -1
		var maxeati = -1
		for i := 0; i < len(nums); i++ {
			var eat = false
			if i > 0 && nums[i-1] < nums[i] {
				eat = true
			}
			if i < len(nums)-1 && nums[i] > nums[i+1] {
				eat = true
			}
			if eat && maxeatelm < nums[i] {
				maxeatelm = nums[i]
				maxeati = i
			}
		}
		var newnums = make([]int, len(nums)-1)
		var j = 0
		for i := 0; i < len(nums); i++ {
			if i == maxeati {
				if i < len(nums)-1 && nums[i] > nums[i+1] {
					newnums[j] = nums[i] + nums[i+1]
					fmt.Fprintf(bufout, "%d R\n", i+1+offset)
					i += 1
					j += 1
				} else {
					newnums[j-1] += nums[i]
					fmt.Fprintf(bufout, "%d L\n", i+1+offset)
					i += 1
				}
			} else {
				newnums[j] = nums[i]
				j += 1
			}
		}
		nums = newnums
	}
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()
	var N, M int
	fmt.Fscanf(bufin, "%d\n", &N)
	var A = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Fscanf(bufin, "%d\n", &A[i])
	}
	fmt.Fscanf(bufin, "%d\n", &M)
	var B = make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Fscanf(bufin, "%d\n", &B[i])
	}
	var G []group
	{
		var j = 0
		for i := 0; i < M; i++ {
			var beg = j
			var maxa, maxcnt = 0, 0
			var b = 0
			for ; j < N && b < B[i]; j++ {
				b += A[j]
				if maxa < A[j] {
					maxa = A[j]
					maxcnt = 1
				} else if maxa == A[j] {
					maxcnt += 1
				}
			}
			var end = j
			if b != B[i] {
				fmt.Fprintf(bufout, "NO\n")
				return
			}
			if maxcnt != 1 && maxcnt == end-beg {
				fmt.Fprintf(bufout, "NO\n")
				return
			}
			G = append(G, group{beg, end})
		}
		if j != N {
			fmt.Fprintf(bufout, "NO\n")
			return
		}
	}
	//fmt.Println(G)
	fmt.Fprintf(bufout, "YES\n")
	for i := 0; i < len(G); i++ {
		output(A, G[i].beg, G[i].end, i)
	}
}

package main

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

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

type Slice struct {
    start, end int
}

type Step struct {
    position int
    step string
}

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

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

func Build(startIndex int, items []int) ([]Step, bool) {
    maxIndex := 0
    cnt := len(items)
    var steps []Step

    if cnt == 1 {
        return steps, true
    }

    for i := 0; i < cnt; i++ {
        if items[i] > items[maxIndex] {
            maxIndex = i
        }
    }

    if maxIndex > 0 {
        for maxIndex > 0 {
            steps = append(steps, Step{startIndex + maxIndex, "L"})
            maxIndex--
            cnt--
        }

        for cnt > 1 {
            steps = append(steps, Step{startIndex, "R"})
            cnt--
        }

        return steps, true
    } else if items[maxIndex] > items[maxIndex+1] {
        for cnt > 1 {
            steps = append(steps, Step{startIndex, "R"})
            cnt--
        }
        return steps, true
    } else {
        for maxIndex + 1 < cnt && items[maxIndex] == items[maxIndex+1] {
            maxIndex++
        }

        if maxIndex+1 >= cnt || items[maxIndex] == items[maxIndex+1] {
            return steps, false
        } else {
            for maxIndex + 1 < cnt {
                steps = append(steps, Step{startIndex + maxIndex, "R"})
                cnt--
            }

            for maxIndex > 0 {
                steps = append(steps, Step{startIndex + maxIndex, "L"})
                maxIndex--
            }
        }
    }

    return steps, true
}

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

    n := ReadInt()
    a := make([]int, n)

    for i := 0; i < n; i++ {
        a[i] = ReadInt()
    }

    k := ReadInt()
    b := make([]int, k)
    slices := make([]Slice, k)

    for i := 0; i < k; i++ {
        b[i] = ReadInt()
    }

    leftPointer := 0
    for i := 0; i < k; i++ {
        if leftPointer >= n {
            fmt.Println("NO")
            return
        }

        curSlice := Slice{leftPointer, leftPointer}
        curSum := a[leftPointer]
        leftPointer++

        for curSum < b[i] && leftPointer < n {
            curSum += a[leftPointer]
            leftPointer++
        }

        if curSum != b[i] {
            fmt.Println("NO")
            return
        } else {
            curSlice.end = leftPointer
            slices[i] = curSlice
        }
    }

    if leftPointer != n {
        fmt.Println("NO")
        return
    }

    var steps []Step

    for i := 0; i < k; i++ {
        newSteps, success := Build(i + 1, a[slices[i].start:slices[i].end])
        if !success {
            fmt.Println("NO")
            return
        } else {
            steps = append(steps, newSteps...)
        }
    }

    fmt.Println("YES")
    for i := 0; i < len(steps); i++ {
        fmt.Println(strconv.Itoa(steps[i].position) + " " + steps[i].step)
    }
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

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

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

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

	b := make([]int, m+1)
	for i := 1; i <= m; i++ {
		fmt.Fscanf(bufin, "%d\n", &b[i])
	}

	var rpos []int
	var rdir []byte

	for ; (m > 0) && (n > 0); m-- {
		i := n
		s := 0
		for ; (i >= 1) && (s < b[m]); i-- {
			s += a[i]
		}
		if s < b[m] {
			fmt.Fprintf(bufout, "NO\n")
			return
		}
		for i++; i < n; n-- {
			// for j := 1; j <= n; j++ {
			// 	fmt.Fprintf(bufout, "%d ", a[j])
			// }
			// fmt.Fprintf(bufout, "\n")
			p := -1
			ms := -1
			for j := i; j < n; j++ {
				if (a[j] != a[j+1]) && (ms < a[j]+a[j+1]) {
					p = j
					ms = a[j] + a[j+1]
				}
			}
			if p == -1 {
				fmt.Fprintf(bufout, "NO\n")
				return
			}
			if a[p] < a[p+1] {
				rpos = append(rpos, p+1)
				rdir = append(rdir, 'L')
			} else {
				rpos = append(rpos, p)
				rdir = append(rdir, 'R')
			}
			a[p] += a[p+1]
			for j := p + 1; j < n; j++ {
				a[j] = a[j+1]
			}
		}
		n--
	}

	if (m > 0) || (n > 0) {
		fmt.Fprintf(bufout, "NO\n")
		return
	}

	fmt.Fprintf(bufout, "YES\n")
	s := len(rpos)
	for i := 0; i < s; i++ {
		fmt.Fprintf(bufout, "%d %c\n", rpos[i], rdir[i])
	}
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

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

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

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

	b := make([]int, m+1)
	for i := 1; i <= m; i++ {
		fmt.Fscanf(bufin, "%d\n", &b[i])
	}

	var rpos []int
	var rdir []byte

	for k := m; k >= 1; k-- {
		found := true
		for (n > k) && (a[n] != b[k]) && found {
			found = false
			for i := n; i >= 2; i-- {
				if a[i] != a[i-1] {
					if a[i-1] < a[i] {
						rpos = append(rpos, i)
						rdir = append(rdir, 'L')
					} else {
						rpos = append(rpos, i-1)
						rdir = append(rdir, 'R')
					}
					a[i-1] += a[i]
					for j := i; j < n; j++ {
						a[j] = a[j+1]
					}
					n--
					found = true
					break
				}
			}
		}
		if (n < k) || (a[n] != b[k]) {
			fmt.Fprintf(bufout, "NO\n")
			return
		}
		n--
	}

	fmt.Fprintf(bufout, "YES\n")
	s := len(rpos)
	for i := 0; i < s; i++ {
		fmt.Fprintf(bufout, "%d %c\n", rpos[i], rdir[i])
	}
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

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

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

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

	b := make([]int, m+1)
	for i := 1; i <= m; i++ {
		fmt.Fscanf(bufin, "%d\n", &b[i])
	}

	var rpos []int
	var rdir []byte

	for k := m; k >= 1; k-- {
		found := true
		for (n > k) && (a[n] != b[k]) && found {
			found = false
			p := -1
			s := -1
			for i := n; i >= k+1; i-- {
				if a[i] != a[i-1] {
					if s < a[i]+a[i-1] {
						p = i
						s = a[i] + a[i-1]
						found = true
					}
				}
			}
			if found {
				i := p
				if a[i-1] < a[i] {
					rpos = append(rpos, i)
					rdir = append(rdir, 'L')
				} else {
					rpos = append(rpos, i-1)
					rdir = append(rdir, 'R')
				}
				a[i-1] += a[i]
				for j := i; j < n; j++ {
					a[j] = a[j+1]
				}
				n--
			}
		}
		if (n < k) || (a[n] != b[k]) {
			fmt.Fprintf(bufout, "NO\n")
			return
		}
		n--
	}

	if n > 0 {
		fmt.Fprintf(bufout, "NO\n")
		return
	}

	fmt.Fprintf(bufout, "YES\n")
	s := len(rpos)
	for i := 0; i < s; i++ {
		fmt.Fprintf(bufout, "%d %c\n", rpos[i], rdir[i])
	}
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

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

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

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

	b := make([]int, m+1)
	for i := 1; i <= m; i++ {
		fmt.Fscanf(bufin, "%d\n", &b[i])
	}

	var rpos []int
	var rdir []byte

	for k := m; k >= 1; k-- {
		found := true
		for (n > k) && (a[n] != b[k]) && found {
			found = false
			for i := n; i >= 2; i-- {
				if a[i] != a[i-1] {
					if a[i-1] < a[i] {
						rpos = append(rpos, i)
						rdir = append(rdir, 'L')
					} else {
						rpos = append(rpos, i-1)
						rdir = append(rdir, 'R')
					}
					a[i-1] += a[i]
					for j := i; j < n; j++ {
						a[j] = a[j+1]
					}
					n--
					found = true
					break
				}
			}
		}
		if (n < k) || (a[n] != b[k]) {
			fmt.Fprintf(bufout, "NO\n")
			return
		}
		n--
	}

	if n > 0 {
		fmt.Fprintf(bufout, "NO\n")
		return
	}

	fmt.Fprintf(bufout, "YES\n")
	s := len(rpos)
	for i := 0; i < s; i++ {
		fmt.Fprintf(bufout, "%d %c\n", rpos[i], rdir[i])
	}
}

package main

import "fmt"

type Item struct {
	leftSonLength int16
	leftEatRight bool
	isActionExist bool
}

const N = 501
var Arr [N][N]Item
var a [N]int32
var suma [N]int32
var b [N]int32
var n, k int16
var isAnswerExist bool

func readData() {
	fmt.Scan(&n)
	for i := int16(1); i <= n; i++ {
		fmt.Scan(&a[i])
	}
	fmt.Scan(&k)
	for i := int16(1); i <= k; i++ {
		fmt.Scan(&b[i])
	}
}

func initData() {
	isAnswerExist = true
	for i := int16(1); i <= n; i++ {
		suma[i] = suma[i - 1] + a[i]
	}
}

func getSum(from int16, to int16) int32 {
	return suma[to] - suma[from - 1]
}
func actionExist(from int16, sum int32) int16 {
	for i := from; i <= n && getSum(from, i) <= sum; i++ {
		if getSum(from, i) == sum {
			return i + 1 - from
		}
	}
	return int16(-1)
}

func answerExist() bool {
	from := int16(1)
	for i := int16(1); i <= k; i++ {
		length := actionExist(from, b[i])
		if length == -1 || !Arr[from][length].isActionExist {
			return false
		}
		from += length
	}
	return true
}

func dp() {
	for i := int16(1); i <= n; i++ {
		Arr[i][1].isActionExist = true
	}
	for l := int16(2); l <= n; l++ {
		for i := int16(1); i + l - 1 <= n; i++ {
			Arr[i][l].isActionExist = false
			for lson := int16(1); lson < l; lson++ {
				ri := i + lson
				rson := l - lson
				if Arr[i][lson].isActionExist && Arr[ri][rson].isActionExist {
					if getSum(i, i + lson - 1) > getSum(ri, ri + rson - 1) {
						Arr[i][l].leftEatRight = true
						Arr[i][l].leftSonLength = lson
						Arr[i][l].isActionExist = true
						break
					}
					if getSum(i, i + lson - 1) < getSum(ri, ri + rson - 1) {
						Arr[i][l].leftEatRight = false
						Arr[i][l].leftSonLength = lson
						Arr[i][l].isActionExist = true
						break
					}
				}
			}
		}
	}
	if !answerExist() {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
		printAnswer()
	}
}

func printActions(preItems, from, length int16) {
	if length != 1 {
		printActions(preItems, from, Arr[from][length].leftSonLength)
		rightFrom := from + Arr[from][length].leftSonLength
		rightSonLength := length - Arr[from][length].leftSonLength
		printActions(preItems + 1, rightFrom, rightSonLength)
		if Arr[from][length].leftEatRight {
			fmt.Printf("%d R\n", preItems + 1)
		} else {
			fmt.Printf("%d L\n", preItems + 2)
		}
	}
}
func printAnswer() {
	from := int16(1)
	for i := int16(1); i <= k; i++ {
		length := actionExist(from, b[i])
		printActions(i - 1, from, length)
		from += length
	}
}

func main() {
	readData()
	initData()
	dp()
}

package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

type group struct {
	beg, end int
}

func output(A []int, beg, end, offset int) {
	var nums = make([]int, end-beg)
	for i := beg; i < end; i++ {
		nums[i-beg] = A[i]
	}

	for len(nums) != 1 {
		var maxeatelm = -1
		var maxeati = -1
		for i := 0; i < len(nums); i++ {
			var eat = false
			if i > 0 && nums[i-1] < nums[i] {
				eat = true
			}
			if i < len(nums)-1 && nums[i] > nums[i+1] {
				eat = true
			}
			if eat && maxeatelm < nums[i] {
				maxeatelm = nums[i]
				maxeati = i
			}
		}
		var newnums = make([]int, len(nums)-1)
		var j = 0
		for i := 0; i < len(nums); i++ {
			if i == maxeati {
				if i < len(nums)-1 && nums[i] > nums[i+1] {
					newnums[j] = nums[i] + nums[i+1]
					fmt.Fprintf(bufout, "%d R\n", i+1+offset)
					i += 1
					j += 1
				} else {
					newnums[j-1] += nums[i]
					fmt.Fprintf(bufout, "%d L\n", i+1+offset)
					i += 1
				}
			} else {
				newnums[j] = nums[i]
				j += 1
			}
		}
		nums = newnums
	}
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()
	var N, M int
	fmt.Fscanf(bufin, "%d\n", &N)
	var A = make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Fscanf(bufin, "%d\n", &A[i])
	}
	fmt.Fscanf(bufin, "%d\n", &M)
	var B = make([]int, M)
	for i := 0; i < M; i++ {
		fmt.Fscanf(bufin, "%d\n", &B[i])
	}
	var G []group
	{
		var j = 0
		for i := 0; i < M; i++ {
			var beg = j
			var maxa, maxcnt = 0, 0
			var b = 0
			for ; j < N && b < B[i]; j++ {
				b += A[j]
				if maxa < A[j] {
					maxa = A[j]
					maxcnt = 1
				} else if maxa == A[j] {
					maxcnt += 1
				}
			}
			var end = j
			if b != B[i] {
				fmt.Fprintf(bufout, "NO\n")
				return
			}
			if maxcnt != 1 && maxcnt == end-beg {
				fmt.Fprintf(bufout, "NO\n")
				return
			}
			G = append(G, group{beg, end})
		}
	}
	//fmt.Println(G)
	fmt.Fprintf(bufout, "YES\n")
	for i := 0; i < len(G); i++ {
		output(A, G[i].beg, G[i].end, i)
	}
}

package main

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

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

type Slice struct {
    start, end int
}

type Step struct {
    position int
    step string
}

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

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

func Build(startIndex int, items []int) ([]Step, bool) {
    maxIndex := 0
    cnt := len(items)
    var steps []Step

    if cnt == 1 {
        return steps, true
    }

    for i := 0; i < cnt; i++ {
        if items[i] > items[maxIndex] {
            maxIndex = i
        }
    }

    if maxIndex > 0 {
        for maxIndex > 0 {
            steps = append(steps, Step{startIndex + maxIndex, "L"})
            maxIndex--
            cnt--
        }

        for cnt > 1 {
            steps = append(steps, Step{startIndex, "R"})
            cnt--
        }

        return steps, true
    } else if items[maxIndex] > items[maxIndex+1] {
        for cnt > 1 {
            steps = append(steps, Step{startIndex, "R"})
            cnt--
        }
        return steps, true
    } else {
        for maxIndex + 1 < cnt && items[maxIndex] == items[maxIndex+1] {
            maxIndex++
        }

        if maxIndex+1 >= cnt || items[maxIndex] == items[maxIndex+1] {
            return steps, false
        } else {
            for maxIndex + 1 < cnt {
                steps = append(steps, Step{startIndex + maxIndex, "R"})
                cnt--
            }

            for maxIndex > 0 {
                steps = append(steps, Step{startIndex + maxIndex, "L"})
                maxIndex--
            }
        }
    }

    return steps, true
}

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

    n := ReadInt()
    a := make([]int, n)

    for i := 0; i < n; i++ {
        a[i] = ReadInt()
    }

    k := ReadInt()
    b := make([]int, k)
    slices := make([]Slice, k)

    for i := 0; i < k; i++ {
        b[i] = ReadInt()
    }

    leftPointer := 0
    for i := 0; i < k; i++ {
        curSlice := Slice{leftPointer, leftPointer}
        curSum := a[leftPointer]
        leftPointer++

        for curSum < b[i] && leftPointer < n {
            curSum += a[leftPointer]
            leftPointer++
        }

        if curSum != b[i] {
            fmt.Println("NO")
            return
        } else {
            curSlice.end = leftPointer
            slices[i] = curSlice
        }
    }

    var steps []Step

    for i := 0; i < k; i++ {
        newSteps, success := Build(i + 1, a[slices[i].start:slices[i].end])
        if !success {
            fmt.Println("NO")
            return
        } else {
            steps = append(steps, newSteps...)
        }
    }

    fmt.Println("YES")
    for i := 0; i < len(steps); i++ {
        fmt.Println(strconv.Itoa(steps[i].position) + " " + steps[i].step)
    }
}

package main

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

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

type AnsTuple struct {
	Index  int
	Direct string
}

var queue []AnsTuple

func recv(v []int, count int) bool {
	if count == len(v) - 1 {
		return true
	}
	u := [2]int{}
	un := [2]int{}
	normalizeIndex := 0
	normalizeIndex2 := 0

	for i := 0; i < len(v); i++ {
		if v[i] == 0 {
			continue
		}

		u[0] = i
		un[0] = normalizeIndex
		normalizeIndex2 = normalizeIndex
		for j := i + 1; j < len(v); j++ {
			if v[j] == 0 {
				continue
			}
			normalizeIndex2++
			if v[i] == v[j] {
				continue
			}

			u[1] = j
			un[1] = normalizeIndex2
			if v[u[0]] < v[u[1]] {

				a := v[u[0]]
				b := v[u[1]]
				v[u[1]] += a
				v[u[0]] = 0
				queue = append(queue, AnsTuple{Index:un[1], Direct:"L"})
				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]
				v[u[0]] = a
				v[u[1]] = b
				println("back", fmt.Errorf("%+v", v).Error())

			} else {
				a := v[u[0]]
				b := v[u[1]]

				v[u[0]] += b
				v[u[1]] = 0
				queue = append(queue, AnsTuple{Index:un[0], Direct:"R"})

				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]

				v[u[0]] = a
				v[u[1]] = b

			}

		}
		normalizeIndex++
	}
	return false
}
func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()
	k := sc.NextInt()
	b := sc.NextIntArray()

	i := 0
	ans := make([]string, 0)
	for j := 0; j < k; j++ {
		sum := 0
		f := i
		for ; sum < b[j] && i < N; i++ {
			sum += a[i]
		}
		if sum != b[j] {
			fmt.Println("NO")
			return
		}
		if j == k - 1 && i != N {
			fmt.Println("NO")
			return
		}
		queue = make([]AnsTuple, 0)
		if !recv(a[f:i], 0) {
			fmt.Println("NO")
			return
		}
		for i := 0; i < len(queue); i++ {
			str := strconv.Itoa(queue[i].Index + j + 1)
			str += " "
			str += queue[i].Direct
			ans = append(ans, str)
		}

	}
	fmt.Println("YES")
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

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

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

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

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

	return mp
}

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

package main

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

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

type AnsTuple struct {
	Index  int
	Direct string
}

var queue []AnsTuple

func recv(v []int, count int) bool {
	if count == len(v) - 1 {
		return true
	}
	u := [2]int{}
	un := [2]int{}
	normalizeIndex := 0
	normalizeIndex2 := 0

	for i := 0; i < len(v); i++ {
		if v[i] == 0 {
			continue
		}
		u[0] = i
		un[0] = normalizeIndex
		normalizeIndex2 = normalizeIndex
		for j := i + 1; j < len(v); j++ {
			if v[i] == v[j] {
				continue
			}
			normalizeIndex2++

			u[1] = j
			un[1] = normalizeIndex2
			if v[u[0]] < v[u[1]] {
				a := v[u[0]]
				b := v[u[1]]
				v[u[1]] += a
				v[u[0]] = 0
				queue = append(queue, AnsTuple{Index:un[1], Direct:"L"})
				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]
				v[u[0]] = a
				v[u[1]] = b

			} else {
				a := v[u[0]]
				b := v[u[1]]

				v[u[0]] += b
				v[u[1]] = 0
				queue = append(queue, AnsTuple{Index:un[0], Direct:"R"})

				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]

				v[u[0]] = a
				v[u[1]] = b

			}

		}
		normalizeIndex++
	}
	return false
}
func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()
	k := sc.NextInt()
	b := sc.NextIntArray()

	i := 0
	ans := make([]string, 0)
	for j := 0; j < k; j++ {
		sum := 0
		f := i
		for ; sum < b[j] && i < N; i++ {
			sum += a[i]
		}
		if sum != b[j] {
			fmt.Println("NO")
			return
		}
		queue = make([]AnsTuple, 0)
		if !recv(a[f:i], 0) {
			fmt.Println("NO")
			return
		}
		for i := 0; i < len(queue); i++ {
			str := strconv.Itoa(queue[i].Index + j + 1)
			str += " "
			str += queue[i].Direct
			ans = append(ans, str)
		}

	}
	fmt.Println("YES")
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

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

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

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

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

	return mp
}

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

package main

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

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

type AnsTuple struct {
	Index  int
	Direct string
}

var queue []AnsTuple

func recv(v []int, count int) bool {
	if count == len(v) - 1 {
		return true
	}
	u := [2]int{}
	un := [2]int{}
	normalizeIndex := 0
	normalizeIndex2 := 0

	for i := 0; i < len(v); i++ {
		if v[i] == 0 {
			continue
		}
		u[0] = i
		un[0] = normalizeIndex
		normalizeIndex2 = normalizeIndex
		for j := i + 1; j < len(v); j++ {
			if v[i] == v[j] {
				continue
			}
			if v[j] == 0 {
				continue
			}
			normalizeIndex2++

			u[1] = j
			un[1] = normalizeIndex2
			if v[u[0]] < v[u[1]] {
				a := v[u[0]]
				b := v[u[1]]
				v[u[1]] += a
				v[u[0]] = 0
				queue = append(queue, AnsTuple{Index:un[1], Direct:"L"})
				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]
				v[u[0]] = a
				v[u[1]] = b

			} else {
				a := v[u[0]]
				b := v[u[1]]

				v[u[0]] += b
				v[u[1]] = 0
				queue = append(queue, AnsTuple{Index:un[0], Direct:"R"})

				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]

				v[u[0]] = a
				v[u[1]] = b

			}

		}
		normalizeIndex++
	}
	return false
}
func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()
	k := sc.NextInt()
	b := sc.NextIntArray()

	i := 0
	ans := make([]string, 0)
	for j := 0; j < k; j++ {
		sum := 0
		f := i
		for ; sum < b[j] && i < N; i++ {
			sum += a[i]
		}
		if sum != b[j] {
			fmt.Println("NO")
			return
		}
		if j == k - 1 && i != N - 1 {
			fmt.Println("NO")
			return
		}
		queue = make([]AnsTuple, 0)
		if !recv(a[f:i], 0) {
			fmt.Println("NO")
			return
		}
		for i := 0; i < len(queue); i++ {
			str := strconv.Itoa(queue[i].Index + j + 1)
			str += " "
			str += queue[i].Direct
			ans = append(ans, str)
		}

	}
	fmt.Println("YES")
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

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

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

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

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

	return mp
}

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

package main

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

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

type AnsTuple struct {
	Index  int
	Direct string
}

var queue []AnsTuple

func recv(v []int, count int) bool {
	if count == len(v) - 1 {
		return true
	}
	u := [2]int{}
	un := [2]int{}
	normalizeIndex := 0
	normalizeIndex2 := 0

	for i := 0; i < len(v); i++ {
		if v[i] == 0 {
			continue
		}
		u[0] = i
		un[0] = normalizeIndex
		normalizeIndex2 = normalizeIndex
		for j := i + 1; j < len(v); j++ {
			if v[i] == v[j] {
				continue
			}
			if v[j] == 0 {
				continue
			}
			normalizeIndex2++

			u[1] = j
			un[1] = normalizeIndex2
			if v[u[0]] < v[u[1]] {
				a := v[u[0]]
				b := v[u[1]]
				v[u[1]] += a
				v[u[0]] = 0
				queue = append(queue, AnsTuple{Index:un[1], Direct:"L"})
				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]
				v[u[0]] = a
				v[u[1]] = b

			} else {
				a := v[u[0]]
				b := v[u[1]]

				v[u[0]] += b
				v[u[1]] = 0
				queue = append(queue, AnsTuple{Index:un[0], Direct:"R"})

				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]

				v[u[0]] = a
				v[u[1]] = b

			}

		}
		normalizeIndex++
	}
	return false
}
func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()
	k := sc.NextInt()
	b := sc.NextIntArray()

	i := 0
	ans := make([]string, 0)
	for j := 0; j < k; j++ {
		sum := 0
		f := i
		for ; sum < b[j] && i < N; i++ {
			sum += a[i]
		}
		if sum != b[j] {
			fmt.Println("NO")
			return
		}
		queue = make([]AnsTuple, 0)
		if !recv(a[f:i], 0) {
			fmt.Println("NO")
			return
		}
		for i := 0; i < len(queue); i++ {
			str := strconv.Itoa(queue[i].Index + j + 1)
			str += " "
			str += queue[i].Direct
			ans = append(ans, str)
		}

	}
	fmt.Println("YES")
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

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

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

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

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

	return mp
}

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

package main

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

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

type AnsTuple struct {
	Index  int
	Direct string
}

var queue []AnsTuple

func recv(v []int, count int) bool {
	if count == len(v) - 1 {
		return true
	}
	u := [2]int{}
	un := [2]int{}
	normalizeIndex := 0
	normalizeIndex2 := 0

	for i := 0; i < len(v); i++ {
		if v[i] == 0 {
			continue
		}
		u[0] = i
		un[0] = normalizeIndex
		normalizeIndex2 = normalizeIndex
		for j := i + 1; j < len(v); j++ {
			if v[i] == v[j] {
				continue
			}
			if v[j] == 0 {
				continue
			}
			normalizeIndex2++

			u[1] = j
			un[1] = normalizeIndex2
			if v[u[0]] < v[u[1]] {
				a := v[u[0]]
				b := v[u[1]]
				v[u[1]] += a
				v[u[0]] = 0
				queue = append(queue, AnsTuple{Index:un[1], Direct:"L"})
				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]
				v[u[0]] = a
				v[u[1]] = b

			} else {
				a := v[u[0]]
				b := v[u[1]]

				v[u[0]] += b
				v[u[1]] = 0
				queue = append(queue, AnsTuple{Index:un[0], Direct:"R"})

				if recv(v, count + 1) {
					return true
				}
				queue = queue[:len(queue) - 1]

				v[u[0]] = a
				v[u[1]] = b

			}

		}
		normalizeIndex++
	}
	return false
}
func main() {
	sc := NewScanner()
	N := sc.NextInt()
	a := sc.NextIntArray()
	k := sc.NextInt()
	b := sc.NextIntArray()

	i := 0
	ans := make([]string, 0)
	for j := 0; j < k; j++ {
		sum := 0
		f := i
		for ; sum < b[j] && i < N; i++ {
			sum += a[i]
		}
		if sum != b[j] {
			fmt.Println("NO")
			return
		}
		if j == k - 1 && i != N {
			fmt.Println("NO")
			return
		}
		queue = make([]AnsTuple, 0)
		if !recv(a[f:i], 0) {
			fmt.Println("NO")
			return
		}
		for i := 0; i < len(queue); i++ {
			str := strconv.Itoa(queue[i].Index + j + 1)
			str += " "
			str += queue[i].Direct
			ans = append(ans, str)
		}

	}
	fmt.Println("YES")
	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}

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

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

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

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

	return mp
}

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


package main

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

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

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

func getI() int {
  return int(getI64())
}

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

type Node struct {
	value int
	right *Node
	down *Node
}

func newNode(v int) *Node{
	return &Node{value: v}
}

func readMatrix (n, m int) *Node {
	//var root, currentNode, rowFirstNode *Node
	var matrix [][]*Node

	matrix = make([][]*Node, n+2, n+2)

	for colNo := 0; colNo < m + 2; colNo++ {
		matrix[0] = append(matrix[0], newNode(-1))

	}

	for rowNo := 1; rowNo < n+1; rowNo++ {
		matrix[rowNo] = append(matrix[rowNo], newNode(-1))
		for colNo := 1; colNo < m + 1; colNo++ {
			matrix[rowNo] = append(matrix[rowNo], newNode(getI()))
		}
		matrix[rowNo] = append(matrix[rowNo], newNode(-1))
	}

	for colNo := 0; colNo < m + 2; colNo++ {
		matrix[n+1] = append(matrix[n+1], newNode(-1))

	}

	for rowNo := 0; rowNo < n + 2; rowNo++ {
		for colNo := 0; colNo < m + 2; colNo++ {
			if colNo < m + 1 {
				matrix[rowNo][colNo].right = matrix[rowNo][colNo + 1]
			}
			if rowNo < n + 1 {
				matrix[rowNo][colNo].down = matrix[rowNo + 1][colNo]
			}
		}
	}

	return matrix[0][0]

}

func printMatrix(root *Node, n, m int) {
	var currentNode, rowFirst *Node
	rowFirst = root.right.down
	currentNode = rowFirst
	for rowFirst.value != -1 {
		for currentNode.value != -1 {
			writer.WriteString(strconv.Itoa(currentNode.value))
			currentNode = currentNode.right
			if currentNode.value != -1 {
				writer.WriteByte(' ')
			}
		}
		writer.WriteByte('\n')
		rowFirst = rowFirst.down
		currentNode = rowFirst
	}
}

func getXY(root *Node, x, y int) *Node{
	var node *Node
	node = root
	for i:=0; i < x; i++ {
		node = node.down
	}
	for i:=0; i < y; i++ {
		node = node.right
	}
	return node
}

func swap(a, b, c, d, h, w int, root *Node) {
	abNode := getXY(root, a - 1, b - 1)
	cdNode := getXY(root, c - 1, d - 1)

	abNodeVer := abNode
	cdNodeVer := cdNode

	for i:=0; i < h; i++ {
		abNodeVer = abNodeVer.down
		cdNodeVer = cdNodeVer.down
		abNodeVer.right, cdNodeVer.right = cdNodeVer.right, abNodeVer.right
	}

	abNodeHor := abNode
	cdNodeHor := cdNode

	for i:=0; i < w; i++ {
		abNodeHor = abNodeHor.right
		cdNodeHor = cdNodeHor.right
		abNodeHor.down, cdNodeHor.down = cdNodeHor.down, abNodeHor.down
	}

	abNodeVer, cdNodeVer = cdNodeVer.right, abNodeVer.right

	for i:=0; i < w; i++ {
		abNodeVer.down, cdNodeVer.down = cdNodeVer.down, abNodeVer.down
		cdNodeVer = cdNodeVer.right
		abNodeVer = abNodeVer.right
	}

	abNodeHor, cdNodeHor = cdNodeHor.down, abNodeHor.down

	for i:=0; i < h; i++ {
		abNodeHor.right, cdNodeHor.right = cdNodeHor.right, abNodeHor.right
		cdNodeHor = cdNodeHor.down
		abNodeHor = abNodeHor.down
	}

}

func main()  {
	var (
		m, n, q int
		root *Node
	)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

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

	n = getI()
	m = getI()
	q = getI()

	root = readMatrix(n, m)

	for i := 0; i < q; i++ {
		a, b, c, d, h, w := getI(), getI(), getI(), getI(), getI(), getI()
		swap(a, b, c, d, h, w, root)
	}

	printMatrix(root, n, m)
}

package main

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

var in *bufio.Scanner
var out *bufio.Writer

type Node struct {
	val   int
	down  *Node
	right *Node
}

func create(v int) *Node {
	return &Node{
		val:   v,
		down:  nil,
		right: nil,
	}
}

const maxn = 1005

var n, m, q int
var a [maxn][maxn]*Node

func swap(i1 int, j1 int, i2 int, j2 int, h int, w int) {
	node1 := a[0][0]
	node2 := a[0][0]

	for ; i1 > 1; i1-- {
		node1 = node1.down
	}

	for ; j1 > 1; j1-- {
		node1 = node1.right
	}

	for ; i2 > 1; i2-- {
		node2 = node2.down
	}

	for ; j2 > 1; j2-- {
		node2 = node2.right
	}

	save1, save2 := node1, node2

	for k := 1; k <= w; k++ {
		node1, node2 = node1.right, node2.right
		node1.down, node2.down = node2.down, node1.down
	}

	node1, node2 = node2.down, node1.down
	for k := 1; k <= h; k++ {
		node1.right, node2.right = node2.right, node1.right
		node1, node2 = node1.down, node2.down
	}

	for k := 1; k <= h; k++ {
		save1, save2 = save1.down, save2.down
		save1.right, save2.right = save2.right, save1.right
	}

	save1, save2 = save2.right, save1.right
	for k := 1; k <= w; k++ {
		save1.down, save2.down = save2.down, save1.down
		save1, save2 = save1.right, save2.right
	}
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

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

	in.Scan()
	m, _ = strconv.Atoi(in.Text())

	in.Scan()
	q, _ = strconv.Atoi(in.Text())

	for i := 0; i <= n+1; i++ {
		for j := 0; j <= m+1; j++ {
			a[i][j] = create(-1)
		}
	}

	for i := 0; i <= n; i++ {
		for j := 0; j <= m; j++ {
			a[i][j].down = a[i+1][j]
			a[i][j].right = a[i][j+1]
		}
	}

	for i := 1; i <= n; i++ {
		for j := 1; j <= m; j++ {
			in.Scan()
			a[i][j].val, _ = strconv.Atoi(in.Text())
		}
	}

	for k := 1; k <= q; k++ {
		in.Scan()
		i1, _ := strconv.Atoi(in.Text())
		in.Scan()
		j1, _ := strconv.Atoi(in.Text())
		in.Scan()
		i2, _ := strconv.Atoi(in.Text())
		in.Scan()
		j2, _ := strconv.Atoi(in.Text())
		in.Scan()
		h, _ := strconv.Atoi(in.Text())
		in.Scan()
		w, _ := strconv.Atoi(in.Text())
		swap(i1, j1, i2, j2, h, w)
	}

	row := a[0][1].down
	for i := 1; i <= n; i++ {
		col := row
		for j := 1; j <= m; j++ {
			out.WriteString(strconv.Itoa(col.val))
			if j < m {
				out.WriteByte(' ')
			}
			col = col.right
		}
		out.WriteByte('\n')
		row = row.down
	}

}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)
var wrtr = bufio.NewWriterSize(os.Stdout, 10_000_000)
var rdr = bufio.NewScanner(os.Stdin)
func gs() string  { rdr.Scan(); return rdr.Text() }
func gi() int     { i,e := strconv.Atoi(gs()); if e != nil {panic(e)}; return i }
func gis(n int) []int  { res := make([]int,n); for i:=0;i<n;i++ { res[i] = gi() }; return res }
func gf() float64 { f,e := strconv.ParseFloat(gs(),64); if e != nil {panic(e)}; return f }
func gbs() []byte { return []byte(gs()) }
func gfs(n int) []float64  { res := make([]float64,n); for i:=0;i<n;i++ { res[i] = gf() }; return res }
func gss(n int) []string  { res := make([]string,n); for i:=0;i<n;i++ { res[i] = gs() }; return res }
func gi64() int64     { i,e := strconv.ParseInt(gs(),10,64); if e != nil {panic(e)}; return i }
func gis64(n int) []int64  { res := make([]int64,n); for i:=0;i<n;i++ { res[i] = gi64() }; return res }

func ia(m int) []int { return make([]int,m) }
func iai(m int,v int) []int { a := make([]int,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi(n int,m int,v int) [][]int {
	r := make([][]int,n); for i:=0;i<n;i++ { x := make([]int,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill2(m int) ([]int,[]int) { a,b := ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i] = gi(),gi()}; return a,b }
func fill3(m int) ([]int,[]int,[]int) { a,b,c := ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi(),gi(),gi()}; return a,b,c }
func fill4(m int) ([]int,[]int,[]int,[]int) { a,b,c,d := ia(m),ia(m),ia(m),ia(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi(),gi(),gi(),gi()}; return a,b,c,d }
func abs(a int) int { if a < 0 { return -a }; return a }
func rev(a []int) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max(a,b int) int { if a > b { return a }; return b }
func min(a,b int) int { if a > b { return b }; return a }
func maxarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr(a []int) int { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr(a []int) int { ans := 0; for _,aa := range(a) { ans += aa }; return ans }
func zeroarr(a []int) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod(a,e,mod int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint(a,e int) int { res, m := 1, a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd(a,b int) int { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended(a,b int) (int,int,int) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv(a,m int) (int,bool) { g,x,_ := gcdExtended(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecintstring(a []int) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.Itoa(a) }; return strings.Join(astr," ") }
func makefact(n int,mod int) ([]int,[]int) {
	fact,factinv := make([]int,n+1),make([]int,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * i % mod }
	factinv[n] = powmod(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * (i+1) % mod }
	return fact,factinv
}

func ia64(m int) []int64 { return make([]int64,m) }
func iai64(m int,v int64) []int64 { a := make([]int64,m); for i:=0;i<m;i++ { a[i] = v }; return a }
func twodi64(n int,m int,v int64) [][]int64 {
	r := make([][]int64,n); for i:=0;i<n;i++ { x := make([]int64,m); for j:=0;j<m;j++ { x[j] = v }; r[i] = x }; return r
}
func fill264(m int) ([]int64,[]int64) { a,b := ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i] = gi64(),gi64()}; return a,b }
func fill364(m int) ([]int64,[]int64,[]int64) { a,b,c := ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i] = gi64(),gi64(),gi64()}; return a,b,c }
func fill464(m int) ([]int64,[]int64,[]int64,[]int64) { a,b,c,d := ia64(m),ia64(m),ia64(m),ia64(m); for i:=0;i<m;i++ {a[i],b[i],c[i],d[i] = gi64(),gi64(),gi64(),gi64()}; return a,b,c,d }
func abs64(a int64) int64 { if a < 0 { return -a }; return a }
func rev64(a []int64) { i,j := 0,len(a)-1; for i < j { a[i],a[j] = a[j],a[i]; i++; j-- } }
func max64(a,b int64) int64 { if a > b { return a }; return b }
func min64(a,b int64) int64 { if a > b { return b }; return a }
func maxarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa > ans { ans = aa } }; return ans }
func minarr64(a []int64) int64 { ans := a[0]; for _,aa := range(a) { if aa < ans { ans = aa } }; return ans }
func sumarr64(a []int64) int64 { ans := int64(0); for _,aa := range(a) { ans += aa }; return ans }
func zeroarr64(a []int64) { for i:=0; i<len(a); i++ { a[i] = 0 } }
func powmod64(a,e,mod int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m % mod }; m = m * m % mod; e >>= 1 }; return res }
func powint64(a,e int64) int64 { res, m := int64(1), a; for e > 0 { if e&1 != 0 { res = res * m }; m = m * m; e >>= 1 }; return res }
func gcd64(a,b int64) int64 { for b != 0 { t:=b; b=a%b; a=t }; return a }
func gcdExtended64(a,b int64) (int64,int64,int64) { if a == 0 { return b,0,1 }; gcd,x1,y1 := gcdExtended64(b%a,a); return gcd, y1-(b/a)*x1,x1 }
func modinv64(a,m int64) (int64,bool) { g,x,_ := gcdExtended64(a,m); if g != 1 { return 0,false }; return (x % m + m) % m,true  }
func vecint64string(a []int64) string { astr := make([]string,len(a)); for i,a := range a { astr[i] = strconv.FormatInt(a,10) }; return strings.Join(astr," ") }
func makefact64(n int,mod int64) ([]int64,[]int64) {
	fact,factinv := make([]int64,n+1),make([]int64,n+1)
	fact[0] = 1; for i:=1;i<=n;i++ { fact[i] = fact[i-1] * int64(i) % mod }
	factinv[n] = powmod64(fact[n],mod-2,mod); for i:=n-1;i>=0;i-- { factinv[i] = factinv[i+1] * int64(i+1) % mod }
	return fact,factinv
}
func main() {
	//f1, _ := os.Create("cpu.prof"); pprof.StartCPUProfile(f1); defer pprof.StopCPUProfile()
	defer wrtr.Flush()
	infn := ""; if infn == "" && len(os.Args) > 1 {	infn = os.Args[1] }
	if infn != "" {	f, e := os.Open(infn); if e != nil { panic(e) }; rdr = bufio.NewScanner(f) }
	rdr.Split(bufio.ScanWords); rdr.Buffer(make([]byte,1024),1_000_000_000)
	// PROGRAM STARTS HERE
	T := gi()
	for tt:=1;tt<=T;tt++ {
		N := gi(); if N == -1 { panic("SHOULD NOT GET HERE1") }
		l,r := 1,N
		for l != r {
			m := (l+r)>>1
			fmt.Fprintf(wrtr,"? %v %v\n",l,m); wrtr.Flush()
			cnt := 0
			for i:=0;i<m-l+1;i++ {
				a := gi()
				//fmt.Fprintf(os.Stderr,"i:%v a:%v m-l+1:%v\n",i,a,m-l+1)
				if a == -1 { panic("SHOULD NOT GET HERE2") }
				if l <= a && a <= m { cnt++ }
			}
			if cnt % 2 == 1 { r = m } else { l = m+1 }
		}
		fmt.Fprintf(wrtr,"! %v\n",l); wrtr.Flush()
	}
}

package main

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

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

func slove() {
	var n int
	fmt.Fscan(r, &n)
	left, right := 1, n
	for left < right{
		m := left + right
		m /= 2
		fmt.Fprintf(w, "? %d %d\n", left, m)
		w.Flush()
		cnt := 0
		for i:=left;i<=m;i++ {
			var a int
			fmt.Fscan(r, &a)
			if a <= m && a >= left {
				cnt++
			}
		}
		if cnt % 2 == 0 {
			left = m + 1
		} else {
			right = m
		}
	}
	fmt.Fprintf(w, "! %d\n", left)
	w.Flush()
}

func main() {
	defer w.Flush()
	var n int
	fmt.Fscan(r, &n)
	for i:=1;i<=n;i++ {
		slove()
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		l, r := 1, n
		for l < r {
			mid := (r + l) / 2
			fmt.Fprintf(out, "? %d %d\n", l, mid)
			out.Flush()

			var c int
			for i := l; i <= mid; i++ {
				var v int
				fmt.Fscan(in, &v)
				if v >= l && v <= mid {
					c++
				}
			}

			if c%2 != 0 {
				r = mid
			} else {
				l = mid + 1
			}
		}

		fmt.Fprintf(out, "! %d\n", l)
		out.Flush()
	}
}

package main

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

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

func main() {
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		n := readInt(input)
		playGame(n)
	}
}

func playGame(n int) {
	father_l := 1
	father_r := n
	l := father_l
	r := (father_r-father_l)/2 + 1
	length := r - l + 1
	for {
		guess(l, r)
		reply := readArrInt(input)
		correct_in_here := length
		for _, v := range reply {
			if v > r || v < l {
				correct_in_here--
			}
		}
		if correct_in_here%2 == 1 {
			father_l = l
			father_r = r
			l = father_l
			r = (father_r + father_l) / 2
		} else {
			father_l = r + 1
			l = father_l
			r = (father_r + father_l) / 2
		}
		if l == r {
			guess(l, r)
			asdfg := readInt(input)
			if asdfg == l {
				answer(asdfg)
			} else {
				answer(l + 1)
			}
			return
		}
		length = r - l + 1
	}
}

func guess(l int, r int) {
	writer.WriteString("?")
	writer.WriteString(" ")
	writer.Write([]byte(strconv.Itoa(l)))
	writer.WriteString(" ")
	writer.Write([]byte(strconv.Itoa(r)))
	writer.WriteString(" ")
	writer.WriteString("\n")
	writer.Flush()
}

func answer(l int) {
	writer.WriteString("!")
	writer.WriteString(" ")
	writer.Write([]byte(strconv.Itoa(l)))
	writer.WriteString("\n")
	writer.Flush()
}

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		l, r := 1, n
		for r-l > 1 {
			mid := (r + l) / 2
			fmt.Fprintf(out, "? %d %d\n", l, mid)
			out.Flush()

			var c int
			for i := 0; i < mid; i++ {
				var v int
				fmt.Fscan(in, &v)
				if v >= l && v <= mid {
					c++
				}
			}

			if c%2 != 0 {
				r = mid
			} else {
				l = mid + 1
			}
		}

		fmt.Fprintf(out, "! %d\n", l)
		out.Flush()
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		l, r := 1, n
		d := 1
		for r-l > 1 {
			mid := (r + l) / 2
			fmt.Fprintf(out, "? %d %d\n", l, mid)
			out.Flush()

			var c int
			for i := 0; i < mid; i++ {
				var v int
				fmt.Fscan(in, &v)
				if v >= l && v <= mid {
					d = v
					c++
				}
			}

			if c == 1 {
				break
			}

			if c%2 != 0 {
				r = mid
			} else {
				l = mid
			}
		}

		fmt.Fprintf(out, "! %d\n", d)
		out.Flush()
	}
}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		l, r := 1, n
		for r-l > 1 {
			mid := (r - l) / 2
			fmt.Fprintf(out, "? %d %d\n", l, mid)
			out.Flush()

			var c int
			for i := 0; i < mid; i++ {
				var v int
				fmt.Fscan(in, &v)
				if v >= l && v <= mid {
					c++
				}
			}

			if c%2 != 0 {
				r = mid
			} else {
				l = mid
			}
		}

		fmt.Fprintf(out, "? %d %d\n", l, l)
		out.Flush()
		var v int
		fmt.Fscan(in, &v)
		if v != l {
			v++
		}
		fmt.Fprintf(out, "! %d\n", v)
		out.Flush()
	}
}