package main

import (
	"fmt"
	"io/ioutil"
	"bytes"
	"os"
)
type Cost struct {
	Next, Cost int
}
var edge0 []*Cost
var edge1 []*Cost

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	edge0 := make([]*Cost, n, n)
	edge1 := make([]*Cost, n, n)
	for i := 0;i < n;i ++ {
		var a,b,c int
		fmt.Fscanf(reader, "%d %d %d\n", &a, &b, &c)
		a --
		b --
		if edge0[a] == nil {
			edge0[a] = &Cost {Next: b, Cost: 0}
		} else {
			edge1[a] = &Cost {Next: b, Cost: 0}
		}
		if edge0[b] == nil {
			edge0[b] = &Cost {Next: a, Cost: c}
		} else {
			edge1[b] = &Cost {Next: a, Cost: c}
		}

	}
	prev, cur := 0, edge0[0].Next
	cost0 := edge0[0].Cost
	for cur != 0 {
		if prev != edge0[cur].Next {
			cost0 += edge0[cur].Cost
			prev = cur
			cur = edge0[cur].Next
		} else {
			cost0 += edge1[cur].Cost
			prev = cur
			cur = edge1[cur].Next
		}
	}
	prev, cur = 0, edge1[0].Next
	cost1 := edge1[0].Cost
	for cur != 0 {
		if prev != edge0[cur].Next {
			cost1 += edge0[cur].Cost
			prev = cur
			cur = edge0[cur].Next
		} else {
			cost1 += edge1[cur].Cost
			prev = cur
			cur = edge1[cur].Next
		}
	}
	if cost0 < cost1 {
		fmt.Printf("%d", cost0)
	} else {
		fmt.Printf("%d", cost1)
	}
}

package main

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

var scanner *bufio.Scanner

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

var graph = map[int]map[int]int{}

func augment(u, v, c int) {
  _, found := graph[u]
  if !found {
    graph[u] = map[int]int{}
  }
  graph[u][v] = c
}

func traverse(start, u, v int) int {
  cost := graph[u][v]
  if v == start {
    return cost
  }
  neighbors := graph[v]
  for w := range neighbors {
    if w != u {
      return cost + traverse(start, v, w)
    }
  }
  return cost
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n := getI()
  for i := 0; i < n; i++ {
    u, v, c := getI(), getI(), getI()
    augment(u, v, 0)
    augment(v, u, c)
  }
  neighbors := graph[1]
  result := -1
  for v := range neighbors {
    cost := traverse(1, 1, v)
    if result == -1 || cost < result {
      result = cost
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}

package main

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

var scanner *bufio.Scanner

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

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  s := getS()
  n := len(s)
  max := 0
  seen := map[string]bool{}
  for i := 0; i < n; i++ {
    for j := i+1; j <= n; j++ {
      if seen[s[i:j]] && j-i > max {
        max = j-i
      }
      seen[s[i:j]] = true
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", max))
}


package main

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

func isInt(s string) bool {
	if len(s) == 0 {
		return false
	}
	if (len(s) > 1 && s[0] == 48) || s[0] == 45 {
		return false
	}

	for idx := range s {
		if s[idx] < 48 || s[idx] > 57 {
			return false
		}
	}
	return true
}

func main() {
	//var in strings.Builder
	//byteList := []byte{44, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
	//	80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
	//	114, 115, 116, 117, 118, 119, 120, 121, 122}
	//for i := 0; i < int(math.Pow(10, 5)); i++ {
	//	idx := rand.Intn(len(byteList))
	//	in.WriteByte(byteList[idx])
	//}
	//outF, err := os.Create("input.txt")
	//if err != nil {
	//	panic(err)
	//}
	//outF.WriteString(in.String())
	//outF.Close()
	//
	//f, err := os.Open("input.txt")
	//if err != nil {
	//	panic(err)
	//}
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, int(math.Pow(10, 6))), int(math.Pow(10,6)))

	var ints strings.Builder
	var others strings.Builder
	var intCount int
	var othersCount int
	var curr strings.Builder

	scanner.Scan()
	s := scanner.Text()

	for idx := range s {
		if s[idx] == 44 || s[idx] == 59 {
			currStr := curr.String()
			if isInt(currStr) {
				intCount += 1
				ints.WriteString(currStr)
				ints.WriteByte(44)
			} else {
				othersCount += 1
				others.WriteString(currStr)
				others.WriteByte(44)
			}
			curr.Reset()
		} else {
			curr.WriteByte(s[idx])
		}
	}
	currStr := curr.String()
	if isInt(currStr) {
		intCount += 1
		ints.WriteString(currStr)
		ints.WriteByte(44)
	} else {
		othersCount += 1
		others.WriteString(currStr)
		others.WriteByte(44)
	}

	intsStr := ints.String()
	if len(intsStr) > 0 {
		intsStr = intsStr[:len(intsStr)-1]
	}

	othersStr := others.String()
	if len(othersStr) > 0 {
		othersStr = othersStr[:len(othersStr)-1]
	}

	if intCount == 0 {
		intsStr = "-"
	} else {
		intsStr = "\"" + intsStr + "\""
	}

	if othersCount == 0 {
		othersStr = "-"
	} else {
		othersStr = "\"" + othersStr + "\""
	}

	fmt.Println(intsStr)
	fmt.Println(othersStr)
}

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func Scanf(args ...interface{}) {
	fmt.Fscanln(in, args...)
}

func outs(ints []string) {
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	if li := len(ints); li > 0 {
		f.WriteString("\"")
		for i, _ := range ints {
			f.WriteString(ints[i])
			if i != li-1 {
				f.WriteString(",")
			}
		}
		f.WriteString("\"\n")
	} else {
		f.WriteString("-\n")
	}
}

func main() {
	var s string
	Scanf(&s)
	l := len(s)
	strs := make([]string, 0, 10000)
	ints := make([]string, 0, 10000)
	for i := 0; i < l; {
		isInt := true
		start := i
		for i < l && s[i] != ',' && s[i] != ';' {
			if s[i] < '0' || s[i] > '9' {
				isInt = false
			}
			i++
		}
		wl := i - start

		var apStr string
		if start == i {
			apStr = string(s[start:i])
			isInt = false
		} else {
			if s[start] == '0' && wl > 1 {
				isInt = false
			}
			apStr = string(s[start:i])
		}

		if isInt {
			ints = append(ints, apStr)
		} else {
			strs = append(strs, apStr)
		}
		if i == l-1 && (s[i] == ',' || s[i] == ';') {
			strs = append(strs, "")
		}
		i++
	}

	outs(ints)
	outs(strs)
}

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func Scanf(args ...interface{}) {
	fmt.Fscanln(in, args...)
}

func outs(ints []string) {
	if li := len(ints); li > 0 {
		fmt.Print("\"")
		for i, _ := range ints {
			fmt.Print(ints[i])
			if i != li-1 {
				fmt.Print(",")
			}
		}
		fmt.Print("\"\n")
	} else {
		fmt.Println("-")
	}

}

func main() {
	var s string
	Scanf(&s)
	l := len(s)
	strs := make([]string, 0, 10000)
	ints := make([]string, 0, 10000)
	for i := 0; i < l; {
		isInt := true
		start := i
		for i < l && s[i] != ',' && s[i] != ';' {
			if s[i] < '0' || s[i] > '9' {
				isInt = false
			}
			i++
		}
		wl := i - start

		var apStr string
		if start == i {
			apStr = string(s[start:i])
			isInt = false
		} else {
			if s[start] == '0' && wl > 1 {
				isInt = false
			}
			apStr = string(s[start:i])
		}

		if isInt {
			ints = append(ints, apStr)
		} else {
			strs = append(strs, apStr)
		}
		if i == l-1 && (s[i] == ',' || s[i] == ';') {
			strs = append(strs, "")
		}
		i++
	}

	outs(ints)
	outs(strs)
}

package main

import "fmt"

func main() {
	var s, a, b string
	fmt.Scan(&s)
	a, b = short(s)
	printResult(a)
	printResult(b)
}

func short(s string) (string, string) {
	var a, b, tmp string
	for _, r := range s {
		if r == ';' || r == ',' {
			if isInteger(tmp) {
				a = a + tmp + ","
			} else {
				b = b + tmp + ","
			}
			tmp = ""
		} else {
			tmp = tmp + string(r)
		}
	}
	if isInteger(tmp) {
		a = a + tmp + ","
	} else {
		b = b + tmp + ","
	}
	return a, b

}

func isInteger(w string) bool {
	if len(w) == 0 {
		return false
	}
	if len(w) > 1 && w[0] == '0' {
		return false
	}
	for _, r := range w {
		if byte(r) < 48 || byte(r) > 57 {
			return false
		}
	}
	return true
}

func printResult(a string) {
	if len(a) == 0 {
		a = "-"
	} else {
		a = `"` + a[:len(a)-1] + `"`
	}
	fmt.Println(a)
}

func split(s string) []string {
	var res []string
	var tmp string
	for _, r := range s {
		if r == ';' || r == ',' {
			res = append(res, tmp)
			tmp = ""
		} else {
			tmp = tmp + string(r)
		}
	}
	res = append(res, tmp)
	return res
}

package main

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

func isNumber(str *string) bool{
	if len(*str) == 0{
		return false
	}
	if len(*str) == 1 && (*str)[0] == '0'{
		return true
	}
	if (*str)[0] == '0'{
		return false
	}
	for _, x:= range (*str){
		if x < '0' || x > '9'{
			return false
		}
	}
	return true
}

const(
	n = int(1e5 + 5)
)
func filter(input chan *string, intOut chan *string, strOut chan *string){
	for str := range input{
		if isNumber(str){
			intOut <- str
		} else {
			strOut <- str
		}
	}
	close(intOut)
	close(strOut)
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	input, _ := rs.ReadString('\n')
	input = strings.TrimSpace(input)

	// parsed := strings.FieldsFunc(input, func(a rune) bool {return a == ';' || a == ','})
	parsed1 := strings.Split(input, ",")
	parsed	:= make([]string, 0, n)

	for i := range parsed1{
		if len(parsed1[i]) > 0{
			parsed2 := strings.Split(parsed1[i], ";")
			parsed = append(parsed, parsed2...)
		} else {
			parsed = append(parsed, parsed1[i])
		}
	}

	ints := make(chan *string)
	strs := make(chan *string)
	inputs := make(chan *string)

	go filter(inputs, ints, strs)

	go func (){
		for i := range parsed{
			inputs <- &parsed[i]
		}
		close(inputs)
	}()

	intString := make([]byte, 0, n)
	strString := make([]byte, 0, n)

	for {
		select {
		case x, ok := <-ints:
			if !ok {
				ints = nil
			} else {
				intString = append(intString, ',')
				intString = append(intString, []byte(*x)...)
			}

		case x, ok := <-strs:
			if !ok {
				strs = nil
			} else {
				strString = append(strString, ',')
				strString = append(strString, []byte(*x)...)
			}
		}

		if ints == nil && strs == nil {
			break
		}
	}

	if len(intString) > 0{
		ws.WriteString("\"" + string(intString[1:]) + "\"\n")
	} else {
		ws.WriteString("-\n")
	}

	if len(strString) > 0{
		ws.WriteString("\"" + string(strString[1:]) + "\"\n")
	} else {
		ws.WriteString("-\n")
	}

	ws.Flush()
}

package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	parse(s)
}

func parse(s string) {
	words := split(s)

	once := false
	for _, w := range words {
		if isNumber(w) {
			if once {
				fmt.Print(",")
			} else {
				fmt.Print(`"`)
			}
			fmt.Print(w)
			once = true
		}
	}
	if !once {
		fmt.Println("-")
	} else {
		fmt.Println(`"`)
	}

	once = false
	for _, w := range words {
		if !isNumber(w) {
			if once {
				fmt.Print(",")
			} else {
				fmt.Print(`"`)
			}
			fmt.Print(w)
			once = true
		}
	}
	if !once {
		fmt.Println("-")
	} else {
		fmt.Println(`"`)
	}
}

func split(s string) []string {
	var result []string

	last := 0
	for i, r := range s {
		if r == ';' || r == ',' {
			result = append(result, s[last:i])
			last = i + 1
		}
	}
	result = append(result, s[last:])
	return result
}

func isNumber(w string) bool {
	if len(w) < 1 {
		return false
	}
	bad := false

	for i, r := range w {
		switch r {
		case '0':
			if bad {
				return false
			}
			if i == 0 {
				bad = true
			}
		case '1', '2', '3', '4', '5', '6', '7', '8', '9':
			if bad {
				return false
			}
			continue
		default:
			return false
		}
	}
	return true
}

package main

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

var (
	in = bufio.NewReader(os.Stdin)
)

func Scanf(args ...interface{}) {
	fmt.Fscanln(in, args...)
}

func outs(ints []string) {
	f := bufio.NewWriter(os.Stdout)
	defer f.Flush()
	if li := len(ints); li > 0 {
		f.WriteString("\"")
		for i, _ := range ints {
			f.WriteString(ints[i])
			if i != li-1 {
				f.WriteString(",")
			}
		}
		f.WriteString("\"\n")
	} else {
		f.WriteString("-")
	}
}

func main() {
	var s string
	Scanf(&s)
	l := len(s)
	strs := make([]string, 0, 10000)
	ints := make([]string, 0, 10000)
	for i := 0; i < l; {
		isInt := true
		start := i
		for i < l && s[i] != ',' && s[i] != ';' {
			if s[i] < '0' || s[i] > '9' {
				isInt = false
			}
			i++
		}
		wl := i - start

		var apStr string
		if start == i {
			apStr = string(s[start:i])
			isInt = false
		} else {
			if s[start] == '0' && wl > 1 {
				isInt = false
			}
			apStr = string(s[start:i])
		}

		if isInt {
			ints = append(ints, apStr)
		} else {
			strs = append(strs, apStr)
		}
		if i == l-1 && (s[i] == ',' || s[i] == ';') {
			strs = append(strs, "")
		}
		i++
	}

	outs(ints)
	outs(strs)
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s, a, b string
	fmt.Scan(&s)
	ws := split(s)
	for _, w := range ws {
		if i, err := strconv.Atoi(w); err != nil || i < 0 || (i != 0 && w[0] == '0') {
			b = b + w + ","
		} else {
			a = a + w + ","
		}
	}

	if len(a) == 0 {
		a = "-"
	} else {
		a = a[:len(a)-1]
	}

	if len(b) == 0 {
		b = "-"
	} else {
		b = b[:len(b)-1]
	}
	fmt.Println("\"" + a + "\"")
	fmt.Println("\"" + b + "\"")
}

func split(s string) []string {
	var res []string
	var tmp string
	for _, r := range s {
		if r == ';' || r == ',' {
			res = append(res, tmp)
			tmp = ""
		} else {
			tmp = tmp + string(r)
		}
	}
	res = append(res, tmp)
	return res
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s, a, b string
	fmt.Scan(&s)
	ws := split(s)
	for _, w := range ws {
		if isInteger(w) {
			a = a + w + ","
		} else {
			b = b + w + ","
		}
	}
	printResult(a)
	printResult(b)
}

func isInteger(w string) bool {
	if len(w) == 0 {
		return false
	}
	if len(w) > 0 && (w[0] == '0' || w[0] == '-') {
		return false
	}
	for _, r := range w {
		if _, err := strconv.Atoi(string(r)); err != nil {
			return false
		}
	}
	return true
}

func printResult(a string) {
	if len(a) == 0 {
		a = "-"
	} else {
		a = `"` + a[:len(a)-1] + `"`
	}
	fmt.Println(a)
}

func split(s string) []string {
	var res []string
	var tmp string
	for _, r := range s {
		if r == ';' || r == ',' {
			res = append(res, tmp)
			tmp = ""
		} else {
			tmp = tmp + string(r)
		}
	}
	res = append(res, tmp)
	return res
}

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s, a, b string
	fmt.Scan(&s)
	ws := split(s)
	for _, w := range ws {
		if i, err := strconv.Atoi(w); err != nil || i < 0 || (i != 0 && w[0] == '0') {
			b = b + w + ","
		} else {
			a = a + w + ","
		}
	}

	if len(a) == 0 {
		a = "-"
	} else {
		a = `"` + a[:len(a)-1] + `"`
	}

	if len(b) == 0 {
		b = "-"
	} else {
		b = `"` + b[:len(b)-1] + `"`
	}
	fmt.Println(a)
	fmt.Println(b)
}

func split(s string) []string {
	var res []string
	var tmp string
	for _, r := range s {
		if r == ';' || r == ',' {
			res = append(res, tmp)
			tmp = ""
		} else {
			tmp = tmp + string(r)
		}
	}
	res = append(res, tmp)
	return res
}

package main

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

func isInt(s string) bool {
	if len(s) == 0 {
		return false
	}
	if (len(s) > 1 && s[0] == 48) || s[0] == 45 {
		return false
	}

	for idx := range s {
		if s[idx] < 48 || s[idx] > 57 {
			return false
		}
	}
	return true
}

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

	scanner.Scan()
	s := scanner.Text()

	var ints strings.Builder
	var others strings.Builder
	var curr strings.Builder
	for idx := range s {
		if s[idx] == 44 || s[idx] == 59 {
			currStr := curr.String()
			if isInt(currStr) {
				ints.WriteString(currStr)
				ints.WriteByte(44)
			} else {
				others.WriteString(currStr)
				others.WriteByte(44)
			}
			curr.Reset()
		} else {
			curr.WriteByte(s[idx])
		}
	}
	currStr := curr.String()
	if isInt(currStr) {
		ints.WriteString(currStr)
		ints.WriteByte(44)
	} else {
		others.WriteString(currStr)
		others.WriteByte(44)
	}

	intsStr := ints.String()
	if len(intsStr) > 0 {
		intsStr = intsStr[:len(intsStr)-1]
	}

	othersStr := others.String()
	if len(othersStr) > 0 {
		othersStr = othersStr[:len(othersStr)-1]
	}

	if len(intsStr) == 0 {
		intsStr = "-"
	} else {
		intsStr = "\"" + intsStr + "\""
	}

	if len(othersStr) == 0 {
		othersStr = "-"
	} else {
		othersStr = "\"" + othersStr + "\""
	}

	fmt.Println(intsStr)
	fmt.Println(othersStr)

}

package main

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

func isInt(s string) bool {
	if len(s) == 0 {
		return false
	}
	if (len(s) > 1 && s[0] == 48) || s[0] == 45 {
		return false
	}

	for idx := range s {
		if s[idx] < 48 || s[idx] > 57 {
			return false
		}
	}
	return true
}

func main() {
	//var in strings.Builder
	//byteList := []byte{44, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
	//	80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
	//	114, 115, 116, 117, 118, 119, 120, 121, 122}
	//for i := 0; i < int(math.Pow(10, 5)); i++ {
	//	idx := rand.Intn(len(byteList))
	//	in.WriteByte(byteList[idx])
	//}
	//outF, err := os.Create("input.txt")
	//if err != nil {
	//	panic(err)
	//}
	//outF.WriteString(in.String())
	//outF.Close()
	//
	//f, err := os.Open("input.txt")
	//if err != nil {
	//	panic(err)
	//}
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, int(math.Pow(10, 6))), int(math.Pow(10,6)))

	var ints strings.Builder
	var others strings.Builder
	var curr strings.Builder

	scanner.Scan()
	s := scanner.Text()

	fmt.Println(s)
	for idx := range s {
		if s[idx] == 44 || s[idx] == 59 {
			currStr := curr.String()
			if isInt(currStr) {
				ints.WriteString(currStr)
				ints.WriteByte(44)
			} else {
				others.WriteString(currStr)
				others.WriteByte(44)
			}
			curr.Reset()
		} else {
			curr.WriteByte(s[idx])
		}
	}
	currStr := curr.String()
	if isInt(currStr) {
		ints.WriteString(currStr)
		ints.WriteByte(44)
	} else {
		others.WriteString(currStr)
		others.WriteByte(44)
	}

	intsStr := ints.String()
	if len(intsStr) > 0 {
		intsStr = intsStr[:len(intsStr)-1]
	}

	othersStr := others.String()
	if len(othersStr) > 0 {
		othersStr = othersStr[:len(othersStr)-1]
	}

	if len(intsStr) == 0 {
		intsStr = "-"
	} else {
		intsStr = "\"" + intsStr + "\""
	}

	if len(othersStr) == 0 {
		othersStr = "-"
	} else {
		othersStr = "\"" + othersStr + "\""
	}

	fmt.Println(intsStr)
	fmt.Println(othersStr)
}

package main

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

func isInt(s string) bool {
	if len(s) == 0 {
		return false
	}
	if (len(s) > 1 && s[0] == 48) || s[0] == 45 {
		return false
	}

	for idx := range s {
		if s[idx] < 48 || s[idx] > 57 {
			return false
		}
	}
	return true
}

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

	var ints strings.Builder
	var others strings.Builder
	var curr strings.Builder

	for scanner.Scan() {
		s := scanner.Text()

		for idx := range s {
			if s[idx] == 44 || s[idx] == 59 {
				currStr := curr.String()
				if isInt(currStr) {
					ints.WriteString(currStr)
					ints.WriteByte(44)
				} else {
					others.WriteString(currStr)
					others.WriteByte(44)
				}
				curr.Reset()
			} else {
				curr.WriteByte(s[idx])
			}
		}
		currStr := curr.String()
		if isInt(currStr) {
			ints.WriteString(currStr)
			ints.WriteByte(44)
		} else {
			others.WriteString(currStr)
			others.WriteByte(44)
		}

		intsStr := ints.String()
		if len(intsStr) > 0 {
			intsStr = intsStr[:len(intsStr)-1]
		}

		othersStr := others.String()
		if len(othersStr) > 0 {
			othersStr = othersStr[:len(othersStr)-1]
		}

		if len(intsStr) == 0 {
			intsStr = "-"
		} else {
			intsStr = "\"" + intsStr + "\""
		}

		if len(othersStr) == 0 {
			othersStr = "-"
		} else {
			othersStr = "\"" + othersStr + "\""
		}

		fmt.Println(intsStr)
		fmt.Println(othersStr)
	}
}

package main

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

func isInt(s string) bool {
	if len(s) == 0 {
		return false
	}
	if (len(s) > 1 && s[0] == 48) || s[0] == 45 {
		return false
	}

	for idx := range s {
		if s[idx] < 48 || s[idx] > 57 {
			return false
		}
	}
	return true
}

func main() {
	//var in strings.Builder
	//byteList := []byte{44, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
	//	80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
	//	114, 115, 116, 117, 118, 119, 120, 121, 122}
	//for i := 0; i < int(math.Pow(10, 5)); i++ {
	//	idx := rand.Intn(len(byteList))
	//	in.WriteByte(byteList[idx])
	//}
	//outF, err := os.Create("input.txt")
	//if err != nil {
	//	panic(err)
	//}
	//outF.WriteString(in.String())
	//outF.Close()
	//
	//f, err := os.Open("input.txt")
	//if err != nil {
	//	panic(err)
	//}
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, int(math.Pow(10, 6))), int(math.Pow(10,6)))

	var ints strings.Builder
	var others strings.Builder
	var curr strings.Builder

	scanner.Scan()
	s := scanner.Text()

	for idx := range s {
		if s[idx] == 44 || s[idx] == 59 {
			currStr := curr.String()
			if isInt(currStr) {
				ints.WriteString(currStr)
				ints.WriteByte(44)
			} else {
				others.WriteString(currStr)
				others.WriteByte(44)
			}
			curr.Reset()
		} else {
			curr.WriteByte(s[idx])
		}
	}
	currStr := curr.String()
	if isInt(currStr) {
		ints.WriteString(currStr)
		ints.WriteByte(44)
	} else {
		others.WriteString(currStr)
		others.WriteByte(44)
	}

	intsStr := ints.String()
	if len(intsStr) > 0 {
		intsStr = intsStr[:len(intsStr)-1]
	}

	othersStr := others.String()
	if len(othersStr) > 0 {
		othersStr = othersStr[:len(othersStr)-1]
	}

	if len(intsStr) == 0 {
		intsStr = "-"
	} else {
		intsStr = "\"" + intsStr + "\""
	}

	if len(othersStr) == 0 {
		othersStr = "-"
	} else {
		othersStr = "\"" + othersStr + "\""
	}

	fmt.Println(intsStr)
	fmt.Println(othersStr)
}


package main

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

const SZ int = 1e5

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	// var str string = "2"
	// for i:= 0; i < SZ; i++ {
	// 	str += "3"
	// }
	var ans []byte = make([]byte,SZ)
	ans[0] = '2'
	for i:= 1; i < SZ; i++ {
		ans[i] = '3'
	}
	var (
		T int
		n int
	)
	//fmt.Scan(&T)
	//fmt.Scanf("%d\n",&T)
	scanf("%d\n",&T)
	for i:= 0; i < T; i++ {
		//fmt.Scan(&n)
		//fmt.Scanf("%d\n",&n)
		scanf("%d\n",&n)
		if n <= 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(string(ans[:n]))
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	nn := 0
	fmt.Fscanf(in, "%d\n", &nn)
	for ii := 0; ii < nn; ii++ {
		n := 0
		fmt.Fscanf(in, "%d\n", &n)
		if n == 1 {
			fmt.Fprintf(out, "%d\n", -1)
		} else {
			ans := make([]byte, n)
			ans[n-1] = '3'
			for i := 1; i < n-1; i++ {
				ans[i] = '2'
			}
			if (n-1)%3 == 0 {
				ans[0] = '3'
			} else {
				ans[0] = '2'
			}
			fmt.Fprintf(out, "%s\n", string(ans))
		}
	}
	return
}

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

package main

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

var reader io.Reader
var scanner *bufio.Scanner

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

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

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

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

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

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

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

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

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

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

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

func mod(a, b, n, m int) int {
	r := 0
	for i := 0; i < n; i++ {
		r = (r*10 + a) % m
	}
	r = (((r + b - a) % m) + m) % m
	return r
}

func good(a, b, n int) bool {
	if a == b {
		return false
	}
	if mod(a, b, n, a) == 0 {
		return false
	}
	if mod(a, b, n, b) == 0 {
		return false
	}
	return true
}

func res(out io.Writer, a, b, n int) {
	for i := 0; i < n-1; i++ {
		fmt.Fprint(out, a)
	}
	fmt.Fprintln(out, b)
}

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

	T := NextInt()
	for t := 0; t < T; t++ {
		n := NextInt()

		if n == 1 {
			fmt.Fprintln(out, -1)
			continue
		}

		ok := false
		for a := 2; !ok && a <= 9; a++ {
			for b := 2; !ok && b <= 9; b++ {
				if good(a, b, n) {
					res(out, a, b, n)
					ok = true
				}
			}
		}

		if !ok {
			fmt.Fprintln(out, -1)
		}
	}

}

package main

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

func main(){

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	out.Flush()
	var t,n int

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

	for T := 0 ; T < t ; T ++ {
		fmt.Fscanf(in,"%d\n",&n)

		//fmt.Println("n = ",n )

		if  n == 1 {
			//fmt.Fprintf(out , "-1\n")
			fmt.Println("-1")
		} else{
			var output string = ""
			output += "2"

			for i := 0 ; i + 1 < n ; i ++ {
				output += "3"
			}
			//fmt.Fprintf(out,"%s\n",output)
			fmt.Println(output)
		}

	}

}

package main

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

const (
	maxn = int(1e5 + 50)
	mod  = int(1e9 + 7)
	eps  = 1e-8
	inf  = int(0x3f3f3f3f)
)

func main() {
	var T int
	scanInt(&T)
	for kase := 1; kase <= T; kase++ {
		n := 0
		scanInt(&n)
		if n == 1 {
			printString("-1")
		} else {
			putchar('2')
			for i := 1; i < n; i++ {
				putchar('3')
			}
			putchar('\n')
		}
	}
	close(channelType)
	oWg.Wait()
	out.Flush()
}

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

var channelType chan string
var in *bufio.Scanner
var out = bufio.NewWriter(os.Stdout)
var oWg *sync.WaitGroup

// string and slice are the return value
func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	channelType = make(chan string, 16)
	oWg = &sync.WaitGroup{}
	oWg.Add(1)
	writer := bufio.NewWriter(os.Stdout)
	go func() {
		defer oWg.Done()
		defer writer.Flush()

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

func scanString() string { in.Scan(); return in.Text() }
func scanInt(a *int)     { *a, _ = strconv.Atoi(scanString()) }
func scanInts(a ...*int) {
	for i := range a {
		*a[i], _ = strconv.Atoi(scanString())
	}
}
func scanInt64(a *int64) { *a, _ = strconv.ParseInt(scanString(), 10, 64) }
func scanInt64s(a ...*int64) {
	for i := range a {
		*a[i], _ = strconv.ParseInt(scanString(), 10, 64)
	}
}
func scanStringSlice(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = scanString()
	}
	return s
}
func scanIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		scanInt(&arr[i])
	}
	return arr
}
func scanInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		scanInt64(&arr[i])
	}
	return arr
}
func printlnInts(args ...int) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printlnInt64s(args ...int64) {
	for _, x := range args {
		fmt.Fprint(out, x, " ")
	}
	fmt.Fprintln(out)
}
func printIntSlice(a []int, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func printInt64Slice(a []int64, flag bool) {
	for _, x := range a {
		fmt.Fprint(out, x, " ")
	}
	if flag { fmt.Fprintln(out) }
}
func printRuneSlice(a []rune, flag bool) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
	if flag { fmt.Fprintln(out) }
}
func putchar(a ...rune) {
	for _, x := range a {
		fmt.Fprintf(out, "%c", x)
	}
}
func printString(s string) { fmt.Fprintln(out, s) }

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

func stringEquivalent(v interface{}) string { return fmt.Sprintf("%v", v) }
func spaceSeperatedStringFromArray(a []int) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.Itoa(a[i]) + " ")
	}
	return sb.String()
}
func spaceSeperatedStringFromArray64(a []int64) string {
	sb := strings.Builder{}
	sb.Grow(len(a) * 9)
	for i := range a {
		sb.WriteString(strconv.FormatInt(a[i], 10) + " ")
	}
	return sb.String()
}
func minMaxFromArray(args ...int64) (int64, int64) {
	minVal, maxVal := int64(math.MaxInt64), int64(math.MinInt64)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func minElementFromArray(args ...int64) int64 { mn, _ := minMaxFromArray(args...); return mn }
func maxElementFromArray(args ...int64) int64 { _, mx := minMaxFromArray(args...); return mx }
func lcmCalculation(a, b int64) int64         { return a / gcdCalculation(a, b) * b }
func gcdCalculation(a, b int64) int64 {
	if a == 0 {
		return b
	}
	return gcdCalculation(b%a, a)
}
func sortInt64Slice(a []int64) { sort.Slice(a, func(i, j int) bool { return a[i] < a[j] }) }
func absoluteValue(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}
func min(args ...int) int { mn, _ := minMaxFinder(args...); return mn }
func max(args ...int) int { _, mx := minMaxFinder(args...); return mx }
func minMaxFinder(args ...int) (int, int) {
	minVal, maxVal := int(math.MaxInt32), int(math.MinInt32)
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func same(x, y double) bool { return math.Abs(float64(x-y)) < eps }
func popcount(x int) (res int) {
	for i := 0; i < 32; i++ {
		if 1 == (1 & (x >> uint(i))) {
			res++
		}
	}
	return
}
func qp(a, n int64) (res int64) {
	for ; n > 0; n >>= 1 {
		if (n & 1) == 1 {
			res = res * a % int64(mod)
		}
		a = a * a % int64(mod)
	}
	return
}
func divUp(a, b int64) int64 {
	if a % b == 0 { return a / b } else { return a / b + 1 }
}
// [l, r)
func reverse(a *[]rune, l, r int) {
	for i, j := l, r - 1; i < j; i, j = i + 1, j - 1 {
		(*a)[i], (*a)[j] = (*a)[j], (*a)[i]
	}
}

/*********************** Structs ***********************/
type pair struct{ X, Y int }
type double float64
type pairSlice []pair

func (p pairSlice) Len() int { return len(p) }
func (p pairSlice) Less(i, j int) bool {
	if p[i].X != p[j].X {
		return p[i].X < p[j].X
	} else {
		return p[i].Y < p[j].Y
	}
}
func (p pairSlice) Swap(i, j int) { p[i], p[j] = p[j], p[i] }

package main

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

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

	var t, n int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n)
		if n == 1 {
			Fprintln(out, -1)
		} else {
			Fprintln(out, "5"+strings.Repeat("3", n-1))
		}
	}
}

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

package main

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

func main() {
	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()
		P(solve(n))
	}

	close(O)
	oWg.Wait()
}

func solve(n int) string {
	if n == 1 {
		return "-1"
	}
	s := strings.Repeat("3", n-1)
	return "2" + s
}

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

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

func init() {
	P = fmt.Println

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

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

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

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

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

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

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

package main

import "fmt"

const SZ int = 1e5

func main() {
	var str string = "2"
	for i:= 0; i < SZ; i++ {
		str += "3"
	}
	var (
		T int
		n int
	)
	//fmt.Scan(&T)
	fmt.Scanf("%d\n",&T)
	for i:= 0; i < T; i++ {
		//fmt.Scan(&n)
		fmt.Scanf("%d\n",&n)
		if n <= 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(str[:n])
		}
	}
}

package main

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

const SZ int = 1e5

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	// var str string = "2"
	// for i:= 0; i < SZ; i++ {
	// 	str += "3"
	// }
	var ans []byte = make([]byte,SZ)
	ans[0] = '2'
	for i:= 1; i < SZ; i++ {
		ans[i] = '3'
	}
	var (
		T int
		n int
	)
	fmt.Scan(&T)
	//fmt.Scanf("%d\n",&T)
	//scanf("%d\n",&T)
	for i:= 0; i < T; i++ {
		fmt.Scan(&n)
		//fmt.Scanf("%d\n",&n)
		//scanf("%d\n",&n)
		if n <= 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(string(ans[:n]))
		}
	}
}

package main

import "fmt"

const SZ int = 1e5

func main() {
	var str string = "2"
	for i:= 0; i < SZ; i++ {
		str += "3"
	}
	var (
		T int
		n int
	)
	fmt.Scan(&T)
	for i:= 0; i < T; i++ {
		fmt.Scan(&n)
		if n <= 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(str[:n])
		}
	}
}

package main

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

const SZ int = 1e5

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	var str string = "2"
	for i:= 0; i < SZ; i++ {
		str += "3"
	}
	var (
		T int
		n int
	)
	//fmt.Scan(&T)
	//fmt.Scanf("%d\n",&T)
	scanf("%d\n",&T)
	for i:= 0; i < T; i++ {
		//fmt.Scan(&n)
		//fmt.Scanf("%d\n",&n)
		scanf("%d\n",&n)
		if n <= 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(str[:n])
		}
	}
}

package main

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

func solve(n uint64) string {
	if n == 1 {
		return "-1"
	}

	sum := 0
	r := make([]byte, n)
	for i := range r {
		d := 2
		for d < 9 && (sum+d)%9 == 0 {
			d *= 2
		}
		if d > 9 {
			return "-1"
		}
		sum += d
		r[i] = '0' + byte(d)
	}
	r[n-1] = '9'

	return string(r)
}

func main() {
	toInt := func(buf []byte) uint64 {
		var n uint64
		for _, v := range buf {
			n = n*10 + uint64(v-'0')
		}
		return n
	}

	var n uint64

	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := uint64(0); i < n; i++ {
		scanner.Scan()
		input := toInt(scanner.Bytes())
		fmt.Println(solve(input))
	}

}

package main

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

func main() {
	sc := NewScanner()

	N := sc.NextInt()
	for i := 0; i < N; i++ {
		A := sc.NextInt()

		s := strings.Builder{}
		if A == 1 {
			fmt.Println(-1)
			continue
		}
		if (A-1)%3 != 0 {
			for j := 0; j < A-1; j++ {
				s.WriteByte('2')
			}
			s.WriteByte('3')
		} else {
			for j := 0; j < A-2; j++ {
				s.WriteByte('2')
			}
			s.WriteByte('3')
			s.WriteByte('3')
		}
		fmt.Println(s.String())

	}
}

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

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

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 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 (
	"fmt"
)
import (
	"bufio"
	"os"
	"io"
)

func ReadInt(line []byte) int {
	var ret = 0
	for i := range line {
		ret = ret * 10 + int(line[i] - '0')
	}
	return ret
}

func Reader() func() int {
	var input []byte
	var idx int
	scanner := bufio.NewReader(os.Stdin)
	return func() int {
		var ret, sign = 0, 1
		for flag := true; flag; {
			for ; idx < len(input); idx++ {
				if (input[idx] >= '0' && input[idx] <= '9') || input[idx] == '-' {
					if input[idx] == '-' {
						sign = -1
						idx += 1
					}
					flag = false
					break
				}
			}
			if !flag {
				break
			}

			var err error
			input, _, err = scanner.ReadLine()
			idx = 0
			if err == io.EOF {
				return -1
			}
		}
		for ; idx < len(input) && input[idx]>='0' && input[idx]<='9'; idx++ {
			ret = ret * 10 + int(input[idx] -'0');
		}
		return ret * sign
	}
}

func main() {
	reader := Reader()
	n := reader()

	for ; n > 0; n-- {
		a := reader()
		if a == 1 {
			fmt.Println(-1)
		} else {
			fmt.Print(5)
			for i := 0; i < a-1; i++ {
				fmt.Print(7)
			}
			fmt.Println()
		}
	}
}

package main

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

var (
	reader Reader = NewReader()
	writer Writer = NewWriter()
)

type Reader interface {
	NextInt() int
	NextInt64() int64
	NextString() string
}

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

type readerImpl struct {
	*bufio.Scanner
}

func NewReader() Reader {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return &readerImpl{Scanner: s}
}

func (i *readerImpl) NextInt() int {
	i.Scan()
	ret, _ := strconv.Atoi(i.Text())
	return ret
}

func (i *readerImpl) NextInt64() int64 {
	i.Scan()
	ret, _ := strconv.ParseInt(i.Text(), 10, 64)
	return ret
}

func (i *readerImpl) NextString() string {
	i.Scan()
	return i.Text()
}

type writerImpl struct {
	*bufio.Writer
}

func NewWriter() Writer {
	return &writerImpl{Writer: bufio.NewWriter(os.Stdout)}
}

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

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

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n := reader.NextInt64()
		writer.Printf("%s\n", sol(n))
	}
}

func sol(i int64) string {
	if i == 1 {
		return "-1"
	}
	return "2" + strings.Repeat("3", int(i-1))
}

package main

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

func main() {
	for t := ScanInt(); t > 0; t-- {
	    n := ScanInt()
	    P(solve(n))
	}

	close(O)
	oWg.Wait()
}

func solve(n int) string {
	if n == 1 {
		return "-1"
	}
	s := strings.Repeat("2", n-1)
	return s + "3"
}
/*********************** I/O ***********************/

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

func init() {
	P = fmt.Println

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

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

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

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

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

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

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

package main

import "fmt"

const SZ int = 1e5

func main() {
	var str string = "2"
	for i:= 0; i < SZ; i++ {
		str += "3"
	}
	var (
		T int
		n int
	)
	fmt.Scanf("%d",&T)
	for i:= 0; i < T; i++ {
		fmt.Scanf("%d", &n)
		if n <= 1 {
			fmt.Println(-1)
		} else {
			fmt.Println(str[:n])
		}
	}
}

package main

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

func solve(n uint64) string {
	if n == 1 {
		return "-1"
	}

	sum := 0
	r := make([]byte, n)
	for i := range r {
		d := 2
		for d < 9 && (sum+d)%9 == 0 {
			d += 2
		}
		if d > 9 {
			return "-1"
		}
		r[i] = '0' + byte(d)
	}
	r[n-1] = '9'

	return string(r)
}

func main() {
	toInt := func(buf []byte) uint64 {
		var n uint64
		for _, v := range buf {
			n = n*10 + uint64(v-'0')
		}
		return n
	}

	var n uint64

	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := uint64(0); i < n; i++ {
		scanner.Scan()
		input := toInt(scanner.Bytes())
		fmt.Println(solve(input))
	}

}

package main

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

func solve(n uint64) string {
	if n == 1 {
		return "-1"
	}

	r := make([]rune, n)
	for i := range r {
		r[i] = '2'
	}
	r[n-1] = '7'

	return string(r)
}

func main() {
	toInt := func(buf []byte) uint64 {
		var n uint64
		for _, v := range buf {
			n = n*10 + uint64(v-'0')
		}
		return n
	}

	var n uint64

	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := uint64(0); i < n; i++ {
		scanner.Scan()
		input := toInt(scanner.Bytes())
		fmt.Println(solve(input))
	}

}

package main

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

func solve(n uint64) string {
	if n == 1 {
		return "-1"
	}

	r := make([]rune, n)
	for i := range r {
		r[i] = '2'
	}
	r[n-1] = '9'

	return string(r)
}

func main() {
	toInt := func(buf []byte) uint64 {
		var n uint64
		for _, v := range buf {
			n = n*10 + uint64(v-'0')
		}
		return n
	}

	var n uint64

	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := uint64(0); i < n; i++ {
		scanner.Scan()
		input := toInt(scanner.Bytes())
		fmt.Println(solve(input))
	}

}

package main

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

func solve(n uint64) string {
	if n == 1 {
		return "-1"
	}

	r := make([]rune, n)
	for i := range r {
		r[i] = '3'
	}
	r[n-1] = '7'

	return string(r)
}

func main() {
	toInt := func(buf []byte) uint64 {
		var n uint64
		for _, v := range buf {
			n = n*10 + uint64(v-'0')
		}
		return n
	}

	var n uint64

	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := uint64(0); i < n; i++ {
		scanner.Scan()
		input := toInt(scanner.Bytes())
		fmt.Println(solve(input))
	}

}

package main

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

func solve(n uint64) string {
	if n == 1 {
		return "-1"
	}

	sum := 0
	r := make([]byte, n)
	for i := range r {
		d := 2
		for d < 9 && (sum+d)%9 == 0 {
			d *= 2
		}
		if d > 9 {
			return "-1"
		}
		r[i] = '0' + byte(d)
	}
	r[n-1] = '9'

	return string(r)
}

func main() {
	toInt := func(buf []byte) uint64 {
		var n uint64
		for _, v := range buf {
			n = n*10 + uint64(v-'0')
		}
		return n
	}

	var n uint64

	fmt.Scan(&n)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := uint64(0); i < n; i++ {
		scanner.Scan()
		input := toInt(scanner.Bytes())
		fmt.Println(solve(input))
	}

}

package main

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

func main() {
	sc := NewScanner()

	N := sc.NextInt()
	for i := 0; i < N; i++ {
		A := sc.NextInt()

		s := strings.Builder{}
		if (A-1)%3 != 0 {
			for j := 0; j < A-1; j++ {
				s.WriteByte('2')
			}
			s.WriteByte('3')
		} else {
			for j := 0; j < A-2; j++ {
				s.WriteByte('2')
			}
			s.WriteByte('3')
			s.WriteByte('3')
		}
		fmt.Println(s.String())

	}
}

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

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

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 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"
	"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)

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

// 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++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial
}

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

// Simple math functions

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

func min64(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 max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

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

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

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

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

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

func main() {
	defer Flush()

	n := readi()
	k := readi()
	f := make([][]byte, n)
	gr := make([][]int, n)
	gc := make([][]int, n)
	var wrows, wcolumns int

	for i := range f {
		f[i] = readb()
		gr[i] = make([]int, n)
		gc[i] = make([]int, n)
	}

	for i := range f {
		var l, r int
		for l < n && f[i][l] == 'W' {
			l++
		}
		for r = len(f[i]) - 1; 0 <= r && f[i][r] == 'W'; {
			r--
		}
		if r < l {
			wrows++
			continue
		}
		for p, q := 0, k-1; q < n; p, q = p+1, q+1 {
			if p <= l && r <= q {
				gr[i][p] = 1
			}
		}
	}

	for j := range f[0] {
		var u, d int
		for u < n && f[u][j] == 'W' {
			u++
		}
		for d = len(f) - 1; 0 <= d && f[d][j] == 'W'; {
			d--
		}
		if d < u {
			wcolumns++
			continue
		}
		for p, q := 0, k-1; q < n; p, q = p+1, q+1 {
			if p <= u && d <= q {
				gc[p][j] = 1
			}
		}
	}

	sr := make([][]int, n)
	for i := range sr {
		sr[i] = make([]int, n+1)
	}
	for i := range gc {
		for j := range gc[i] {
			sr[i][j+1] = sr[i][j] + gc[i][j]
		}
	}

	sc := make([][]int, n+1)
	for i := range sc {
		sc[i] = make([]int, n)
	}
	for j := range gr[0] {
		for i := range gr {
			sc[i+1][j] = sc[i][j] + gr[i][j]
		}
	}

	sum := func(i, j int) int {
		sumr := sr[i][j+k] - sr[i][j]
		sumc := sc[i+k][j] - sc[i][j]
		return sumr + sumc
	}

	var ans int
	for i := 0; i+k-1 < n; i++ {
		for j := 0; j+k-1 < n; j++ {
			ans = max(ans, wrows+wcolumns+sum(i, j))
		}
	}

	println(ans)
}

package main
import "fmt"
import "os"
import "bufio"

var input *bufio.Reader

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

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

const N = 2005
var arr [N][N]int

func process(x1, x2, y1, y2 int) {
    x1++; y1++; x2++; y2++
    arr[x1][y1]++
    arr[x1][y2+1]--
    arr[x2+1][y1]--
    arr[x2+1][y2+1]++
}

func gao() {
    for i:=1; i<=2000; i++ {
        for j:=1; j<=2000; j++ {
            arr[i][j] += arr[i-1][j] + arr[i][j-1] - arr[i-1][j-1]
        }
    }
}

func main(){
    input = bufio.NewReader(os.Stdin)
    var n, k int
    fmt.Fscanf(input, "%d%d\n", &n, &k)
    var s [N]string

    ans := 0
    for i:=0; i<n; i++ {
        fmt.Fscanf(input, "%s\n", &s[i])
        l := n; r := -1
        for j:=0; j<n; j++ {
            if s[i][j]=='B' {
                l = min(l, j)
                r = max(r, j)
            }
        }
        if l==n {
            ans++
            continue
        }
        if r-l+1>k {
            continue
        }
        process(max(0, i-k+1), i, max(0, r+1-k), l)
    }

    for j:=0; j<n; j++ {
        u := n; d := -1
        for i:=0; i<n; i++ {
            if s[i][j]=='B' {
                u = min(u, i)
                d = max(d, i)
            }
        }
        if u==n {
            ans++
            continue
        }
        if d-u+1>k {
            continue
        }
        process(max(0, d-k+1), u, max(0, j-k+1), j)
    }

    gao()
    mx := 0
    for i:=1; i<=2000; i++ {
        for j:=1; j<=2000; j++ {
            mx=max(mx, arr[i][j])
        }
    }
    fmt.Println(ans+mx)
}


package main

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

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

func slove() {
	var n, m int
	fmt.Fscan(r, &n, &m)
	board := make([]string, n)
	for i := range board {
		fmt.Fscan(r, &board[i])
	}
	first := -1
	for i := range board {
		for j := range board[i] {
			if board[i][j] == 'R' {
				if first > j {
					fmt.Fprintln(w, "No")
					return
				}
				if first == -1 {
					first = j
				}
			}
		}
	}
	fmt.Fprintln(w, "Yes")
}

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

package main

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

func acc(op func(int64, int64) int64, c ...int64) int64 {
	res := c[0]
	for _, i := range c {
		res = op(res, i)
	}
	return res
}

func max(c ...int64) int64 {
	return acc(func(a int64, b int64) int64 {
		if a < b {
			return b
		}
		return a
	}, c...)
}

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

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

func solve(inout io.ReadWriter) {
	scan := func(inp ...interface{}) {
		fmt.Fscan(inout, inp...)
	}
	printf := func(format string, outp ...interface{}) {
		fmt.Fprintf(inout, format, outp...)
	}

	var n, m int
	scan(&n, &m)
	s := make([]string, n)

	r, c := n, m

	for i := 0; i < n; i++ {

		scan(&s[i])
		for j := 0; j < m; j++ {
			if s[i][j] == 'R' {
				if i < r {
					r = i
				}
				if j < c {
					c = j
				}
			}
		}
	}

	if r == n || s[r][c] != 'R' {
		printf("NO\n")
	} else {
		printf("YES\n")
	}

}

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

	var T int = 1
	fmt.Fscan(inout, &T)
	for ; T > 0; T-- {
		solve(inout)
	}
}

package main

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

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

func (in *CF1680B) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1680B) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1680B
Date: 8/8/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1680/B
Problem: CF1680B
**/
func (in *CF1680B) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, m := in.NextInt(), in.NextInt()

		pos := make([][]int, 0)

		for i := 0; i < n; i++ {
			data := in.GetLine()
			for j := 0; j < m; j++ {
				if data[j] == 'R' {
					pos = append(pos, []int{i, j, i + j})
				}
			}
		}

		sort.Slice(pos, func(i, j int) bool {
			if pos[i][2] < pos[i][2] {
				return true
			}
			return false
		})

		ws := true
		for i := 1; i < len(pos); i++ {
			if pos[i][0]-pos[0][0] < 0 || pos[i][1]-pos[0][1] < 0 {
				ws = false
			}
		}

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

	}
}

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

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

package main

import "fmt"

type position struct {
	x, y int
}

func solve() string {
	var n, m int
	fmt.Scanln(&n, &m)

	var leftMost position = position{n, m}
	var upMost position = position{n, m}

	for i := 0; i < n; i++ {
		var row string
		fmt.Scanln(&row)
		for j := 0; j < m; j++ {
			if row[j] == 'R' {
				if j < leftMost.y {
					leftMost.x = i
					leftMost.y = j
				}

				if i < upMost.x {
					upMost.x = i
					upMost.y = j
				}
			}
		}
	}

	if leftMost.y == upMost.y {
		return "YES"
	}

	return "NO"
}

func main() {
	var test int
	fmt.Scanln(&test)

	for test > 0 {
		test--
		fmt.Println(solve())
	}
}

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, m int
		fmt.Fscan(in, &n, &m)

		robs := [][]int{}
		for i := 0; i < n; i++ {
			var s string
			fmt.Fscan(in, &s)

			for j, ch := range s {
				if ch == 'R' {
					robs = append(robs, []int{i, j})
				}
			}
		}

		var f bool
		for i := 0; i < len(robs); i++ {
			ok := true
			for j := 0; j < len(robs); j++ {
				if robs[j][0] < robs[i][0] || robs[j][1] < robs[i][1] {
					ok = false
				}
			}

			if ok {
				f = true
				break
			}
		}

		if f {
			fmt.Fprintln(out, "YES")
		} else {
			fmt.Fprintln(out, "NO")
		}
	}
}

package main

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

const N int = 10

type Pair struct { x, y int }

var (
	n, m int
	g [N]string
	points []Pair
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	Fscan(in, &t)
	for ; t > 0; t-- {
		Fscan(in, &n, &m)
		points = make([]Pair, 0)
		for i := 0; i < n; i++ {
			Fscan(in, &g[i])
		}
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				if g[i][j] == 'R' {
					points = append(points, Pair{i, j})
				}
			}
		}
		sort.Slice(points, func(i, j int) bool {
			return points[i].x + points[i].y < points[j].x + points[j].y
		})
		for {
			c := points[0]
			if c.x == 0 && c.y == 0 {
				Fprintln(out, "YES")
				goto next
			} else if c.x > 0 {
				points[0].x--
				for i := 1; i < len(points); i++ {
					points[i].x--
					if points[i].x < 0 {
						Fprintln(out, "NO")
						goto next
					}
				}
			} else if c.y > 0 {
				points[0].y--
				for i := 1; i < len(points); i++ {
					points[i].y--
					if points[i].y < 0 {
						Fprintln(out, "NO")
						goto next
					}
				}
			}
		}
		next:
	}
}

func min(a, b int) int { if a > b { return b }; return a }
func max(a, b int) int { if a < b { return b }; return a }
func abs(v int) int { if v > 0 { return v }; return -v }
func gcd(a, b int) int { if b > 0 { return gcd(b, a % b) }; return a }
func lcm(a, b int) int { return a * b / gcd(a, b) }

package main

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

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

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

	var T int
	var m int
	var n int
	var s string

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &m)
		Fscan(in, &n)

		g := make([]string, m)
		for i := 0; i < m; i++ {
			Fscan(in, &s)
			g[i] = s
		}

		ma := 1 << 30

	loop:
		for _, v := range g {
			for i, x := range v {
				if x == 'R' {
					ma = i
					break loop
				}
			}
		}

		ans := "YES"

	lp2:
		for j := 0; j < n; j++ {
			for i := 0; i < m; i++ {
				if g[i][j] == 'R' {
					if j < ma {
						ans = "NO"
						break lp2
					}
				}
			}
		}

		Fprintln(out, ans)
	}
}

package main

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

type Int int64

const (
	INF = 3e5 + 10
	L0  = Int(0)
	L1  = Int(1)
)

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

	var T int
	Fscan(in, &T)

	for tt := 0; tt < T; tt++ {
		var n, m Int
		Fscan(in, &n, &m)

		mx := Max(n, m)

		s := make([]string, n)

		ml, mu := mx, mx

		for i := L0; i < n; i++ {
			Fscan(in, &s[i])

			for jj, ch := range s[i] {
				j := Int(jj)
				if ch == 'R' {
					ml = Min(ml, j)
					mu = Min(mu, i)
				}
			}

		}

		flag := false
		for i := L0; i < n && !flag; i++ {
			for jj, ch := range s[i] {
				j := Int(jj)
				if ch == 'R' {
					if i <= mu && j <= ml {
						flag = true
						break
					}

				}
			}
		}

		if flag {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}

	}

}

func MakeGrid(h, w int) [][]Int {
	index := make([][]Int, h)
	data := make([]Int, h*w)
	for i := 0; i < h; i++ {
		index[i] = data[i*w : (i+1)*w]
	}
	return index
}

func Abs(x Int) Int {
	if x > 0 {
		return x
	}
	return -x
}

func Min(nums ...Int) Int {
	return nums[MinIdx(nums...)]
}

func MinIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num < nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

func Max(nums ...Int) Int {
	return nums[MaxIdx(nums...)]
}

func MaxIdx(nums ...Int) Int {
	maxNumIdx := L0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = Int(i)
		}
	}
	return maxNumIdx
}

var (
	mod  Int
	fmod func(Int) Int = doNothing
)

// SetMod sets the mod. It must be called first.
func SetMod(newMod Int) {
	mod = newMod
	fmod = dynamicMod
}

func dynamicMod(m Int) Int {
	m %= mod
	if m < 0 {
		return m + mod
	}
	return m
}

func doNothing(m Int) Int {
	return m
}

// Mod returns m % mod.
func (m Int) Mod() Int {
	return fmod(m)
}

// Inv returns modular multiplicative inverse
func (m Int) Inv() Int {
	return m.Pow(Int(0).Sub(2))
}

// Pow returns m^n
func (m Int) Pow(n Int) Int {
	p := Int(1)
	for n > 0 {
		if n&1 == 1 {
			p.MulAs(m)
		}
		m.MulAs(m)
		n >>= 1
	}
	return p
}

// Add returns m+x
func (m Int) Add(x Int) Int {
	return (m + x).Mod()
}

// Sub returns m-x
func (m Int) Sub(x Int) Int {
	return (m - x).Mod()
}

// Mul returns m*x
func (m Int) Mul(x Int) Int {
	return (m * x).Mod()
}

// Div returns m/x
func (m Int) Div(x Int) Int {
	return m.Mul(x.Inv())
}

// AddAs assigns *m + x to *m and returns m
func (m *Int) AddAs(x Int) *Int {
	*m = m.Add(x)
	return m
}

// SubAs assigns *m - x to *m and returns m
func (m *Int) SubAs(x Int) *Int {
	*m = m.Sub(x)
	return m
}

// MulAs assigns *m * x to *m and returns m
func (m *Int) MulAs(x Int) *Int {
	*m = m.Mul(x)
	return m
}

// DivAs assigns *m / x to *m and returns m
func (m *Int) DivAs(x Int) *Int {
	*m = m.Div(x)
	return m
}

func (m *Int) MaxAs(x ...Int) *Int {
	*m = Max(append(x, *m)...)
	return m
}

func (m *Int) MinAs(x ...Int) *Int {
	*m = Min(append(x, *m)...)
	return m
}

package main

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

func main_edu_128_A() {
	_in, _out := os.Stdin, os.Stdout
	in, out := bufio.NewReader(_in), bufio.NewWriter(_out)
	defer out.Flush()
	var cas int = 1
	Fscan(in, &cas)
	var sol func()
	// Coding...beg!
	sol = func() {
		/* var l1, l2, r1, r2 int
		Fscan(in, &l1, &r1, &l2, &r2)
		if l1 > l2 {
			l1, r1, l2, r2 = l2, r2, l1, r1
		}
		if l1 == l2 {
			Fprintln(out, l1)
			return
		}
		if r1 < l2 {
			Fprintln(out, l1+l2)
			return
		}
		Fprintln(out, l2) */
		var n, m, col int
		col = -1
		Fscan(in, &n, &m)
		a := make([]string, n)
		for i := 0; i < n; i++ {
			Fscan(in, &a[i])
		}
		for i := 0; i < n; i++ {
			for j := 0; j < m; j++ {
				if a[i][j] == 'R' {
					col = j
					break
				}
			}
			if col != -1{
				break
			}
		}
		for i := 0; i < n; i++ {
			for j := 0; j < col; j++ {
				if a[i][j] == 'R' {
				//	Fprintln(out, ":", i, j, col)
					Fprintln(out, "NO")
					return
				}
			}
		}
		Fprintln(out, "YES")
	}
	// Coding...ove!
	for i := 0; i < cas; i++ {
		sol()
	}
}

func main() {
	main_edu_128_A()
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		text, _ := reader.ReadString('\n')
		ninps := strings.Fields(text)
		n, _ := strconv.Atoi(ninps[0])
		m, _ := strconv.Atoi(ninps[1])

		il := -1
		jl := -1

		failed := false
		for i := 0; i < n; i++ {
			s, _ := reader.ReadString('\n')
			if s[len(s)-1] == 10 {
				s = s[:len(s)-1]
			}
			if s[len(s)-1] == 13 {
				s = s[:len(s)-1]
			}

			for j := 0; j < m; j++ {
				if il > -1 && j < jl {
					if string(s[j]) == "R" {
						failed = true
					}
				}
				if string(s[j]) == "R" && il == -1 {
					il = i
					jl = j
				}
			}
		}

		//fmt.Println("M: p1: ", il, jl, " p2:", id, jd)
		if failed == false {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		text, _ := reader.ReadString('\n')
		ninps := strings.Fields(text)
		n, _ := strconv.Atoi(ninps[0])
		m, _ := strconv.Atoi(ninps[1])

		il := -1
		jl := -1
		id := -1
		jd := -1

		for i := 0; i < n; i++ {
			s, _ := reader.ReadString('\n')
			if s[len(s)-1] == 10 {
				s = s[:len(s)-1]
			}
			if s[len(s)-1] == 13 {
				s = s[:len(s)-1]
			}

			for j := 0; j < m; j++ {
				if i > il && il > -1 && j <= jl {
					if string(s[j]) == "R" && id == -1 {
						id = i
						jd = j
					}
				}
				if string(s[j]) == "R" && il == -1 {
					il = i
					jl = j
				}
			}
		}

		//fmt.Println("M: p1: ", il, jl, " p2:", id, jd)
		if il == -1 || id == -1 {
			fmt.Println("YES")
			continue
		}

		if il <= id && jl <= jd {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}

package main

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

func main() {
	var (
		t int
	)

	reader := bufio.NewReader(os.Stdin)
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		t--

		text, _ := reader.ReadString('\n')
		ninps := strings.Fields(text)
		n, _ := strconv.Atoi(ninps[0])
		m, _ := strconv.Atoi(ninps[1])

		il := -1
		jl := -1
		id := -1
		jd := -1

		for i := 0; i < n; i++ {
			s, _ := reader.ReadString('\n')
			if s[len(s)-1] == 10 {
				s = s[:len(s)-1]
			}
			if s[len(s)-1] == 13 {
				s = s[:len(s)-1]
			}

			for j := 0; j < m; j++ {
				if i > il && il > -1 {
					if string(s[j]) == "R" && id == -1 {
						id = i
						jd = j
					}
				}
				if string(s[j]) == "R" && il == -1 {
					il = i
					jl = j
				}
			}
		}

		//fmt.Println("M: p1: ", il, jl, " p2:", id, jd)
		if il == -1 || id == -1 {
			fmt.Println("YES")
			continue
		}

		if il <= id && jl <= jd {
			fmt.Println("YES")
		} else {
			fmt.Println("NO")
		}
	}
}