You and your friends live in $$$n$$$ houses. Each house is located on a 2D plane, in a point with integer coordinates. There might be different houses located in the same point. The mayor of the city is asking you for places for the building of the Eastern exhibition. You have to find the number of places (points with integer coordinates), so that the summary distance from all the houses to the exhibition is minimal. The exhibition can be built in the same point as some house. The distance between two points $$$(x_1, y_1)$$$ and $$$(x_2, y_2)$$$ is $$$|x_1 - x_2| + |y_1 - y_2|$$$, where $$$|x|$$$ is the absolute value of $$$x$$$.

First line contains a single integer $$$t$$$ $$$(1 \leq t \leq 1000)$$$ — the number of test cases. The first line of each test case contains a single integer $$$n$$$ $$$(1 \leq n \leq 1000)$$$. Next $$$n$$$ lines describe the positions of the houses $$$(x_i, y_i)$$$ $$$(0 \leq x_i, y_i \leq 10^9)$$$. It's guaranteed that the sum of all $$$n$$$ does not exceed $$$1000$$$.

For each test case output a single integer - the number of different positions for the exhibition. The exhibition can be built in the same point as some house.

NoteHere are the images for the example test cases. Blue dots stand for the houses, green — possible positions for the exhibition.First test case.Second test case. Third test case. Fourth test case. Fifth test case. Sixth test case. Here both houses are located at $$$(0, 0)$$$.

package main

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

var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

//https://codeforces.com/problemset/problem/1486/B
// median;sorting;hamilton distance

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)
	in.Buffer(make([]byte, 4096), int(1e+9))
	for t := nextNum(); t > 0; t-- {
		solve()
	}
}

func solve() {
	n := nextNum()
	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = nextNum()
		y[i] = nextNum()
	}
	sort.Ints(x)
	sort.Ints(y)
	i, j := (n-1)/2, n/2
	println(int64(x[j]-x[i]+1) * int64(y[j]-y[i]+1))
}

func nextNum() int {
	in.Scan()
	var r, f int
	f = 1
	for _, c := range in.Bytes() {
		if c == '-' {
			f = -1
			continue
		}
		r *= 10
		r += int(c - '0')
	}
	return r * f
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		X, Y := make([]int, n), make([]int, n)
		for i := 0; i < n; i++ {
			X[i], Y[i] = readTwoNums(reader)
		}
		res := solve(n, X, Y)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, X, Y []int) int64 {
	sort.Ints(X)
	sort.Ints(Y)

	var a int64 = 1
	if n&1 == 0 && X[n/2-1] != X[n/2] {
		a = int64(X[n/2]) - int64(X[n/2-1]) + 1
	}
	var b int64 = 1
	if n&1 == 0 && Y[n/2-1] != Y[n/2] {
		b = int64(Y[n/2]-Y[n/2-1]) + 1
	}

	return a * b
}

package main

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

func solveB() {
	var n int64
	scan(&n)
	x := make([]int64, n)
	y := make([]int64, n)
	for i := range x {
		scan(&x[i])
		scan(&y[i])
	}
	sort.Slice(x, func(i, j int) bool { return x[i] < x[j] })
	sort.Slice(y, func(i, j int) bool { return y[i] < y[j] })

	dx := int64(1)
	dy := int64(1)
	if n%2 == 0 {
		dx = x[n/2] - x[n/2-1] + 1
		dy = y[n/2] - y[n/2-1] + 1
	}

	printf("%d\n", dx*dy)
}

func solveA() {
	var n int64
	scan(&n)

	a := make([]int64, n)
	for i := range a {
		scan(&a[i])
	}

	c := int64(0)
	for i := 0; i < len(a)-1; i++ {
		if a[i] < c {
			printf("NO\n")
			return
		}
		dx := a[i] - c
		a[i+1] += dx
		c++
	}

	if a[n-1] >= c {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)

	for t := 0; t < T; t++ {
		solveB()
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)

		x := make([]int, n)
		y := make([]int, n)

		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(in, &x[i])
			_, _ = fmt.Fscan(in, &y[i])
		}

		sort.Ints(x)
		sort.Ints(y)

		if n%2 == 1 {
			fmt.Println(1)
		} else {
			m := n / 2

			yLen := int64(y[m] - y[m-1] + 1)
			xLen := int64(x[m] - x[m-1] + 1)

			ans := yLen * xLen

			fmt.Println(ans)
		}
	}
}

package main

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

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

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

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		x := make([]int, n)
		y := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &x[i], &y[i])
		}
		sort.Ints(x)
		sort.Ints(y)
		if n%2 == 0 {
			fmt.Println((abs(x[n/2-1]-x[n/2]) + 1) * (abs(y[n/2-1]-y[n/2]) + 1))
		} else {
			fmt.Println(1)
		}
	}
}

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

package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"sort"
	"strings"
)

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		var sx, sy int64
		ps := make([]pair, n)
		for i := range ps {
			Fscan(in, &ps[i].x, &ps[i].y)
			sx += ps[i].x
			sy += ps[i].y
		}
		if n&1 == 1 {
			Fprintln(out, 1)
			return
		}
		sort.Slice(ps, func(i, j int) bool { return ps[i].x < ps[j].x })
		d1 := ps[n/2].x - ps[n/2-1].x + 1
		sort.Slice(ps, func(i, j int) bool { return ps[i].y < ps[j].y })
		d2 := ps[n/2].y - ps[n/2-1].y + 1
		Fprintln(out, d1*d2)
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

package main

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

var in *bufio.Reader

func solve() {
	var n int
	fmt.Fscan(in, &n)

	xs := make([]int, n)
	ys := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(in, &xs[i])
		fmt.Fscan(in, &ys[i])
	}

	if n%2 == 1 {
		fmt.Println(1)
		return
	}

	mid := n / 2
	sort.Ints(xs)
	width := int64(xs[mid] - xs[mid-1] + 1)

	sort.Ints(ys)
	height := int64(ys[mid] - ys[mid-1] + 1)

	fmt.Println(width * height)
}

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

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

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

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

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

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

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

func sint64() int64 {
	s := sstring()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func sint64s(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = sint64()
	}
	return a
}

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

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

func sol(n int64, xy [][2]int64) int64 {
	if n&1 == 1 {
		return 1
	}
	x := []int64{}
	y := []int64{}
	for _, e := range xy {
		x = append(x, e[0])
		y = append(y, e[1])
	}
	sort.Slice(x, func(il, ir int) bool {
		return x[il] < x[ir]
	})
	sort.Slice(y, func(il, ir int) bool {
		return y[il] < y[ir]
	})
	xl := x[n/2-1]
	xr := x[n/2]
	yb := y[n/2-1]
	yt := y[n/2]
	return (xr - xl + 1) * (yt - yb + 1)
}

package main

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

var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

//https://codeforces.com/problemset/problem/1486/B
// median;sorting;hamilton distance

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)
	in.Buffer(make([]byte, 4096), int(1e+9))
	for t := nextNum(); t > 0; t-- {
		solve()
	}
}

func solve() {
	n := nextNum()
	x := make([]int, n)
	y := make([]int, n)
	for i := 0; i < n; i++ {
		x[i] = nextNum()
		y[i] = nextNum()
	}
	sort.Ints(x)
	sort.Ints(y)
	i, j := (n-1)/2, n/2
	println((x[j] - x[i] + 1) * (y[j] - y[i] + 1))
}

func nextNum() int {
	in.Scan()
	var r, f int
	f = 1
	for _, c := range in.Bytes() {
		if c == '-' {
			f = -1
			continue
		}
		r *= 10
		r += int(c - '0')
	}
	return r * f
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		n := readNum(reader)
		X, Y := make([]int, n), make([]int, n)
		for i := 0; i < n; i++ {
			X[i], Y[i] = readTwoNums(reader)
		}
		res := solve(n, X, Y)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

func solve(n int, X, Y []int) int {
	sort.Ints(X)
	sort.Ints(Y)

	a := 1
	if n&1 == 0 && X[n/2-1] != X[n/2] {
		a = X[n/2] - X[n/2-1] + 1
	}
	b := 1
	if n&1 == 0 && Y[n/2-1] != Y[n/2] {
		b = Y[n/2] - Y[n/2-1] + 1
	}

	return a * b
}

package main

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

func main() {
	defer writer.Flush()
	//redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)

	for t := 0; t < T; t++ {
		var n int
		scan(&n)
		x := make([]int, n)
		y := make([]int, n)
		for i := range x {
			scan(&x[i])
			scan(&y[i])
		}
		sort.Slice(x, func(i, j int) bool { return x[i] < x[j] })
		sort.Slice(y, func(i, j int) bool { return y[i] < y[j] })

		dx := -1
		dy := -1
		if n%2 == 0 {
			dx = x[n/2] - x[n/2-1] + 1
			dy = y[n/2] - y[n/2-1] + 1
		} else {
			dx = 1
			dy = 1
		}

		printf("%d\n", dx*dy)
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n int
		_, _ = fmt.Fscan(in, &n)

		x := make([]int, n)
		y := make([]int, n)

		for i := 0; i < n; i++ {
			_, _ = fmt.Fscan(in, &x[i])
			_, _ = fmt.Fscan(in, &y[i])
		}

		sort.Ints(x)
		sort.Ints(y)

		if n%2 == 1 {
			fmt.Println(1)
		} else {
			m := n / 2
			ans := (y[m] - y[m-1] + 1) * (x[m] - x[m-1] + 1)
			fmt.Println(ans)
		}
	}
}

package main

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

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

	var t, n int64
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
		fmt.Fscan(in, &n)
		var X, Y int64
		x := make([]int64, n)
		y := make([]int64, n)
		for i := int64(0); i < n; i++ {
			fmt.Fscan(in, &x[i], &y[i])
			X += x[i]
			Y += y[i]
		}
		if n == 1 {
			fmt.Println(1)
			continue
		}
		if n == 2 {
			fmt.Println((abs(x[0]-x[1]) + 1) * (abs(y[0]-y[1]) + 1))
			continue
		}
		result := 1
		if X%n == n/2 {
			result *= 2
		}
		if Y%n == n/2 {
			result *= 2
		}
		fmt.Println(result)
	}
}

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

package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		var sx, sy int64
		ps := make([]pair, n)
		for i := range ps {
			Fscan(in, &ps[i].x, &ps[i].y)
			sx += ps[i].x
			sy += ps[i].y
		}
		f := func(x, y int64) (s int64) {
			for _, p := range ps {
				s += abs(p.x-x) + abs(p.y-y)
			}
			return
		}
		sx /= int64(n)
		sy /= int64(n)
		d, c := int64(1e18), 0
		for i := sx - 1; i < sx+2; i++ {
			for j := sy - 1; j < sy+2; j++ {
				dd := f(i, j)
				if dd < d {
					d, c = dd, 1
				} else if dd == d {
					c++
				}
			}
		}
		Fprintln(out, c)
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}

	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }
func abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}


A very brave explorer Petya once decided to explore Paris catacombs. Since Petya is not really experienced, his exploration is just walking through the catacombs.Catacombs consist of several rooms and bidirectional passages between some pairs of them. Some passages can connect a room to itself and since the passages are built on different depths they do not intersect each other. Every minute Petya arbitrary chooses a passage from the room he is currently in and then reaches the room on the other end of the passage in exactly one minute. When he enters a room at minute i, he makes a note in his logbook with number ti:   If Petya has visited this room before, he writes down the minute he was in this room last time;  Otherwise, Petya writes down an arbitrary non-negative integer strictly less than current minute i. Initially, Petya was in one of the rooms at minute 0, he didn't write down number t0.At some point during his wandering Petya got tired, threw out his logbook and went home. Vasya found his logbook and now he is curious: what is the minimum possible number of rooms in Paris catacombs according to Petya's logbook?

The first line contains a single integer n (1 ≤ n ≤ 2·105) — then number of notes in Petya's logbook. The second line contains n non-negative integers t1, t2, ..., tn (0 ≤ ti < i) — notes in the logbook.

In the only line print a single integer — the minimum possible number of rooms in Paris catacombs.

NoteIn the first sample, sequence of rooms Petya visited could be, for example 1 → 1 → 2, 1 → 2 → 1 or 1 → 2 → 3. The minimum possible number of rooms is 2.In the second sample, the sequence could be 1 → 2 → 3 → 1 → 2 → 1.

package main

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

func solve() {
	n := readInt()
	t := make([]int, n)
	for i := 0; i < n; i++ {
		t[i] = readInt() - 1
	}
	values := make([]int, n)
	for i := 0; i < n; i++ {
		values[i] = -1
	}
	id := 0
	for i := n - 1; i >= 0; i-- {
		if values[i] != -1 {
			continue
		}
		id++
		next := i
		for next >= 0 && values[next] == -1 {
			values[next] = id
			next = t[next]
		}
	}
	fmt.Println(id)
}

var scanner *bufio.Scanner

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

// IO

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

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

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

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

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

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

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

package main

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

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

// 	rooms := 1
// 	a := make([]int, n+1)
// 	a[1] = 0
// 	times := make([]int, n+1)
// 	times[0] = 1
// 	for i := 1; i <= n; i++ {
// 		var record int
// 		fmt.Scanf("%d", &record) // record < i
// 		visitedRoom := times[record]
// 		if (visitedRoom > 0) && (a[visitedRoom] == record) {
// 			a[visitedRoom] = i
// 			times[i] = visitedRoom
// 		} else {
// 			rooms++
// 			a[rooms] = i
// 			times[i] = rooms
// 		}
// 	}

// 	fmt.Println(rooms)
// }

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	rooms := 1
	a := make([]int, n+1)
	a[1] = 0
	times := make([]int, n+1)
	times[0] = 1
	for i := 1; scanner.Scan(); i++ {
		record, _ := strconv.Atoi(scanner.Text())
		visitedRoom := times[record]
		if (visitedRoom > 0) && (a[visitedRoom] == record) {
			a[visitedRoom] = i
			times[i] = visitedRoom
		} else {
			rooms++
			a[rooms] = i
			times[i] = rooms
		}
	}

	fmt.Println(rooms)
}


You are given two strings $$$s$$$ and $$$t$$$ both of length $$$2$$$ and both consisting only of characters 'a', 'b' and 'c'.Possible examples of strings $$$s$$$ and $$$t$$$: "ab", "ca", "bb".You have to find a string $$$res$$$ consisting of $$$3n$$$ characters, $$$n$$$ characters should be 'a', $$$n$$$ characters should be 'b' and $$$n$$$ characters should be 'c' and $$$s$$$ and $$$t$$$ should not occur in $$$res$$$ as substrings.A substring of a string is a contiguous subsequence of that string. So, the strings "ab", "ac" and "cc" are substrings of the string "abacc", but the strings "bc", "aa" and "cb" are not substrings of the string "abacc".If there are multiple answers, you can print any of them.

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of characters 'a', 'b' and 'c' in the resulting string. The second line of the input contains one string $$$s$$$ of length $$$2$$$ consisting of characters 'a', 'b' and 'c'. The third line of the input contains one string $$$t$$$ of length $$$2$$$ consisting of characters 'a', 'b' and 'c'.

If it is impossible to find the suitable string, print "NO" on the first line.  Otherwise print "YES" on the first line and string $$$res$$$ on the second line. $$$res$$$ should consist of $$$3n$$$ characters, $$$n$$$ characters should be 'a', $$$n$$$ characters should be 'b' and $$$n$$$ characters should be 'c' and $$$s$$$ and $$$t$$$ should not occur in $$$res$$$ as substrings. If there are multiple answers, you can print any of them.

package main

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

/* solution */

func solve() {
	ans := solveOne()
	print("YES")
	print(ans)

}

func solveOne() string {

	n := readInt()
	ss, tt := read(), read()
	s, t := [2]byte{ss[0], ss[1]}, [2]byte{tt[0], tt[1]}

	// case 1 (s[0] == s[1] && s == reverse(t))
	if s[0] != s[1] && s[0] == t[1] && s[1] == t[0] {
		one, two := s[0], not(s[0], s[1])
		three := not(one, two)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 2.1 (s[0] == s[1])
	if s[0] == s[1] {
		one, two := t[0], not(t[0], t[1])
		three := not(one, two)
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}

	// case 2.2 (t[0] == t[1])
	if t[0] == t[1] {
		one, two := s[0], not(s[0], s[1])
		three := not(one, two)
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}

	// case 3.1 (s[0] == t[0])
	if s[0] == t[0] {
		two, three := not(s[0], s[0]), s[0]
		one := not(two, three)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 3.2 (s[1] == t[1])
	if s[1] == t[1] {
		one, two := s[1], not(s[1], s[1])
		three := not(one, two)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 4 (s[0] == t[1] || s[1] == t[0])
	if s[0] == t[1] {
		one, two, three := s[1], s[0], t[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}
	if s[1] == t[0] {
		one, two, three := t[1], t[0], s[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}

	return ""

}

func not(a, b byte) byte {
	if a != 'a' && b != 'a' {
		return 'a'
	}
	if a != 'b' && b != 'b' {
		return 'b'
	}
	return 'c'
}

/* stubs */

func main() {

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

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

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanLines)

	solve()

}

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

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

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

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

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

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

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

func getc(a, b byte) byte {
    var c byte = byte(3)-(a-byte(97))-(b-byte(97))+byte(97)
    return c
}

func getans(a, b byte, n int) []byte{
    c := getc(a, b)
    var ans []byte
    for i:=1; i<=n; i++ {
        ans = append(ans, a)
    }
    for i:=1; i<=n; i++ {
        ans = append(ans, b)
    }
    for i:=1; i<=n; i++ {
        ans = append(ans, c)
    }
    return ans
}

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

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

    if t[0]==t[1] {
        s, t = t, s
    }

    var ans []byte
    if s[0]==s[1] {
        if t[0]==t[1] {
            ans = []byte{97, 98, 99}
        } else if s[0]==t[0] {
            ans = []byte{t[0], getc(t[0], t[1]), t[1]}
        } else if s[0]==t[1] {
            ans = []byte{t[1], t[0], getc(t[0], t[1])}
        } else {
            ans = []byte{s[0], t[1], t[0]}
        }
        var tans []byte
        for i:=1; i<=n; i++ {
            tans = append(tans, ans[0], ans[1], ans[2])
        }
        ans = tans
    } else {
        if s[0]==t[0] {
            ans = getans(s[1], getc(s[0], s[1]), n)
        } else if s[1]==t[1] {
            ans = getans(s[1], s[0], n)
        } else {
            ans = getans(s[0], getc(s[0], s[1]), n)
        }
    }

    fmt.Printf("YES\n")
    fmt.Println(string(ans))

}

package main

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

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

	var n int
	var s, t string
	Fscan(bufio.NewReader(in), &n, &s, &t)
	Fprintln(out, "YES")
	if s[0] == s[1] && t[0] == t[1] {
		Fprint(out, strings.Repeat("abc", n))
	} else if s[0] != s[1] && t[0] != t[1] {
		for _, p := range []string{"abc", "acb", "bac", "bca", "cab", "cba"} {
			if p[:2] != s && p[:2] != t && p[1:] != s && p[1:] != t {
				for i := range p {
					Fprint(out, strings.Repeat(p[i:i+1], n))
				}
				break
			}
		}
	} else {
		if t[0] == t[1] {
			s, t = t, s
		}
		if t[0] != s[0] && t[1] != s[0] {
			Fprint(out, strings.Repeat(s[:1]+t[1:]+t[:1], n))
		} else {
			miss := byte('a')
			for ; miss == s[0] || miss == t[0] || miss == t[1]; miss++ {
			}
			b := t[0]
			if b == s[0] {
				b = t[1]
			}
			Fprint(out, strings.Repeat(s[:1]+string(miss), n), strings.Repeat(string(b), n))
		}
	}
}

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

package main

import (
	"fmt"
)

const empty = '!'
const nmax = 4

func sample(n uint32, bl map[rune]map[rune]bool, abc string) (bool, string, uint32) {
	l := int64(3 * n)

	r := make([]rune, l)

	count := map[rune]uint32{
		'a': n,
		'b': n,
		'c': n,
	}

	order := map[rune]int{}

	order[empty] = 0
	for i, ch := range abc {
		order[ch] = i + 1
	}

	getOptions := func(min, prev rune) rune {
		//TODO: add order

		for i, ch := range abc {
			if (min == empty || i > order[min]) && count[ch] > 0 && !bl[prev][ch] {
				return ch
			}
		}

		return empty
	}

	i, c := int64(0), uint32(0)
	for i >= 0 && i < l {
		prev, s := empty, empty

		if i > 0 {
			prev = r[i-1]
		}

		if r[i] > empty {
			s = r[i]
		}

		found := false
		next := getOptions(s, prev)

		found = next != empty //&& (i != l-1 || !bl[next][r[0]])

		if found {
			r[i] = next
			count[next]--
			i++
		} else {
			i--
			if i >= 0 && r[i] > empty {
				count[r[i]]++
				if i < l-1 {
					r[i+1] = empty
				}
			}
			c++
		}

	}

	return i > 0, string(r), c
}

func solve(n uint32, s1, s2 []rune) (bool, string) {
	variants := []string{"abc", "bac", "cab", "cba", "bca", "acb"}
	abc := ""

	var m uint32 = 8
	if n < m {
		m = n
	}

	bl := map[rune]map[rune]bool{}

	for _, ch := range [...]rune{'a', 'b', 'c', empty} {
		bl[ch] = map[rune]bool{}
	}

	bl[s1[0]][s1[1]] = true
	bl[s2[0]][s2[1]] = true

	min := uint32(65536)
	for _, v := range variants {
		f, _, c := sample(m, bl, v)
		if f && c < min {
			min, abc = c, v
		}
	}

	if len(abc) == 0 {
		return false, abc
	}

	f, s, _ := sample(n, bl, abc)

	return f, s
}

func main() {
	var n uint32
	var s1, s2 string

	fmt.Scan(&n)
	fmt.Scan(&s1, &s2)

	f, res := solve(n, ([]rune)(s1), ([]rune)(s2))

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

// Author: sighduck
// URL: https://codeforces.com/contest/1213/problem/E

package main

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

func classifyString(s string) (string, map[string]string) {
	classifiers := "xyzx"
	ptr := 0
	lettersToClassifiers := make(map[string]string)
	classifiersToLetters := make(map[string]string)
	for _, char := range s + "abc" {
		letter := string(char)
		currentClassifier := string(classifiers[ptr])
		_, ok := lettersToClassifiers[letter]
		if !ok {
			lettersToClassifiers[letter] = currentClassifier
			classifiersToLetters[currentClassifier] = letter
			ptr += 1
		}
	}
	classifiedString := []string{}
	for _, char := range s {
		letter := string(char)
		classifiedString = append(classifiedString, lettersToClassifiers[letter])
	}
	return strings.Join(classifiedString, ""), classifiersToLetters
}

func Solve(n int, s string, t string) string {
	if !strings.Contains("abca", s) && !strings.Contains("abca", t) {
		return strings.Repeat("abc", n)
	}
	if !strings.Contains("acba", s) && !strings.Contains("acba", t) {
		return strings.Repeat("acb", n)
	}
	c, m := classifyString(s + t)
	if c == "xyzy" {
		return strings.Repeat(m["y"], n) + strings.Repeat(m["x"], n) + strings.Repeat(m["z"], n)
	} else if c == "xyyx" {
		return strings.Repeat(m["x"], n) + strings.Repeat(m["z"], n) + strings.Repeat(m["y"], n)
	} else if c == "xyxz" {
		return strings.Repeat(m["y"], n) + strings.Repeat(m["z"], n) + strings.Repeat(m["x"], n)
	}
	return ""
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	var s, t string
	fmt.Fscanf(reader, "%s\n%s\n", &s, &t)

	fmt.Fprintf(writer, "YES\n")
	fmt.Fprintf(writer, "%s\n", Solve(n, s, t))
}

package main

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

/* solution */

func solve() {
	ans := solveOne()
	print("YES")
	print(ans)

}

func solveOne() string {

	n := readInt()
	ss, tt := read(), read()
	s, t := [2]byte{ss[0], ss[1]}, [2]byte{tt[0], tt[1]}

	// case 1 (s[0] == s[1] && s == reverse(t))
	if s[0] != s[1] && s[0] == t[1] && s[1] == t[0] {
		one, two := s[0], not(s[0], s[1])
		three := not(one, two)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 2.1 (s[0] == s[1])
	if s[0] == s[1] {
		if t[0] < t[1] {
			return strings.Repeat("cba", n)
		}
		return strings.Repeat("abc", n)
	}

	// case 2.2 (t[0] == t[1])
	if t[0] == t[1] {
		if s[0] < s[1] {
			return strings.Repeat("cba", n)
		}
		return strings.Repeat("abc", n)
	}

	// case 3 (s[0] == t[0])
	if s[0] == t[0] {
		one, two := s[0], not(s[1], t[1])
		var three byte
		if one == two {
			three = one
			one = not(three, three)
			two = not(one, three)
			return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
		}
		three = not(one, two)
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}

	// case 4 (s[0] == t[1] || s[1] == t[0])
	if s[0] == t[1] {
		one, two, three := s[1], s[0], t[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}
	if s[1] == t[0] {
		one, two, three := t[1], t[0], s[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}

	return ""

}

func not(a, b byte) byte {
	if a != 'a' && b != 'a' {
		return 'a'
	}
	if a != 'b' && b != 'b' {
		return 'b'
	}
	return 'c'
}

/* stubs */

func main() {

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

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

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanLines)

	solve()

}

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

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

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

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

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

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

/* solution */

func solve() {
	ans := solveOne()
	print("YES")
	print(ans)

}

func solveOne() string {

	n := readInt()
	ss, tt := read(), read()
	s, t := [2]byte{ss[0], ss[1]}, [2]byte{tt[0], tt[1]}

	// case 1 (s[0] == s[1] && s == reverse(t))
	if s[0] != s[1] && s[0] == t[1] && s[1] == t[0] {
		one, two := s[0], not(s[0], s[1])
		three := not(one, two)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 2.1 (s[0] == s[1])
	if s[0] == s[1] {
		if (2+t[0]-t[1])%2 == 1 {
			return strings.Repeat("cba", n)
		}
		return strings.Repeat("abc", n)
	}

	// case 2.2 (t[0] == t[1])
	if t[0] == t[1] {
		if (2+s[0]-s[1])%2 == 1 {
			return strings.Repeat("cba", n)
		}
		return strings.Repeat("abc", n)
	}

	// case 3.1 (s[0] == t[0])
	if s[0] == t[0] {
		two, three := not(s[0], s[0]), s[0]
		one := not(two, three)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 3.2 (s[1] == t[1])
	if s[1] == t[1] {
		one, two := s[1], not(s[1], s[1])
		three := not(one, two)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 4 (s[0] == t[1] || s[1] == t[0])
	if s[0] == t[1] {
		one, two, three := s[1], s[0], t[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}
	if s[1] == t[0] {
		one, two, three := t[1], t[0], s[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}

	return ""

}

func not(a, b byte) byte {
	if a != 'a' && b != 'a' {
		return 'a'
	}
	if a != 'b' && b != 'b' {
		return 'b'
	}
	return 'c'
}

/* stubs */

func main() {

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

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

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanLines)

	solve()

}

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

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

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

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

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

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

/* solution */

func solve() {
	ans := solveOne()
	print("YES")
	print(ans)

}

func solveOne() string {

	n := readInt()
	ss, tt := read(), read()
	s, t := [2]byte{ss[0], ss[1]}, [2]byte{tt[0], tt[1]}

	// case 1 (s[0] == s[1] && s == reverse(t))
	if s[0] != s[1] && s[0] == t[1] && s[1] == t[0] {
		one, two := s[0], not(s[0], s[1])
		three := not(one, two)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 2.1 (s[0] == s[1])
	if s[0] == s[1] {
		if t[0] < t[1] {
			return strings.Repeat("cba", n)
		}
		return strings.Repeat("abc", n)
	}

	// case 2.2 (t[0] == t[1])
	if t[0] == t[1] {
		if s[0] < s[1] {
			return strings.Repeat("cba", n)
		}
		return strings.Repeat("abc", n)
	}

	// case 3.1 (s[0] == t[0])
	if s[0] == t[0] {
		two, three := not(s[0], s[0]), s[0]
		one := not(two, three)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 3.2 (s[1] == t[1])
	if s[1] == t[1] {
		one, two := s[1], not(s[1], s[1])
		three := not(one, two)
		return strings.Repeat(string(one), n) + strings.Repeat(string(two), n) + strings.Repeat(string(three), n)
	}

	// case 4 (s[0] == t[1] || s[1] == t[0])
	if s[0] == t[1] {
		one, two, three := s[1], s[0], t[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}
	if s[1] == t[0] {
		one, two, three := t[1], t[0], s[0]
		return strings.Repeat(bytes.NewBuffer([]byte{one, two, three}).String(), n)
	}

	return ""

}

func not(a, b byte) byte {
	if a != 'a' && b != 'a' {
		return 'a'
	}
	if a != 'b' && b != 'b' {
		return 'b'
	}
	return 'c'
}

/* stubs */

func main() {

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

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

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanLines)

	solve()

}

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

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

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

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

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

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	s := io.Next()
	t := io.Next()

	var check func(string) bool
	check = func(S string) bool {
		for i := 0; i < 3*n-1; i++ {
			if S[i:i+2] == t || S[i:i+2] == s {
				return false
			}
		}
		return true
	}

	var perm = []string{"abc", "acb", "bac", "bca", "cab", "cba"}

	for _, v := range perm {
		var T string
		for i := 0; i < n; i++ {
			T += v
		}
		if check(T) {
			io.Println("YES")
			io.Println(T)
			break
		}
	}
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

package main

import (
	"fmt"
	"strings"
)

const empty = '!'

func solve(n uint32, s1, s2 []rune) (bool, string) {
	const ABC = "abc"

	m := uint32(2)
	if n < m {
		m = n
	}
	l := int64(3 * m)

	count := map[rune]uint32{
		'a': m,
		'b': m,
		'c': m,
	}

	r := make([]rune, l)
	bl := map[rune]map[rune]bool{}

	for _, ch := range [...]rune{'a', 'b', 'c', empty} {
		bl[ch] = map[rune]bool{}
	}

	bl[s1[0]][s1[1]] = true
	bl[s2[0]][s2[1]] = true

	getOptions := func(min, prev rune) rune {
		//TODO: add order

		for _, ch := range ABC {
			if ch >= min && count[ch] > 0 && !bl[prev][ch] {
				return ch
			}
		}

		return empty
	}

	i := int64(0)
	for i >= 0 && i < l {
		prev, s := empty, empty

		if i > 0 {
			prev = r[i-1]
		}

		if r[i] > empty {
			s = r[i] + 1
		}

		found := false
		next := getOptions(s, prev)

		found = next != empty

		if found {
			count[next]--
			r[i] = next
			i++
		} else {
			i--
			if r[i] > empty {
				count[r[i]]++
				if i < l-1 {
					r[i+1] = empty
				}
			}
		}

		//fmt.Println(i, string(r), count)
	}

	if i == 0 {
		return false, ""
	}

	res := string(r)
	if n > m {
		res = strings.Repeat(res, int(n>>1))

		if n%2 > 0 {
			r = []rune{empty, empty, empty}

			count['a'] = 1
			count['b'] = 1
			count['c'] = 1

			for i := 0; i < 3 && i >= 0; {
				prev, s := rune(res[len(res)-1]), empty

				if i > 0 {
					prev = r[i-1]
				}

				if r[i] > empty {
					s = r[i] + 1
				}

				found := false
				next := getOptions(s, prev)

				found = next != empty

				if found {
					count[next]--
					r[i] = next
					i++
				} else {
					i--
					if r[i] > empty {
						count[r[i]]++
						if i < len(r)-1 {
							r[i+1] = empty
						}
					}
				}
			}

			res += string(r)
		}
	}

	return true, res
}

func main() {
	var n uint32
	var s1, s2 string

	fmt.Scan(&n)
	fmt.Scan(&s1, &s2)

	f, res := solve(n, ([]rune)(s1), ([]rune)(s2))

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

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

func getc(a, b byte) byte {
    var c byte = byte(3)-(a-byte(97))-(b-byte(97))+byte(97)
    return c
}

func getans(a, b byte, n int) []byte{
    c := getc(a, b)
    var ans []byte
    for i:=1; i<=n; i++ {
        ans = append(ans, a)
    }
    for i:=1; i<=n; i++ {
        ans = append(ans, b)
    }
    for i:=1; i<=n; i++ {
        ans = append(ans, c)
    }
    return ans
}

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

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

    if t[0]==t[1] {
        s, t = t, s
    }

    var ans []byte
    if s[0]==s[1] {
        if t[0]==t[1] {
            ans = []byte{97, 98, 99}
        } else if s[0]==t[0] {
            ans = []byte{t[0], getc(t[0], t[1]), t[1]}
        } else if s[0]==t[1] {
            ans = []byte{t[1], t[0], getc(t[0], t[1])}
        } else {
            ans = []byte{s[0], t[1], t[0]}
        }
        var tans []byte
        for i:=1; i<=n; i++ {
            tans = append(tans, ans[0], ans[1], ans[2])
        }
        ans = tans
    } else {
        if s[0]==t[0] {
            ans = getans(s[1], getc(s[0], s[1]), n)
        } else if s[1]==t[1] {
            ans = getans(s[0], getc(s[0], s[1]), n)
        } else {
            ans = getans(s[0], getc(s[0], s[1]), n)
        }
    }

    fmt.Printf("YES\n")
    fmt.Println(string(ans))

}


On an $$$8 \times 8$$$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the cells through which it passes.Determine which color was used last.  The red stripe was painted after the blue one, so the answer is R.

The first line of the input contains a single integer $$$t$$$ ($$$1 \leq t \leq 4000$$$) — the number of test cases. The description of test cases follows. There is an empty line before each test case. Each test case consists of $$$8$$$ lines, each containing $$$8$$$ characters. Each of these characters is either 'R', 'B', or '.', denoting a red square, a blue square, and an unpainted square, respectively. It is guaranteed that the given field is obtained from a colorless one by drawing horizontal red rows and vertical blue columns. At least one stripe is painted.

For each test case, output 'R' if a red stripe was painted last, and 'B' if a blue stripe was painted last (without quotes).

NoteThe first test case is pictured in the statement.In the second test case, the first blue column is painted first, then the first and last red rows, and finally the last blue column. Since a blue stripe is painted last, the answer is B.

package main

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

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

func (in *CF1742C) 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 *CF1742C) load() {
  if len(in.split) <= in.index {
    in.split = strings.Split(in.GetLine(), in.separator)
    in.index = 0
  }
}

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

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

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

/**
Run solve the problem CF1742C
Date: 10/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1742/C
Problem: CF1742C
**/
func (in *CF1742C) Run() {
  for t := in.NextInt(); t > 0; t-- {
    m := make([]string, 8)
    in.GetLine()
    for i := 0; i < 8; i++ {
      m[i] = in.NextString()
    }

    ans := uint8(0)
    for i := 0; i < 8; i++ {
      r := 0
      b := 0

      for j := 0; j < 8; j++ {
        if m[i][j] == 'R' {
          r++
        }
      }
      if r == 8 {
        ans = 'R'
        break
      }

      for j := 0; j < 8; j++ {
        if m[j][i] == 'B' {
          b++
        }
      }

      if b == 8 {
        ans = 'B'
        break
      }

    }

    fmt.Println(string(rune(ans)))
  }
}

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

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

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++ {
		aa := make([]string, 8)
		for i := 0; i < 8; i++ {
			fmt.Fscan(in, &aa[i])
		}

		d := 'B'
		for i := range aa {
			var r int
			for j := 0; j < 8; j++ {
				if aa[i][j] == 'R' {
					r++
				}
			}
			if r == 8 {
				d = 'R'
			}
		}
		fmt.Fprintln(out, string(d))
	}
}

package main

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

var in *bufio.Reader = bufio.NewReader(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func ans() {
	var n int = 8
	var grid []string = make([]string, n)
	for i := 0; i < n; i++ {
		Fscan(in, &grid[i])
	}
	for row := 0; row < n; row++ {
		var cntR int = 0
		for col := 0; col < n; col++ {
			if grid[row][col] == 'R' {
				cntR++
			}
		}
		if cntR == n {
			Fprintln(out, "R")
			return
		}
	}
	for col := 0; col < n; col++ {
		var cntB int = 0
		for row := 0; row < n; row++ {
			if grid[row][col] == 'B' {
				cntB++
			}
		}
		if cntB == n {
			Fprintln(out, "B")
			return
		}
	}
}

func main() {
	defer out.Flush()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans()
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve() {
	f := false
	var n int
	fmt.Fscan(in, &n)
	for i := 0; i < 8; i++ {
		var a string
		fmt.Fscanln(in, &a)
		if "RRRRRRRR" == a {
			f = true
		}
	}

	if f {
		fmt.Fprintln(out, "R")
		return
	}

	fmt.Fprintln(out, "B")
}

func main() {
	var T int
	fmt.Fscan(in, &T)
	for ; T > 0; T-- {
		solve()
	}
	out.Flush()
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve() {
	f := false
	var n int
	s := "RB"
	fmt.Fscan(in, &n)
	for i := 0; i < 8; i++ {
		var a string
		fmt.Fscanln(in, &a)
		f_t := true
		for j := 0; j < 8; j++ {
			if a[j] != s[0] {
				f_t = false
			}
		}

		if f_t {
			f = true
		}
	}

	if f {
		fmt.Fprintln(out, "R")
		return
	}

	fmt.Fprintln(out, "B")
}

func main() {
	var T int
	fmt.Fscan(in, &T)
	for ; T > 0; T-- {
		solve()
	}
	out.Flush()
}

package main

import "fmt"

func main() {
	var t int

	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		board := make([]string, 8)
		for j := 0; j < 8; j++ {
			fmt.Scan(&board[j])
		}
		for j := 0; j < 8; j++ {
			flag := true
			for k := 0; k < 8; k++ {
				if board[j][k] != 'R' {
					flag = false
					break
				}
			}
			if flag {
				fmt.Println("R")
				break
			}
		}
		for j := 0; j < 8; j++ {
			flag := true
			for k := 0; k < 8; k++ {
				if board[k][j] != 'B' {
					flag = false
					break
				}
			}
			if flag {
				fmt.Println("B")
				break
			}
		}
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

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

func main() {
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
    var red = "B"
    for i := 0; i < 8; i ++{
      var s string
      fmt.Fscan(in, &s)
      if s == "RRRRRRRR" {
        red = "R"
      }
    }
    fmt.Println(red)
	}
}

package main

import (
	"fmt"
)

func main() {
	var num int
	fmt.Scan(&num)
	for i := 0; i < num; i++ {

		// var numArr []int

		var arr [8]string
		for i := 0; i < len(arr); i++ {

			var str string
			fmt.Scan(&str)
			arr[i] = str
		}
		var res string
		res = thri(arr)
		fmt.Println(res)
		// var res string
		// res = sec(numArr)
	}

}
func thri(arr [8]string) string {
	count := 0
	for i := 0; i < len(arr); i++ {
		for j := 0; j < len(arr[i]); j++ {
			if arr[i][j] == 82 {
				count++
			}
		}
		if count != 8 {
			count = 0
		} else {
			return "R"
		}
	}
	if count != 8 {
		return "B"
	} else {
		return "R"
	}
}

package main

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

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

func readInt() int {
	var i int
	fmt.Fscan(reader, &i)
	return i
}

func readString() string {
	var s string
	fmt.Fscan(reader, &s)
	return s
}

func main(){
	defer writer.Flush()
	T := readInt()
	for i := 1; i <= T; i++{
		board := make([]string, 8)
		ans := "B"
		for r := 0; r < 8; r++ {
			board[r] = readString()
		}
		for r := 0; r < 8; r++ {
			allEq := true
			for c := 0; c < 8; c++ {
				if board[r][c] != board[r][0] {
					allEq = false
					break
				}
			}
			if allEq && board[r][0] == 'R'{
				ans = string(board[r][0])
			}
		}
		for c := 0; c < 8; c++ {
			allEq := true
			for r := 0; r < 8; r++ {
				if board[r][c] != board[0][c] {
					allEq = false
					break
				}
			}
			if allEq && board[0][c] == 'B'{
				ans = string(board[0][c])
			}
		}
		fmt.Fprintln(writer, ans)
	}
}

package main

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

const mod = 998244353
const mx = int64(1e9 + 7)

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	arr := make([]string, 8)
	for i := 0; i < 8; i++ {
		Fscan(in, &arr[i])
	}
	var check func(i, j int) bool
	check = func(i, j int) bool {
		v := arr[i][j]
		col := true
		row := true
		for d := 0; d < 8; d++ {
			if arr[i][d] != v {
				col = false
			}
			if arr[d][j] != v {
				row = false
			}
		}
		if v == 'R' {
			return col
		} else {
			return row
		}
	}
	check(3, 4)
	for i := 0; i < 8; i++ {
		for j := 0; j < 8; j++ {
			if arr[i][j] != '.' {
				if check(i, j) {
					Fprintln(out, string(arr[i][j]))
					return
				}
			}
		}
	}
}

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

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

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

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

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

func match(arr [8][8]byte) byte {
	for i := 0; i < 8; i++ {
		var row []byte
		for j := 0; j < 8; j++ {
			row = append(row, arr[i][j])
		}

		if string(row) == "RRRRRRRR" {
			return 'R'
		}
	}

	return 'B'
}

func main() {
	writer.Flush()
	var test int
	fmt.Fscanf(reader, "%d\n", &test)
	for test > 0 {
		var arr [8][8]byte
		fmt.Fscanf(reader, "\n")
		for i := 0; i < 8; i++ {
			for j := 0; j < 8; j++ {
				fmt.Fscanf(reader, "%c", &arr[i][j])
			}
			fmt.Fscanf(reader, "\n")
		}
		fmt.Printf("%c\n", match(arr))
		test--
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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
}

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

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	t := io.ReadInt()
	for i := 0; i < t; i++ {
		io.ReadString()

		done := false
		for j := 0; j < 8; j++ {
			row := io.ReadString()
			if done {
				continue
			}

			oneSizeSet := true
			for _, c := range row {
				if c != 'R' {
					oneSizeSet = false
				}
			}

			if oneSizeSet {
				fmt.Println("R")
				done = true
			}
		}

		if !done {
			fmt.Println("B")
		}
	}
}

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var s string
	fmt.Scanln(&s)
	count, _ := strconv.Atoi(s)
	answers := make([]string, 0, count)
	for i := 0; i < count ; i++ {
		scanner.Scan()
		var arr [8][8]string
		for row := 0; row < 8; row++ {
			scanner.Scan()
			line := strings.Split(scanner.Text(), "")
			for column := 0; column < 8; column++ {
				arr[row][column] = line[column]
			}
		}
		if checkArrayByRow(arr) {
			answers = append(answers, "R")
		}
		if checkArrayByColumn(arr) {
			answers = append(answers, "B")
		}
	}
	for _, answer := range answers {
		fmt.Println(answer)
	}
}

func checkArrayByRow(arr [8][8]string) bool {
	outer:
	for row := 0; row < 8; row++ {
		for column := 0; column < 8; column++ {
			if arr[row][column] != "R" {
				continue outer
			}
		}
		return true
	}
	return false
}

func checkArrayByColumn(arr [8][8]string) bool {
	outer:
	for row := 0; row < 8; row++ {
		for column := 0; column < 8; column++ {
			if arr[column][row] != "B" {
				continue outer
			}
		}
		return true
	}
	return false
}

package main

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

func check_row(g []string, i int, c rune) bool {
	r := true
	for _, v := range g[i] {
		if rune(v) != c {
			r = false
			break
		}
	}
	return r
}

func check_column(g []string, i int, c rune) bool {
	r := true
	for j := range g[i] {
		v := g[j][i]
		if rune(v) != c {
			r = false
			break
		}
	}
	return r
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		g := make([]string, 8)
		for i:= range g {
			fmt.Fscan(r, &g[i])
		}

		var res rune
		for i := range g {
			if check_row(g, i, 'R') {
				res = 'R'
				break
			}
			if check_column(g, i, 'B') {
				res = 'B'
				break
			}
		}

		fmt.Fprintln(w, string(res))

	}

}

package main

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

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

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

	var T int
	var s string

loop:
	for Fscan(in, &T); T > 0; T-- {
		g := [8]string{}
		for i := 0; i < 8; i++ {
			Fscan(in, &s)
			g[i] = s
		}

		for i := 0; i < 8; i++ {
			if g[i] == "RRRRRRRR" {
				Fprintln(out, "R")
				continue loop
			}
		}

	lp:
		for j := 0; j < 8; j++ {
			for i := 0; i < 8; i++ {
				if g[i][j] != 'B' {
					continue lp
				}
			}
			Fprintln(out, "B")
			continue loop
		}

		Fprintln(out, "")
	}
}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		a := make([]string, 8)
		for i := range a {
			Fscan(in, &a[i])
		}
		for _, s := range a {
			if  s == strings.Repeat("R", 8) {
				Fprintln(out, "R")
				return
			}
		}
		Fprintln(out, "B")
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	// 如果是多组数据，请务必加上这段保险 —— 已经无法统计，有多少位竞赛选手在漏读数据上损失大把分数（包括我）
	// 此外，如果不小心写成了 scan(v) 而不是 scan(&v)，由于未传入指针，不会读入任何数据，这样本地运行一次就能立马发现错误
	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

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

package main

import "fmt"

func main() {
	var t int
	var s string
	fmt.Scan(&t)
	for t > 0 {
		t--
		fmt.Scanf("\n")
		var r bool
		for i := 0; i < 8; i++ {
			fmt.Scan(&s)
			// fmt.Println(s)
			if s == "RRRRRRRR" {
				r = true
			}
		}
		if r {
			fmt.Println("R")
		} else {
			fmt.Println("B")
		}
	}
}

package main

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

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

func solve() {
	m := [8]string{}

	for i := 0; i < 8; i++ {
		var s string
		Fscan(r, &s)
		m[i] = s
	}

	for row := 0; row < 8; row++ {
		if m[row][0] == 'R' && m[row] == "RRRRRRRR" {
			Fprintln(w, "R")
			return
		}
	}
	Fprintln(w, "B")
}

func main() {
	// inputFile, _ := os.OpenFile("input.txt", os.O_RDONLY, os.ModePerm)

	defer w.Flush()

	var t int
	Fscan(r, &t)

	for i := 0; i < t; i++ {
		solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var T int
	fmt.Scan(&T)
	for Case := 1; Case <= T; Case++ {
		var G = [8]string{}
		for i := 0; i < 8; i++ {
			fmt.Scan(&G[i])
		}
		ans := -1
		for i := 0; i < 8; i++ {
			ok := true
			for j := 0; j < 8; j++ {
				if G[i][j] != 'R' {
					ok = false
				}
			}
			if ok {
				ans = 0
			}
		}
		for j := 0; j < 8; j++ {
			ok := true
			for i := 0; i < 8; i++ {
				if G[i][j] != 'B' {
					ok = false
				}
			}
			if ok {
				ans = 1
			}
		}
		if ans == 0 {
			fmt.Println("R")
		} else {
			fmt.Println("B")
		}
	}
}

package main

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

var (
	reader = bufio.NewReader(os.Stdin)
	t      int
)

func solve(b []string) string {
	for _, x := range b {
		if x == "RRRRRRRR" {
			return "R"
		}
	}
	return "B"
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		b := make([]string, 8)
		for i := 0; i < 8; i++ {
			fmt.Fscan(reader, &b[i])
		}
		fmt.Println(solve(b))
	}
}

package main

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

const cf = true

func solve() {
	var str string
	ans := "B"
	for i := 0; i < 8; i++ {
		fmt.Fscan(in, &str)
		if !strings.Contains(str, "B") && !strings.Contains(str, ".") {
			ans = "R"
		}
	}
	fmt.Fprintln(out, ans)
}

func main() {
	defer out.Flush()
	t := 1
	fmt.Fscan(in, &t)
	for ; t > 0; t-- {
		solve()
	}
}

type SqrtInt interface {
	SignedSqrt | UnsignedSqrt
}

type SignedSqrt interface {
	~int | ~int32 | ~int64
}

type UnsignedSqrt interface {
	~uint | ~uint32 | ~uint64 | ~uintptr
}

func sqrt[T SqrtInt](x T) T {
	l, r := T(0), T(2000000123)
	for l < r {
		mid := (l + r) / 2
		if mid*mid > x {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l - 1
}

func ConvertInt(val string, base, toBase int) (string, error) {
	i, err := strconv.ParseInt(val, base, 64)
	if err != nil {
		return "", err
	}
	return strconv.FormatInt(i, toBase), nil
}

type set[T Ordered] struct {
	itms map[T]struct{}
}

func (s *set[T]) init() {
	if s.itms == nil {
		s.itms = make(map[T]struct{})
	}
}

func (s *set[T]) add(item T) *set[T] {
	s.init()
	s.itms[item] = exists
	return s
}

func (s *set[T]) remove(item T) *set[T] {
	s.init()
	delete(s.itms, item)
	return s
}

func (s *set[T]) has(item T) bool {
	s.init()
	_, c := s.itms[item]
	return c
}

func (s *set[T]) sortedItems() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	sort.Slice(items, func(i, j int) bool {
		return items[i] < items[j]
	})
	return items
}

func (s *set[T]) items() []T {
	s.init()
	items := make([]T, 0, s.size())
	for item := range s.itms {
		items = append(items, item)
	}
	return items
}

func (s *set[T]) size() int {
	s.init()
	return len(s.itms)
}

var exists = struct{}{}

const MaxUint = ^uint(0)
const MinUint = 0
const MaxInt = int(MaxUint >> 1)
const MinInt = -MaxInt - 1

func reverseStr(s string) string {
	r := []byte(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

type Ordered interface {
	Integer | Float | ~string
}

func abs[T Signed](x T) T {
	if x < 0 {
		return -x
	}
	return x
}

func min[T Ordered](x, y T) T {
	if x < y {
		return x
	}
	return y
}

func max[T Ordered](x, y T) T {
	if x > y {
		return x
	}
	return y
}

var (
	in  = getReader()
	out = getWriter()
)

func getReader() *bufio.Reader {
	if cf {
		return bufio.NewReader(os.Stdin)
	} else {
		in, _ := os.Open("input.txt")
		return bufio.NewReader(in)
	}
}

func getWriter() *bufio.Writer {
	if cf {
		return bufio.NewWriter(os.Stdout)
	} else {
		out, _ := os.Create("output.txt")
		return bufio.NewWriter(out)
	}
}

package main

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

var sc = bufio.NewScanner(os.Stdin)

const mod = 998244353
const N = 2e5

func main() {
	sc.Buffer(make([]byte, 500000*1+1), 500000)
	sc.Split(bufio.ScanWords)

	T := nextInt()
	for T > 0 {
		T--
		a := make([]string, 8)
		flag := -1
		for i := 0; i < 8; i++ {
			a[i] = nextString()
			t := true
			for j := 0; j < 8; j++ {
				if a[i][j] != 'R' {
					t = false
				}
			}
			if t {
				flag = 0
			}
		}
		if flag == 0 {
			fmt.Println("R")
		} else {
			fmt.Println("B")
		}
	}
}

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

package main

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

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

func (in *CF1742C) 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 *CF1742C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1742C
Date: 10/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1742/C
Problem: CF1742C
**/
func (in *CF1742C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := make([]string, 8)
		in.GetLine()
		for i := 0; i < 8; i++ {
			m[i] = in.NextString()
		}

		ans := uint8(0)
		for i := 0; i < 8; i++ {
			r := 0
			b := 0

			for j := 0; j < 8; j++ {
				if m[i][j] == 'R' {
					r++
				} else if m[i][j] == 'B' {
					b++
				}
			}
			if r == 8 {
				ans = 'R'
				break
			}

			if b == 8 {
				ans = 'B'
				break
			}

			b, r = 0, 0
			for j := 0; j < 8; j++ {
				if m[j][i] == 'R' {
					r++
				} else if m[j][i] == 'B' {
					b++
				}
			}

			if r == 8 {
				ans = 'R'
				break
			}

			if b == 8 {
				ans = 'B'
				break
			}

		}

		fmt.Println(string(rune(ans)))
	}
}

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

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

package main

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

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

func (in *CF1742C) 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 *CF1742C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1742C
Date: 10/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1742/C
Problem: CF1742C
**/
func (in *CF1742C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := make([]string, 8)
		in.GetLine()
		for i := 0; i < 8; i++ {
			m[i] = in.NextString()
		}

		ans := uint8(0)
		for i := 0; i < 8; i++ {
			aux := uint8(0)
			ok := true
			for j := 0; j < len(m[i]); j++ {
				if m[i][j] == '.' {
					ok = false
					break
				}
				if j == 0 {
					aux = m[i][j]
				} else {
					if aux == m[i][j] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}

			ok = true
			aux = uint8(0)
			for j := 0; j < len(m[i]); j++ {
				if m[j][i] == '.' {
					ok = false
					break
				}
				if j == 0 {
					aux = m[j][i]
				} else {
					if aux == m[j][i] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}
		}

		fmt.Println(string(rune(ans)))
	}
}

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

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

package main

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

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

func (in *CF1742C) 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 *CF1742C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1742C
Date: 10/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1742/C
Problem: CF1742C
**/
func (in *CF1742C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := make([]string, 8)
		in.GetLine()
		for i := 0; i < 8; i++ {
			m[i] = in.NextString()
		}

		ans := uint8(0)
		for i := 0; i < 8; i++ {
			aux := uint8(0)
			ok := true
			for j := 0; j < len(m[i]); j++ {
				fmt.Println("m>", m[i][j])
				if m[i][j] == '.' {
					ok = false
					break
				}
				if j == 0 {
					aux = m[i][j]
				} else {
					if aux == m[i][j] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}

			ok = true
			aux = uint8(0)
			for j := 0; j < len(m[i]); j++ {
				if m[j][i] == '.' {
					ok = false
					break
				}
				if j == 0 {
					aux = m[j][i]
				} else {
					if aux == m[j][i] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}
		}

		fmt.Println(string(rune(ans)))
	}
}

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

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

package main

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

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

func (in *CF1742C) 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 *CF1742C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1742C
Date: 10/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1742/C
Problem: CF1742C
**/
func (in *CF1742C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := make([]string, 8)
		in.GetLine()
		for i := 0; i < 8; i++ {
			m[i] = in.NextString()
		}

		ans := uint8(0)
		for i := 0; i < 8; i++ {
			aux := uint8(0)
			ok := true
			for j := 0; j < len(m[i]); j++ {
				if m[i][j] == '.' {
					break
				}
				if j == 0 {
					aux = m[i][j]
				} else {
					if aux == m[i][j] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}

            ok = true
			aux = uint8(0)
			for j := 0; j < len(m[i]); j++ {
				if m[j][i] == '.' {
					break
				}
				if j == 0 {
					aux = m[j][i]
				} else {
					if aux == m[j][i] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}
		}

		fmt.Println(string(rune(ans)))
	}
}

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

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

package main

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

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

func (in *CF1742C) 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 *CF1742C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1742C
Date: 10/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1742/C
Problem: CF1742C
**/
func (in *CF1742C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := make([]string, 8)
		in.GetLine()
		for i := 0; i < 8; i++ {
			m[i] = in.NextString()
		}

		ans := uint8(0)
		for i := 0; i < 8; i++ {
			aux := uint8(0)
			ok := true
			for j := 0; j < len(m[i]); j++ {
				if m[i][j] == '.' {
					break
				}
				if j == 0 {
					aux = m[i][j]
				} else {
					if aux == m[i][j] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}

			aux = uint8(0)
			for j := 0; j < len(m[i]); j++ {
				if m[j][i] == '.' {
					break
				}
				if j == 0 {
					aux = m[j][i]
				} else {
					if aux == m[j][i] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}
		}

		fmt.Println(string(rune(ans)))
	}
}

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

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

package main

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

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

func (in *CF1742C) 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 *CF1742C) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1742C
Date: 10/21/2022
User: wotan
URL: https://codeforces.com/problemset/problem/1742/C
Problem: CF1742C
**/
func (in *CF1742C) Run() {
	for t := in.NextInt(); t > 0; t-- {
		m := make([]string, 8)
		in.GetLine()
		for i := 0; i < 8; i++ {
			m[i] = in.NextString()
		}

		ans := uint8(0)
		for i := 0; i < 8; i++ {
			aux := uint8(0)
			ok := true
			for j := 0; j < len(m[i]); j++ {
				if j == 0 {
					aux = m[i][j]
				} else {
					if aux == m[i][j] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}

			aux = uint8(0)
			for j := 0; j < len(m[i]); j++ {
				if j == 0 {
					aux = m[j][i]
				} else {
					if aux == m[j][i] {
						ans = aux
						continue
					} else {
						ok = false
						ans = uint8(0)
						break
					}
				}
			}
			if ok {
				break
			}
		}

		fmt.Println(string(rune(ans)))
	}
}

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

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

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++ {
		aa := make([]string, 8)
		for i := 0; i < 8; i++ {
			fmt.Fscan(in, &aa[i])
		}

		var d rune
		var f bool
		for i := range aa {
			r, b := 0, 0
			for j := 0; j < 8; j++ {
				if aa[i][j] == 'R' {
					r++
				} else if aa[i][j] == 'B' {
					b++
				}
			}
			if r == 8 {
				d = 'R'
				f = true
			} else if b == '8' {
				d = 'B'
				f = true
			}
		}

		if !f {
			for i := range aa {
				r, b := 0, 0
				for j := 0; j < 8; j++ {
					if aa[j][i] == 'R' {
						r++
					} else if aa[j][i] == 'B' {
						b++
					}
				}
				if r == 8 {
					d = 'R'
				} else if b == 8 {
					d = 'B'
				}
			}
		}
		fmt.Fprintln(out, string(d))
	}
}

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++ {
		aa := make([]string, 8)
		for i := 0; i < 8; i++ {
			fmt.Fscan(in, &aa[i])
		}

		var d byte
		for i := range aa {
			r, b := 0, 0
			for j := 0; j < 8; j++ {
				if aa[i][j] == 'R' {
					r++
				} else if aa[i][j] == 'B' {
					b++
				}
			}
			if r == 8 {
				d = 'R'
			} else if b == '8' {
				d = 'B'
			}
		}

		for i := range aa {
			r, b := 0, 0
			for j := 0; j < 8; j++ {
				if aa[j][i] == 'R' {
					r++
				} else if aa[j][i] == 'B' {
					b++
				}
			}
			if r == 8 {
				d = 'R'
			} else if b == 8 {
				d = 'B'
			}
		}
		fmt.Fprintln(out, string(d))
	}
}

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++ {
		aa := make([]string, 8)
		for i := 0; i < 8; i++ {
			fmt.Fscan(in, &aa[i])
		}

		var d byte
		for i := range aa {
			if aa[i][0] == '.' {
				continue
			}

			f := true
			for j := 1; j < 8; j++ {
				if aa[i][j] != aa[i][j-1] {
					f = false
					break
				}
			}
			if f {
				d = aa[i][7]
			}
		}

		for i := range aa {
			if aa[0][i] == '.' {
				continue
			}

			f := true
			for j := 1; j < 8; j++ {
				if aa[j][i] != aa[j-1][i] {
					f = false
					break
				}
			}
			if f {
				d = aa[7][i]
			}
		}
		fmt.Fprintln(out, string(d))
	}
}

package main

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

var in *bufio.Reader = bufio.NewReader(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func ans(cur int) {
	var n int = 8
	var grid []string = make([]string, n)
	for i := 0; i < n; i++ {
		Fscan(in, &grid[i])
	}
	if cur == 9 {
		for i := 0; i < n; i++ {
			Fprintln(out, grid[i])
		}
	}
	for row := 0; row < n; row++ {
		var cntR int = 0
		var cntB int = 0
		for col := 0; col < n; col++ {
			if grid[row][col] == 'R' {
				cntR++
			} else if grid[row][col] == 'B' {
				cntB++
			}
		}
		if cntR == n {
			Fprintln(out, "R")
			return
		}
		if cntB == n {
			Fprintln(out, "B")
			return
		}
	}
	for col := 0; col < n; col++ {
		var cntR int = 0
		var cntB int = 0
		for row := 0; row < n; row++ {
			if grid[row][col] == 'R' {
				cntR++
			} else if grid[row][col] == 'B' {
				cntB++
			}
		}
		if cntR == n {
			Fprintln(out, "R")
			return
		}
		if cntB == n {
			Fprintln(out, "B")
			return
		}
	}
}

func main() {
	defer out.Flush()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans(i)
	}
}

package main

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

var in *bufio.Reader = bufio.NewReader(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func ans() {
	var n int = 8
	var grid []string = make([]string, n)
	for i := 0; i < n; i++ {
		Fscan(in, &grid[i])
	}
	for row := 0; row < n; row++ {
		var cntR int = 0
		var cntB int = 0
		for col := 0; col < n; col++ {
			if grid[row][col] == 'R' {
				cntR++
			} else if grid[row][col] == 'B' {
				cntB++
			}
		}
		if cntR == n {
			Fprintln(out, "R")
			return
		}
		if cntB == n {
			Fprintln(out, "B")
			return
		}
	}
	for col := 0; col < n; col++ {
		var cntR int = 0
		var cntB int = 0
		for row := 0; row < n; row++ {
			if grid[row][col] == 'R' {
				cntR++
			} else if grid[row][col] == 'B' {
				cntB++
			}
		}
		if cntR == n {
			Fprintln(out, "R")
			return
		}
		if cntB == n {
			Fprintln(out, "B")
			return
		}
	}
}

func main() {
	defer out.Flush()
	var t int
	Fscan(in, &t)
	for i := 0; i < t; i++ {
		ans()
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func solve() {
	var n int
	fmt.Fscan(in, &n)
	hashMap := make(map[byte]int)
	for i := 0; i < 8; i++ {
		var a string
		fmt.Fscanln(in, &a)
		for j := 0; j < 8; j++ {
			hashMap[a[j]]++
		}
	}

	s := "RB"
	if hashMap[s[0]] > hashMap[s[1]] {
		fmt.Fprintln(out, "R")
		return
	}

	fmt.Fprintln(out, "B")
}

func main() {
	var T int
	fmt.Fscan(in, &T)
	for ; T > 0; T-- {
		solve()
	}
	out.Flush()
}

package main

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

var in = bufio.NewReader(os.Stdin)

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

func main() {
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
    a := make([]string, 8,8)
    var skip = false
    for i := 0; i < 8; i ++{
      var s string
      fmt.Fscan(in, &s)
      if s == "RRRRRRRR" {
        fmt.Println("R")
        skip = true
      } else if s == "BBBBBBBB" {
        fmt.Println("B")
        skip = true
      }
      a[i] = s
    }
    if skip {
      continue
    }
    for i := 0; i<8;i++ {
      s := fmt.Sprintf("%c%c%c%c%c%c%c%c",a[0][i],a[1][i],a[2][i],a[3][i],a[4][i],a[5][i],a[6][i],a[7][i])
      if s == "RRRRRRRR" {
        fmt.Println("R")
        break
      } else if s == "BBBBBBBB" {
        fmt.Println("B")
        break
      }
    }
	}
}

package main

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

var in = bufio.NewReader(os.Stdin)

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

func main() {
	var t int
	fmt.Fscan(in, &t)

	for ; t > 0; t-- {
    a := make([]int, 256,256)
    for i := 0; i < 8; i ++{
      var s string
      fmt.Fscan(in, &s)
      for _, c := range s {
        a[int(c)]++
      }
    }
    if a[int('R')] > a[int('B')] {
      fmt.Println("R")
    } else {
      fmt.Println("B")
    }
	}
}

package main

import (
	"fmt"
)

func main() {
	var num int
	fmt.Scan(&num)
	for i := 0; i < num; i++ {

		// var numArr []int

		var arr [8]string
		for i := 0; i < len(arr); i++ {

			var str string
			fmt.Scan(&str)
			arr[i] = str
		}
		var res string
		res = thri(arr)
		fmt.Println(res)
		// var res string
		// res = sec(numArr)
	}

}
func thri(arr [8]string) string {
	count := 0
	for i := 0; i < len(arr); i++ {
		for j := 0; j < len(arr[i]); j++ {
			if arr[i][j] == 82 {
				count++
			}
		}
		if count != 8 {
			count = 0
		}
	}
	if count != 8 {
		return "B"
	} else {
		return "R"
	}
}

package main

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

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

func readInt() int {
	var i int
	fmt.Fscan(reader, &i)
	return i
}

func readString() string {
	var s string
	fmt.Fscan(reader, &s)
	return s
}

func main(){
	defer writer.Flush()
	T := readInt()
	for i := 1; i <= T; i++{
		board := make([]string, 8)
		ans := "B"
		for r := 0; r < 8; r++ {
			board[r] = readString()
		}
		for r := 0; r < 8; r++ {
			allEq := true
			for c := 0; c < 8; c++ {
				if board[r][c] != board[r][0] {
					allEq = false
					break
				}
			}
			if allEq && board[r][0] != '.'{
				ans = string(board[r][0])
			}
		}
		for c := 0; c < 8; c++ {
			allEq := true
			for r := 0; r < 8; r++ {
				if board[r][c] != board[0][c] {
					allEq = false
					break
				}
			}
			if allEq && board[0][c] != '.'{
				ans = string(board[0][c])
			}
		}
		fmt.Fprintln(writer, ans)
	}
}

package main

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

const mod = 998244353
const mx = int64(1e9 + 7)

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	arr := make([]string, 8)
	for i := 0; i < 8; i++ {
		Fscan(in, &arr[i])
	}
	var check func(i, j int) bool
	check = func(i, j int) bool {
		v := arr[i][j]
		col := true
		row := true
		for d := 0; d < 8; d++ {
			if arr[i][d] != v {
				col = false
			}
			if arr[d][j] != v {
				row = false
			}
		}
		return col || row
	}
	check(3, 4)
	for i := 0; i < 8; i++ {
		for j := 0; j < 8; j++ {
			if arr[i][j] != '.' {
				if check(i, j) {
					Fprintln(out, string(arr[i][j]))
					return
				}
			}
		}
	}
}

func max(i, j int) int {
	if i > j {
		return i
	}
	return j
}

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

func main() {
	stdin := os.Stdin
	stdout := os.Stdout
	in := bufio.NewReader(stdin)
	out := bufio.NewWriter(stdout)
	n := 1
	Fscan(in, &n)
	for i := 0; i < n; i++ {
		solve(in, out)
	}
}

package main

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

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

func match(arr [8][8]byte) byte {
	for i := 0; i < 8; i++ {
		var row []byte
		var col []byte
		for j := 0; j < 8; j++ {
			row = append(row, arr[i][j])
			col = append(col, arr[j][i])
		}

		if string(row) == "BBBBBBBB" || string(col) == "BBBBBBBB" {
			return 'B'
		}

		if string(row) == "RRRRRRRR" || string(col) == "RRRRRRRR" {
			return 'R'
		}
	}

	return ' '
}

func main() {
	writer.Flush()
	var test int
	fmt.Fscanf(reader, "%d\n", &test)
	for test > 0 {
		var arr [8][8]byte
		fmt.Fscanf(reader, "\n")
		for i := 0; i < 8; i++ {
			for j := 0; j < 8; j++ {
				fmt.Fscanf(reader, "%c", &arr[i][j])
			}
			fmt.Fscanf(reader, "\n")
		}
		fmt.Printf("%c\n", match(arr))
		test--
	}
}

package main

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

type IO struct {
	in  io.Reader
	out io.Writer
}

func NewIO(in io.Reader, out io.Writer) *IO {
	return &IO{in: bufio.NewReader(in), out: out}
}

func (io *IO) ReadInt() int {
	var res int
	_, _ = fmt.Fscanf(io.in, "%d\n", &res)
	return res
}

func (io *IO) ReadPairInt() (int, int) {
	var a, b int
	_, _ = fmt.Fscanf(io.in, "%d %d\n", &a, &b)
	return a, b
}

func (io *IO) ReadString() string {
	var res string
	_, _ = fmt.Fscanf(io.in, "%s\n", &res)
	return res
}

func (io *IO) ReadIntSlice(n int) sort.IntSlice {
	var t int
	res := make(sort.IntSlice, 0, n)
	for i := 0; i < n; i++ {
		_, _ = fmt.Fscanf(io.in, "%d", &t)
		res = append(res, t)
	}
	_, _ = fmt.Fscanf(io.in, "\n")
	return res
}

func (io *IO) Println(v ...interface{}) {
	_, _ = fmt.Fprintln(io.out, v...)
}

func (io *IO) Print(v ...interface{}) {
	_, _ = fmt.Fprint(io.out, v...)
}

func (io *IO) Printf(format string, v ...interface{}) {
	_, _ = fmt.Fprintf(io.out, format, v...)
}

func (io *IO) PrintIntSlice(s sort.IntSlice) {
	for _, v := range s {
		io.Printf("%d ", v)
	}
}

func (io *IO) PrintlnIntSlice(s sort.IntSlice) {
	io.PrintIntSlice(s)
	io.Printf("\n")
}

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
}

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

func main() {
	io := NewIO(os.Stdin, os.Stdout)

	t := io.ReadInt()
	for i := 0; i < t; i++ {
		io.ReadString()

		done := false
		for j := 0; j < 8; j++ {
			row := io.ReadString()
			if done {
				continue
			}

			oneSizeSet := true
			for _, c := range row {
				if c != int32(row[0]) || c == '.' {
					oneSizeSet = false
				}
			}

			if oneSizeSet {
				fmt.Println("R")
				done = true
			}
		}

		if !done {
			fmt.Println("B")
		}
	}
}

package main

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

func check_row(g []string, i int, c rune) bool {
	r := true
	for _, v := range g[i] {
		if rune(v) != c {
			r = false
			break
		}
	}
	return r
}

func check_column(g []string, i int, c rune) bool {
	r := true
	for j := range g[i] {
		v := g[j][i]
		if rune(v) != c {
			r = false
			break
		}
	}
	return r
}

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

	var T int
	for fmt.Fscan(r, &T); T > 0; T-- {

		g := make([]string, 8)
		for i:= range g {
			fmt.Fscan(r, &g[i])
		}

		var res rune
		for i := range g {
			o := []rune{'R', 'B'}
			for _, col := range o {
				if check_row(g, i, col) || check_column(g, i, col) {
					res = col
					break
				}
			}
		}

		fmt.Fprintln(w, string(res))

	}

}

package main

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

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

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

	var T int
	var s string

loop:
	for Fscan(in, &T); T > 0; T-- {
		g := [8]string{}
		for i := 0; i < 8; i++ {
			Fscan(in, &s)
			g[i] = s
		}

	l1:
		for i := 0; i < 8; i++ {
			if g[i][0] == '.' {
				continue
			}
			for j := 1; j < 8; j++ {
				if g[i][j] != g[i][0] {
					continue l1
				}
			}
			Fprintln(out, string(g[i][0]))
			continue loop
		}

	l2:
		for j := 0; j < 8; j++ {
			if g[0][j] == '.' {
				continue
			}
			for i := 1; i < 8; i++ {
				if g[i][j] != g[0][j] {
					continue l2
				}
			}
			Fprintln(out, string(g[0][j]))
			continue loop
		}

		Fprintln(out, "")
	}
}

package main

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

// https://space.bilibili.com/206214
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(curCase int) {
		a := make([]string, 8)
		ok := false
		for i := range a {
			Fscan(in, &a[i])
			if ok {
				continue
			}
			if a[i][0] == '.' {
				continue
			}
			if strings.Count(a[i], a[i][:1]) == 8 {
				Fprintln(out, a[i][:1])
				ok = true
			}
		}
		if ok {
			return
		}
		for j := 0; j < 8; j++ {
			if a[0][j] == '.' {
				continue
			}
			c := 0
			for i := 0; i < 8; i++ {
				if a[i][j] == a[0][j] {
					c++
				}
			}
			if c == 8 {
				Fprintln(out, string(a[0][j]))
				return
			}
		}
	}

	cases := 1
	Fscan(in, &cases)
	for curCase := 1; curCase <= cases; curCase++ {
		solve(curCase)
	}

	// 如果是多组数据，请务必加上这段保险 —— 已经无法统计，有多少位竞赛选手在漏读数据上损失大把分数（包括我）
	// 此外，如果不小心写成了 scan(v) 而不是 scan(&v)，由于未传入指针，不会读入任何数据，这样本地运行一次就能立马发现错误
	leftData, _ := ioutil.ReadAll(in)
	if s := strings.TrimSpace(string(leftData)); s != "" {
		panic("有未读入的数据：\n" + s)
	}

}

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