package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(input, &s, &s)
	var rooms [10]int
	for _, ch := range s {
		switch {
		case 'L' == ch:
			i := 0
			for ; rooms[i] == 1; i++ {
			}
			rooms[i] = 1
		case 'R' == ch:
			i := 9
			for ; rooms[i] == 1; i-- {
			}
			rooms[i] = 1
		default:
			rooms[ch-'0'] = 0
		}
	}
	for _, el := range rooms {
		fmt.Print(el)
	}
}

// Author: sighduck
// URL: https://codeforces.com/contest/1200/problem/A

package main

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

const NoAvailableRoom = -1

type AvailableRoom struct {
	Left  int
	Right int
}

func getNextLeftRoom(rooms []string, available AvailableRoom) AvailableRoom {
	for i := available.Left + 1; i <= available.Right; i++ {
		if rooms[i] == "0" {
			return AvailableRoom{Left: i, Right: available.Right}
		}
	}
	return AvailableRoom{Left: NoAvailableRoom, Right: NoAvailableRoom}
}

func getNextRightRoom(rooms []string, available AvailableRoom) AvailableRoom {
	for i := available.Right - 1; i >= available.Left; i-- {
		if rooms[i] == "0" {
			return AvailableRoom{Left: available.Left, Right: i}
		}
	}
	return AvailableRoom{Left: NoAvailableRoom, Right: NoAvailableRoom}
}

func Solve(n int, s string) string {
	available := AvailableRoom{Left: 0, Right: 9}
	rooms := make([]string, 10)
	for i := 0; i < 10; i++ {
		rooms[i] = "0"
	}
	for i := 0; i < n; i++ {
		op := string(s[i])
		if op == "L" {
			rooms[available.Left] = "1"
			available = getNextLeftRoom(rooms, available)
		} else if op == "R" {
			rooms[available.Right] = "1"
			available = getNextRightRoom(rooms, available)
		} else {
			room, _ := strconv.Atoi(op)
			rooms[room] = "0"
			if room < available.Left {
				available.Left = room
			}
			if room > available.Right {
				available.Right = room
			}
			if available.Left == NoAvailableRoom || available.Right == NoAvailableRoom {
				available.Left = room
				available.Right = room
			}
		}
	}
	return strings.Join(rooms, "")
}

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

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n%s\n", &n, &s)
	fmt.Fprintf(writer, "%s\n", Solve(n, s))
}

package main
import "fmt"

func main() {
	ar := [10]int{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	for i := 0; i < n; i++ {
		if s[i:i+1] == "L" {
			for j := 0; j < 10; j++ {
				if ar[j] == 0 {
					ar[j] = 1
					break
				}
			}
		} else if s[i:i+1] == "R" {
			for j := 9; j >= 0; j-- {
				if ar[j] == 0 {
					ar[j] = 1
					break
				}
			}
		} else {
			var k int
			k = int(s[i])
			ar[k-48] = 0 // 0 in ASCII is 48! :)
		}
	}
	for i:=0; i<10; i++ {
	    fmt.Printf("%d",ar[i])
	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var (
		total  int
		orders string
	)
	rooms := make([]bool, 10)

	_, _ = fmt.Fscan(input, &total)
	_, _ = fmt.Fscan(input, &orders)

	for _, c := range orders {
		if c == 'L' {
			for i := 0; i < 10; i += 1 {
				if !rooms[i] {
					rooms[i] = true
					break
				}
			}
		} else if c == 'R' {
			for i := 9; i > -1; i -= 1 {
				if !rooms[i] {
					rooms[i] = true
					break
				}
			}
		} else {
			leave, _ := strconv.Atoi(string(c))
			rooms[leave] = false
		}
	}

	ans := ""
	for _, r := range rooms {
		if r {
			ans += "1"
		} else {
			ans += "0"
		}
	}

	fmt.Println(ans)

}

package main

import "fmt"

func main() {
	var n int
	fmt.Scanln(&n)
	var line string
	fmt.Scanln(&line)

	rooms := make([]rune, 10)
	for i := 0; i < 10; i++ {
		rooms[i] = '0'
	}

	actions := []rune(line)
	for _, action := range actions {
		if action == 'L' {
			for i := 0; i < 10; i++ {
				if rooms[i] == '0' {
					rooms[i] = '1'
					break
				}
			}
		} else if action == 'R' {
			for i := 9; i >= 0; i-- {
				if rooms[i] == '0' {
					rooms[i] = '1'
					break
				}
			}
		} else {
			rooms[action-48] = '0'
		}
	}

	result := string(rooms)
	fmt.Println(result)
}

package main

import "fmt"

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

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

func main(){
	var t int
	fmt.Scanln(&t)
	var target[10] int
	for i := 0;i < t ;i++  {
		var c rune
		var j int
		fmt.Scanf("%c", &c)
		switch c {
		case 'L':
			for j=0;j <10 && target[j]==1 ;j++  {}
			target[j] = 1
		case 'R':
			for j=9;j >=0 && target[j]==1 ;j--  {}
			target[j] = 1
		default:
			target[c - '0'] = 0
		}
	}
	for i:=0;i<10 ;i++  {
		fmt.Print(target[i])
	}
}

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

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

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

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

    arr := make([]int, 10)

    for i:=0; i<n; i++ {
        if s[i]=='L' {
            for j:=0; j<10; j++ {
                if arr[j]==0 {
                    arr[j]=1
                    break
                }
            }
        } else if s[i]=='R' {
            for j:=9; j>=0; j-- {
                if arr[j]==0 {
                    arr[j]=1
                    break
                }
            }
        } else {
            arr[s[i]-'0'] = 0
        }
    }
    for i:=0; i<10; i++ {
        fmt.Printf("%d", arr[i])
    }
    fmt.Println();
}

// cf1200a
package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var s string
	fmt.Fscan(in, &n, &s)

	var r int

	for _, e := range s {
		switch e {
		case 'L':
			var i uint = 9
			for r&(1<<i) != 0 {
				i--
			}
			r |= 1 << i
		case 'R':
			var i uint
			for r&(1<<i) != 0 {
				i++
			}
			r |= 1 << i
		default:
			r ^= 1 << uint(9-(e-'0'))
		}

	}
	fmt.Fprintf(out, "%010b\n", r)
}

// Author: sighduck
// URL: https://codeforces.com/contest/1200/problem/A

package main

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

const NoAvailableRoom = -1

type AvailableRoom struct {
	Left  int
	Right int
}

func getNextLeftRoom(rooms []string, available AvailableRoom) AvailableRoom {
	var start int
	if available.Left == NoAvailableRoom {
		start = 0
	} else {
		start = available.Left + 1
	}
	for i := start; i <= 9; i++ {
		if rooms[i] == "0" {
			return AvailableRoom{Left: i, Right: available.Right}
		}
	}
	return AvailableRoom{Left: NoAvailableRoom, Right: NoAvailableRoom}
}

func getNextRightRoom(rooms []string, available AvailableRoom) AvailableRoom {
	var start int
	if available.Right == NoAvailableRoom {
		start = 9
	} else {
		start = available.Right - 1
	}
	for i := start; i >= 0; i-- {
		if rooms[i] == "0" {
			return AvailableRoom{Left: available.Left, Right: i}
		}
	}
	return AvailableRoom{Left: NoAvailableRoom, Right: NoAvailableRoom}
}

func Solve(n int, s string) string {
	available := AvailableRoom{Left: 0, Right: 9}
	rooms := make([]string, 10)
	for i := 0; i < 10; i++ {
		rooms[i] = "0"
	}
	for i := 0; i < n; i++ {
		op := string(s[i])
		if op == "L" {
			rooms[available.Left] = "1"
			available = getNextLeftRoom(rooms, available)
		} else if op == "R" {
			rooms[available.Right] = "1"
			available = getNextRightRoom(rooms, available)
		} else {
			room, _ := strconv.Atoi(op)
			rooms[room] = "0"
			if room < available.Left {
				available.Left = room
			}
			if room > available.Right {
				available.Right = room
			}
			if available.Left == NoAvailableRoom || available.Right == NoAvailableRoom {
				available.Left = room
				available.Right = room
			}
		}
	}
	return strings.Join(rooms, "")
}

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

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n%s\n", &n, &s)
	fmt.Fprintf(writer, "%s\n", Solve(n, s))
}

package main

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

/* solution */

func solve() {
	n := readInt()
	s := read()
	rooms := make([]int, 10)
	for i := 0; i < n; i++ {
		if s[i] == 'L' {
			for j := 0; j <= 9; j++ {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else if s[i] == 'R' {
			for j := 9; j >= 0; j-- {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else {
			rooms[s[i]-'0'] = 0
		}
	}
	ans := ""
	for i := 0; i <= 9; i++ {
		ans += string(rooms[i] + '0')
	}
	print(ans)
}

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

package main

import (
	"fmt"
	"strconv"
)

func main() {
	var q int
	var st string

	// scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&q)

	a := make([]int, 10)

	fmt.Scanln(&st)

	for _, y := range st {
		if string(y) == "L" {
			for i := 0; i < 10; i++ {
				if a[i] == 0 {
					a[i] = 1
					break
				}
			}
		} else if string(y) == "R" {
			for i := 9; i >= 0; i-- {
				if a[i] == 0 {
					a[i] = 1
					break
				}
			}
		} else {
			z, _ := strconv.Atoi(string(y))
			a[z] = 0
		}
	}
	ans := ""
	for i := 0; i < 10; i++ {
		y := strconv.Itoa(a[i])
		ans += y
	}
	fmt.Println(ans)

}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var n int
	var s string
	fmt.Fscan(input, &n, &s)
	var rooms [10]int
	for _, ch := range s {
		switch {
		case 'L' == ch:
			i := 0
			for ; rooms[i] == 1; i++ {
			}
			rooms[i] = 1
		case 'R' == ch:
			i := 9
			for ; rooms[i] == 1; i-- {
			}
			rooms[i] = 1
		case '0' <= ch && ch <= '9':
			rooms[ch-'0'] = 0
		}
	}
	for _, el := range rooms {
		fmt.Print(el)
	}

}

package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	var rooms [10]int
	for _, ch := range s {
		switch {
		case 'L' == ch:
			i := 0
			for ; rooms[i] == 1; i++ {
			}
			rooms[i] = 1
		case 'R' == ch:
			i := 9
			for ; rooms[i] == 1; i-- {
			}
			rooms[i] = 1
		case '0' <= ch && ch <= '9':
			rooms[ch-'0'] = 0
		}
	}
	for _, el := range rooms {
		fmt.Print(el)
	}

}

// Author: sighduck
// URL: https://codeforces.com/contest/1200/problem/A

package main

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

func Solve(n int, s string) string {
	left := 0
	right := 9
	rooms := make([]string, 10)
	for i := 0; i < 10; i++ {
		rooms[i] = "0"
	}
	for i := 0; i < n; i++ {
		op := string(s[i])
		if op == "L" {
			rooms[left] = "1"
			left += 1
		} else if op == "R" {
			rooms[right] = "1"
			right -= 1
		} else {
			room, _ := strconv.Atoi(op)
			rooms[room] = "0"
			if room < left || left > 9 {
				left = room
			}
			if room > right || right < 0 {
				right = room
			}
		}
	}
	return strings.Join(rooms, "")
}

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

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n%s\n", &n, &s)
	fmt.Fprintf(writer, "%s\n", Solve(n, s))
}

// Author: sighduck
// URL: https://codeforces.com/contest/1200/problem/A
// Re-attempt later ...

package main

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

const NoAvailableRoom = -1

func getNextLeftRoom(rooms []string, left int) int {
	for i := left + 1; i <= 9; i++ {
		if rooms[i] == "0" {
			return i
		}
	}
	return NoAvailableRoom
}

func getNextRightRoom(rooms []string, right int) int {
	for i := right - 1; i >= 0; i-- {
		if rooms[i] == "0" {
			return i
		}
	}
	return NoAvailableRoom
}

func Solve(n int, s string) string {
	left := 0
	right := 9
	rooms := make([]string, 10)
	for i := 0; i < 10; i++ {
		rooms[i] = "0"
	}
	for i := 0; i < n; i++ {
		op := string(s[i])
		if op == "L" {
			rooms[left] = "1"
			left = getNextLeftRoom(rooms, left)
		} else if op == "R" {
			rooms[right] = "1"
			right = getNextRightRoom(rooms, right)
		} else {
			room, _ := strconv.Atoi(op)
			rooms[room] = "0"
			if room < left || left == NoAvailableRoom {
				left = room
			}
			if room > right || right == NoAvailableRoom {
				right = room
			}
		}
	}
	return strings.Join(rooms, "")
}

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

	var n int
	var s string
	fmt.Fscanf(reader, "%d\n%s\n", &n, &s)
	fmt.Fprintf(writer, "%s\n", Solve(n, s))
}

package main

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

/* solution */

func solve() {
	n := readInt()
	s := read()
	rooms := make([]int, 10)
	for i := 0; i < n; i++ {
		if s[i] == 'L' {
			for j := 0; j < 9; j++ {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else if s[i] == 'R' {
			for j := 9; j >= 0; j-- {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else {
			rooms[s[i]-'0'] = 0
		}
	}
	ans := ""
	for i := 0; i < 10; i++ {
		ans += string(rooms[i] + '0')
	}
	print(ans)
}

/* 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.ScanWords)

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

package main

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

/* solution */

func solve() {
	read()
	s := read()
	rooms := make([]int, 10)
	for i := 0; i < len(s); i++ {
		if s[i] == 'L' {
			for j := 0; j < 9; j++ {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else if s[i] == 'R' {
			for j := 9; j >= 0; j-- {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else {
			rooms[s[i]-'0'] = 0
		}
	}
	ans := ""
	for i := 0; i < 10; i++ {
		ans += string(rooms[i] + '0')
	}
	print(ans)
}

/* 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.ScanWords)

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

package main

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

/* solution */

func solve() {
	n := readInt()
	s := read()
	rooms := make([]int, 10)
	for i := 0; i < n; i++ {
		if s[i] == 'L' {
			for j := 0; j < 9; j++ {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else if s[i] == 'R' {
			for j := 9; j >= 0; j-- {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else {
			rooms[s[i]-'0'] = 0
		}
	}
	ans := ""
	for i := 0; i < 10; i++ {
		ans += string(rooms[i] + '0')
	}
	print(ans)
}

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

package main

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

/* solution */

func solve() {
	read()
	s := read()
	rooms := make([]int, 10)
	for i := 0; i < len(s); i++ {
		if s[i] == 'L' {
			for j := 0; j < 9; j++ {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else if s[i] == 'R' {
			for j := 9; j >= 0; j-- {
				if rooms[j] == 0 {
					rooms[j] = 1
					break
				}
			}
		} else {
			rooms[s[i]-'0'] = 0
		}
	}
	ans := ""
	for i := 0; i < 10; i++ {
		ans += string(rooms[i] + '0')
	}
	print(ans)
}

/* 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)
	reader.Split(bufio.ScanWords)

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

package main

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

func main() {
	var q int
	var st string

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	a := make([]int, 10)

	fmt.Scanln(&st)

	for _, y := range st {
		if string(y) == "L" {
			for i := 0; i < 10; i++ {
				if a[i] == 0 {
					a[i] = 1
					break
				}
			}
		} else if string(y) == "R" {
			for i := 9; i >= 0; i-- {
				if a[i] == 0 {
					a[i] = 1
					break
				}
			}
		} else {
			z, _ := strconv.Atoi(string(y))
			a[z] = 0
		}
	}

	for i := 0; i < 10; i++ {
		fmt.Printf("%d", a[i])
	}

}

package main

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

func main() {
	var q int
	var st string

	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &q)

	a := make([]int, 10)

	fmt.Scanln(&st)

	for _, y := range st {
		if string(y) == "L" {
			for i := 0; i < 10; i++ {
				if a[i] == 0 {
					a[i] = 1
					break
				}
			}
		} else if string(y) == "R" {
			for i := 9; i >= 0; i-- {
				if a[i] == 0 {
					a[i] = 1
					break
				}
			}
		} else {
			z, _ := strconv.Atoi(string(y))
			a[z] = 0
		}
	}
	ans := ""
	for i := 0; i < 10; i++ {
		y := strconv.Itoa(a[i])
		ans += y
	}
	fmt.Println(ans)

}


package main

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

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

	var n, k, v, c int
	Fscan(in, &n, &k)
	lim := (n-1)/(k-1) + 1
	ans := make([][]int, n)
	inAns := make([]bool, n)
	pos := make([][]int, n)
	for i := 1; i <= n*k; i++ {
		Fscan(in, &v)
		v--
		if inAns[v] {
			continue
		}
		pos[v] = append(pos[v], i)
		if len(pos[v]) != 2 {
			continue
		}
		if c++; c == lim {
			c = 0
			for j, p := range pos {
				if len(p) > 1 {
					ans[j] = p[:2]
					inAns[j] = true
				} else {
					pos[j] = nil
				}
			}
		}
	}
	for j, p := range pos {
		if len(p) > 1 {
			ans[j] = p[:2]
		}
	}
	for _, p := range ans {
		Fprintln(out, p[0], p[1])
	}
}

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

package main

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

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

	var n, k, v, c int
	Fscan(in, &n, &k)
	lim := (n-1)/(k-1) + 1
	ans := make([][]int, n)
	vis := make([]bool, n)
	ps := make([][]int, n)
	for i := 1; i <= n*k; i++ {
		Fscan(in, &v)
		v--
		if vis[v] {
			continue
		}
		ps[v] = append(ps[v], i)
		if len(ps[v]) != 2 {
			continue
		}
		if c++; c == lim {
			c = 0
			for j, p := range ps {
				if len(p) > 1 {
					ans[j] = p[:2]
					vis[j] = true
				}
				ps[j] = nil
			}
		}
	}
	for j, p := range ps {
		if len(p) > 1 {
			ans[j] = p[:2]
		}
	}
	for _, p := range ans {
		Fprintln(out, p[0], p[1])
	}
}

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


package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		a, b, k := readThreeNums(reader)
		A := readNNums(reader, k)
		B := readNNums(reader, k)
		res := solve(a, b, k, A, B)
		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(a, b, k int, A, B []int) int64 {
	ad := make([]int, a)
	bd := make([]int, b)
	for i := 0; i < k; i++ {
		u, v := A[i], B[i]
		u--
		v--
		ad[u]++
		bd[v]++
	}

	var res int64

	for i := 0; i < k; i++ {
		u, v := A[i], B[i]
		u--
		v--
		// if we choose this pair, other could be
		res = res + int64(k) - 1 - int64(ad[u]-1) - int64(bd[v]-1)
	}
	res /= 2
	return res
}

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

func main(){

	var input io.Reader=bufio.NewReader(os.Stdin)
	var t int32
	fmt.Fscan(input,&t)
	for t>0{
		var a,b,k,i int64
		fmt.Fscan(input,&a);fmt.Fscan(input,&b);fmt.Fscan(input,&k)
		var boys []int64=make([]int64,k)
		var girls []int64=make([]int64,k)
		for i=0;i<k;i++{
			fmt.Fscan(input,&boys[i])
		}
		for i=0;i<k;i++{
			fmt.Fscan(input,&girls[i])
		}
		var temp_boy []int64=make([]int64,a)
		var temp_girl []int64=make([]int64,b)
		for i=0;i<k;i++{
			temp_boy[boys[i]-1]++
			temp_girl[girls[i]-1]++
		}
		var ans int64
		for i=0;i<k;i++{
			ans+=k-temp_boy[boys[i]-1]-temp_girl[girls[i]-1]+1
		}
		fmt.Println(ans/2)
		t--

	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var N int
	var a, b, k, boy, girl int
	Fscan(in, &N)
	for tt:=0; tt < N; tt ++ {
		Fscan(in, &a)
		Fscan(in, &b)
		Fscan(in, &k)

		c1 := make([]int, a)
		c2 := make([]int, b)

		for i :=0; i<k; i++ {
			Fscan(in, &boy)
			c1[boy - 1]++
		}
		for i :=0; i<k; i++ {
			Fscan(in, &girl)
			c2[girl - 1]++
		}

		ans := int64(k) * int64(k - 1) / 2

		for _, v := range c1 {
			ans -= int64(v) * int64(v - 1) / 2
		}

		for _, v := range c2 {
			ans -= int64(v) * int64(v - 1) / 2
		}
		out.WriteString(Sprintf("%d\n", ans))
	}
}

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 int }
	solve := func(Case int) {
		var a,b,k int
		Fscan(in, &a,&b,&k)

		ps := make([]pair,k)
		for i := range ps {
			Fscan(in, &ps[i].x)
		}
		for i := range ps {
			Fscan(in, &ps[i].y)
		}
		sort.Slice(ps, func(i, j int) bool { return ps[i].x < ps[j].x })

		ans := int64(0)
		cnt := make([]int, b+1)
		all := 0
		for i, n := 0, len(ps); i < n; {
			st := i
			v := ps[st]
			for ; i < n && ps[i].x == v.x; i++ {
				ans+=int64(all-cnt[ps[i].y])
			}

			for ; st < i && ps[st].x == v.x; st++ {
				all++
				cnt[ps[st].y]++
			}
		}
		Fprintln(out, ans)
	}

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

package main

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

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)

// github.com/EndlessCheng/codeforces-go
func Solve(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var kase int;
	fmt.Fscan(in, &kase);
	for s := 1 ; s <= kase ; s++{
		fmt.Fscan(in,&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Fscan(in,&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Fscan(in,&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 0; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int64 = 0;
		for i:= 1; i <= k ;i++{
			ans += int64(k - cnta[a[i]] - cntb[b[i]] + 1);
		}
		ans >>= 1;
		fmt.Fprintln(out,ans);
	}

}

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

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

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

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getI()
	}
	return ret
}

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

// min, max, asub, abs
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
}

// min for n entry
func nmin(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func solve(qty, boys, girls []int) int64 {
	b := make([]int, qty[1]+1)
	g := make([]int, qty[0]+1)
	for i := 0; i < qty[2]; i++ {
		g[boys[i]]++
		b[girls[i]]++
	}

	var total int64
	for i := 0; i < qty[2]; i++ {
		total += int64((qty[2] - 1) - (g[boys[i]] - 1) - (b[girls[i]] - 1))
	}
	return total / 2
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt32)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	t := getI()
	for i := 0; i < t; i++ {
		qty := getInts(3)
		boys, girls := getInts(qty[2]), getInts(qty[2])

		res := solve(qty, boys, girls)
		fmt.Fprintf(wr, "%d\n", res)
	}

	out()
}

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var a, b, k int
		Fscan(in, &a, &b, &k)

		boys, girls := make([]int, k), make([]int, k)
		for i := range boys {
			Fscan(in, &boys[i])
		}
		for i := range girls {
			Fscan(in, &girls[i])
		}
		mpb, mpg := make(map[int]int), make(map[int]int)
		for i := 0; i < k; i++ {
			mpb[boys[i]]++
			mpg[girls[i]]++
		}

		var ans int64
		for i := 0; i < k; i++ {
			ans += int64(k - mpb[boys[i]] - mpg[girls[i]] + 1)
		}
		Fprintln(out, ans>>1)
	}
}

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

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var a, b, k int
		Fscan(in, &a, &b, &k)
		boys, girls := make([]int, k), make([]int, k)
		for i, _ := range boys {
			Fscan(in, &boys[i])
		}
		for i, _ := range girls {
			Fscan(in, &girls[i])
		}

		mpb, mpg := make(map[int]int), make(map[int]int)
		for i := 0; i < k; i++ {
			mpb[boys[i]]++
			mpg[girls[i]]++
		}
		ans := int64(0)
		for i := 0; i < k; i++ {
			ans += int64(k - mpb[boys[i]] - mpg[girls[i]] + 1)
		}
		Fprintln(out, ans>>1)
	}

}

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

package main

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

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

func Max(x, y int64) int64 {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	t := 10000
	fmt.Fscan(in, &t)
	for ; t != 0; t-- {
		var a, b, k int
		fmt.Fscan(in, &a, &b, &k)
		av, bv := make([]int, a), make([]int, b)
		abv := make(map[int]map[int]int)
		ans := int64(0)
		x, y := make([]int, k), make([]int, k)
		for i := 0; i < k; i++ {
			fmt.Fscan(in, &x[i])
			x[i]--
		}
		for i := 0; i < k; i++ {
			fmt.Fscan(in, &y[i])
			y[i]--
		}
		for i := 0; i < k; i++ {
			if _, ok := abv[x[i]]; !ok {
				abv[x[i]] = make(map[int]int)
			}
			ans += int64(i - (av[x[i]] + bv[y[i]] - abv[x[i]][y[i]]))
			av[x[i]]++
			bv[y[i]]++
			abv[x[i]][y[i]]++
		}
		fmt.Println(ans)
	}
}

package main

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

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

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

func IntArray(size int) []int {
	arr := make([]int, size)
	for i := 0; i < size; i++ {
		scanf("%d", &arr[i])
	}
	scanf("\n")
	return arr
}

func Max(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] > m {
			m = args[i]
		}
	}
	return m
}

func Min(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] < m {
			m = args[i]
		}
	}
	return m
}

type pair struct {
	boy, girl int
}

func solve() {
	var a, b, k, ans, i int64
	scanf("%d %d %d\n", &a, &b, &k)
	edges := make([]pair, k)
	A, B := make([]int64, a), make([]int64, b)
	for i = 0; i < k; i++ {
		scanf("%d", &edges[i].boy)
	}
	scanf("\n")
	for i = 0; i < k; i++ {
		scanf("%d", &edges[i].girl)
	}
	scanf("\n")
	for _, edge := range edges {
		A[edge.boy-1]++
		B[edge.girl-1]++
	}

	for _, edge := range edges {
		ans += k - A[edge.boy-1] - B[edge.girl-1] + 1
	}

	printf("%d\n", ans/2)
}

func main() {
	defer writer.Flush()

	var cases int

	scanf("%d\n", &cases)

	for c := 0; c < cases; c++ {
		solve()
	}
}

/*

 */

package main

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

var sc = bufio.NewScanner(os.Stdin)
var wr = bufio.NewWriter(os.Stdout)

func out(x ...interface{}) {
	fmt.Fprintln(wr, x...)
}

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

func getF() float64 {
	sc.Scan()
	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getI()
	}
	return ret
}

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

// min, max, asub, abs
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
}

// min for n entry
func nmin(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = min(ret, e)
	}
	return ret
}

// max for n entry
func nmax(a ...int) int {
	ret := a[0]
	for _, e := range a {
		ret = max(ret, e)
	}
	return ret
}

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

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

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func solve(qty, boys, girls []int) int {
	b := make([]int, qty[1]+1)
	g := make([]int, qty[0]+1)
	for i := 0; i < qty[2]; i++ {
		g[boys[i]]++
		b[girls[i]]++
	}

	var total int
	for i := 0; i < qty[2]; i++ {
		total += ((int(qty[2]) - 1) - (g[boys[i]] - 1) - (b[girls[i]] - 1))
	}
	return total / 2
}

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt32)
	// this template is new version.
	// use getI(), getS(), getInts(), getF()
	t := getI()
	for i := 0; i < t; i++ {
		qty := getInts(3)
		boys, girls := getInts(qty[2]), getInts(qty[2])

		res := solve(qty, boys, girls)
		fmt.Fprintf(wr, "%d\n", res)
	}

	out()
}

package main

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

// var cache = make(map[string]int)

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int {
	num, err := strconv.Atoi(strings.TrimSpace(s))
	if err != nil {
		fmt.Fprintln(os.Stderr, "reading standard input:", err)
	}
	return num
}

// GetNums reads "n" numbers from the input
func GetNums(n int) []int {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var result []int
	for i := 0; i < n; i++ {
		scanner.Scan()

		if err := scanner.Err(); err != nil {
			fmt.Fprintln(os.Stderr, "reading standard input:", err)
		}

		fmt.Println(scanner.Text())
		result = append(result, ParseInt(scanner.Text()))
	}

	return result
}

func solve(qty, boys, girls []int) int {
	b := make([]int, qty[1]+1)
	g := make([]int, qty[0]+1)
	for i := 0; i < qty[2]; i++ {
		g[boys[i]]++
		b[girls[i]]++
	}

	var total int
	for i := 0; i < qty[2]; i++ {
		total += ((int(qty[2]) - 1) - (g[boys[i]] - 1) - (b[girls[i]] - 1))
	}
	return total / 2
}

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

	var results []int

	for i := 0; i < test_cases; i++ {
		qty := GetNums(3)
		boys := GetNums(qty[2])
		girls := GetNums(qty[2])
		results = append(results, solve(qty, boys, girls))
	}

	for _, r := range results {
		fmt.Println(r)
	}
}

package main

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

// var cache = make(map[string]int)

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int {
	num, err := strconv.Atoi(strings.TrimSpace(s))
	if err != nil {
		fmt.Fprintln(os.Stderr, "reading standard input:", err)
	}
	return num
}

// GetNums reads "n" numbers from the input
func GetNums(n int) []int {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var result []int
	for i := 0; i < n; i++ {
		scanner.Scan()

		if err := scanner.Err(); err != nil {
			fmt.Fprintln(os.Stderr, "reading standard input:", err)
		}

		result = append(result, ParseInt(scanner.Text()))
	}

	return result
}

func solve(qty, boys, girls []int) int {
	b := make([]int, qty[1]+1)
	g := make([]int, qty[0]+1)
	for i := 0; i < qty[2]; i++ {
		g[boys[i]]++
		b[girls[i]]++
	}

	var total int
	for i := 0; i < qty[2]; i++ {
		total += ((int(qty[2]) - 1) - (g[boys[i]] - 1) - (b[girls[i]] - 1))
	}
	return total / 2
}

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

	var results []int

	for i := 0; i < test_cases; i++ {
		qty := GetNums(3)
		fmt.Println(qty)
		boys := GetNums(qty[2])
		girls := GetNums(qty[2])
		results = append(results, solve(qty, boys, girls))
	}

	for _, r := range results {
		fmt.Println(r)
	}
}

package main

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

// var cache = make(map[string]int)

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int {
	num, err := strconv.Atoi(strings.TrimSpace(s))
	if err != nil {
		fmt.Fprintln(os.Stderr, "reading standard input:", err)
	}
	return num
}

// GetNums reads "n" numbers from the input
func GetNums(n int) []int {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var result []int
	for i := 0; i < n; i++ {
		scanner.Scan()

		if err := scanner.Err(); err != nil {
			fmt.Fprintln(os.Stderr, "reading standard input:", err)
		}

		result = append(result, ParseInt(scanner.Text()))
	}

	return result
}

func solve(qty, boys, girls []int) int {
	b := make([]int, qty[1]+1)
	g := make([]int, qty[0]+1)
	for i := 0; i < qty[2]; i++ {
		g[boys[i]]++
		b[girls[i]]++
	}

	var total int
	for i := 0; i < qty[2]; i++ {
		total += ((int(qty[2]) - 1) - (g[boys[i]] - 1) - (b[girls[i]] - 1))
	}
	return total / 2
}

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

	var results []int

	for i := 0; i < test_cases; i++ {
		qty := GetNums(3)
		boys := GetNums(qty[2])
		girls := GetNums(qty[2])
		results = append(results, solve(qty, boys, girls))
	}

	for _, r := range results {
		fmt.Println(r)
	}
}

package main

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

// var cache = make(map[string]int)

// SplitNums splits a string into a slice of integers
func SplitNums(s string) []int {
	nums := strings.Split(strings.TrimSpace(s), " ")
	var result []int
	for _, n := range nums {
		result = append(result, ParseInt(n))
	}
	return result
}

// ParseInt converts a string into an integer
func ParseInt(s string) int {
	num, err := strconv.Atoi(strings.TrimSpace(s))
	if err != nil {
		fmt.Fprintln(os.Stderr, "reading standard input:", err)
	}
	return num
}

// GetNums reads "n" numbers from the input
func GetNums(n int) []int {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var result []int
	for i := 0; i < n; i++ {
		scanner.Scan()

		if err := scanner.Err(); err != nil {
			fmt.Fprintln(os.Stderr, "reading standard input:", err)
		}

		result = append(result, ParseInt(scanner.Text()))
	}

	return result
}

func solve(qty, boys, girls []int) int {
	b := make([]int, qty[1]+1)
	g := make([]int, qty[0]+1)
	for i := 0; i < qty[2]; i++ {
		g[boys[i]]++
		b[girls[i]]++
	}

	var total int
	for i := 0; i < qty[2]; i++ {
		total += ((int(qty[2]) - 1) - (g[boys[i]] - 1) - (b[girls[i]] - 1))
	}
	return total / 2
}

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

	for i := 0; i < test_cases; i++ {
		qty := GetNums(3)
		boys := GetNums(qty[2])
		girls := GetNums(qty[2])
		fmt.Println(solve(qty, boys, girls))
	}
}

package main

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

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
var answer = make([]int, limit)

// github.com/EndlessCheng/codeforces-go
func Solve(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var kase int;
	fmt.Fscan(in, &kase);
	for s := 1 ; s <= kase ; s++{
		fmt.Fscan(in,&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Fscan(in,&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Fscan(in,&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans += + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		fmt.Fprintln(out,ans);
	}

}

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

package main

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

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
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...) }
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
var answer = make([]int, limit)
func main() {
	var kase int
	scanf("%d",&kase);
	for s:= 1; s <= kase;s++{
		scanf("%d%d%d",&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			scanf("%d",&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			scanf("%d",&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans = ans + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		answer[s] = ans;
	}
	for s:= 1; s <= kase;s++{
		printf("%d\n",answer[s]);
	}
}

package main

import (
	"fmt"
)

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
var answer = make([]int, limit)
func main() {
	var kase int
	fmt.Scanf("%d",&kase);
	for s:= 1; s <= kase;s++{
		fmt.Scanf("%d%d%d",&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans = ans + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		answer[s] = ans;
	}
	for s:= 1; s <= kase;s++{
		fmt.Println(answer[s]);
	}
}

package main

import (
	"fmt"
	"os"
)

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
func main() {
	var kase int
	fmt.Scanf("%d",&kase);
	for s:= 1; s <= kase;s++{
		fmt.Scanf("%d%d%d",&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans = ans + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		fmt.Fprint(os.Stdout,ans)
		fmt.Fprint(os.Stdout,"\n")
	}
}

package main

import "fmt"

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
func main() {
	var kase int
	fmt.Scanf("%d",&kase);
	for s:= 1; s <= kase;s++{
		fmt.Scanf("%d%d%d",&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans = ans + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		fmt.Print(ans)
		fmt.Print("\n")
	}
}

package main

import "fmt"

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
func main() {
	var kase int
	fmt.Scanf("%d",&kase);
	for s:= 1; s <= kase;s++{
		fmt.Scanf("%d%d%d",&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans = ans + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		fmt.Printf("%d\n",ans)
	}
}

package main

import "fmt"

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
func main() {
	var kase int
	fmt.Scanf("%d",&kase);
	for s:= 1; s <= kase;s++{
		fmt.Scanf("%d%d%d",&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans = ans + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		println(ans)
	}
}

package main

import "fmt"

func Min(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func Max(x, y int) int{
	if x > y {
		return x
	}
	return y
}
const limit int = 200005;
var n,m,k int;
var a = make([]int,limit)
var b = make([]int, limit)
var cnta = make([]int,limit)
var cntb = make([]int, limit)
func main() {
	var kase int
	fmt.Scanf("%d",&kase);
	for s:= 1; s <= kase;s++{
		fmt.Scanf("%d%d%d",&n,&m,&k);
		var maxx int = 0;
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&a[i]);
			//cnta[a[i]]++;
			maxx = Max(maxx,a[i])
		}
		for i:= 1; i <= k ;i++{
			fmt.Scanf("%d",&b[i]);
			//cntb[b[i]]++;
			maxx = Max(maxx,b[i])
		}
		for i:= 1; i <= maxx ;i++{
			cntb[i] = 0;
			cnta[i] = 0;
		}
		for i:= 1; i <= k ;i++{
			cntb[b[i]]++;
			cnta[a[i]]++;
		}
		var ans int = 0;
		for i:= 1; i <= k ;i++{
			ans = ans + k - cnta[a[i]] - cntb[b[i]] + 1;
		}
		ans >>= 1;
		fmt.Println(ans)
	}
}

package main

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

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

	var t int
	for Fscan(in, &t); t > 0; t-- {
		var a, b, k int
		Fscan(in, &a, &b, &k)
		boys, girls := make([]int, k), make([]int, k)
		for i, _ := range boys {
			Fscan(in, &boys[i])
		}
		for i, _ := range girls {
			Fscan(in, &girls[i])
		}

		mpb, mpg := make(map[int]int), make(map[int]int)
		for i := 0; i < k; i++ {
			mpb[boys[i]]++
			mpg[girls[i]]++
		}
		ans := 0
		for i := 0; i < k; i++ {
			ans += k - mpb[boys[i]] - mpg[girls[i]] + 1
		}
		Fprintln(out, ans>>1)
	}

}

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

package main

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

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

func Max(x, y int64) int64 {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	t := 10000
	fmt.Fscan(in, &t)
	for ; t != 0; t-- {
		var a, b, k int
		fmt.Fscan(in, &a, &b, &k)
		av, bv := make([]int, a), make([]int, b)
		abv := make(map[int]map[int]int)
		ans := 0
		x, y := make([]int, k), make([]int, k)
		for i := 0; i < k; i++ {
			fmt.Fscan(in, &x[i])
			x[i]--
		}
		for i := 0; i < k; i++ {
			fmt.Fscan(in, &y[i])
			y[i]--
		}
		for i := 0; i < k; i++ {
			if _, ok := abv[x[i]]; !ok {
				abv[x[i]] = make(map[int]int)
			}
			ans += i - (av[x[i]] + bv[y[i]] - abv[x[i]][y[i]])
			av[x[i]]++
			bv[y[i]]++
			abv[x[i]][y[i]]++
		}
		fmt.Println(ans)
	}
}

package main

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

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

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

func IntArray(size int) []int {
	arr := make([]int, size)
	for i := 0; i < size; i++ {
		scanf("%d", &arr[i])
	}
	scanf("\n")
	return arr
}

func Max(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] > m {
			m = args[i]
		}
	}
	return m
}

func Min(args ...int) int {
	m := args[0]
	for i := range args {
		if args[i] < m {
			m = args[i]
		}
	}
	return m
}

type pair struct {
	boy, girl int
}

func solve() {
	var a, b, k int
	scanf("%d %d %d\n", &a, &b, &k)
	edges := make([]pair, k)
	A, B := make([]int, a), make([]int, b)
	for i := 0; i < k; i++ {
		scanf("%d", &edges[i].boy)
	}
	scanf("\n")
	for i := 0; i < k; i++ {
		scanf("%d", &edges[i].girl)
	}
	scanf("\n")
	for _, edge := range edges {
		A[edge.boy-1]++
		B[edge.girl-1]++
	}

	ans := 0

	for _, edge := range edges {
		ans += k - A[edge.boy-1] - B[edge.girl-1] + 1
	}

	printf("%d\n", ans/2)
}

func main() {
	defer writer.Flush()

	var cases int

	scanf("%d\n", &cases)

	for c := 0; c < cases; c++ {
		solve()
	}
}

/*

 */

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

func main(){

	var input io.Reader=bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(input,&t)
	for t>0{
		var a,b,k,i int
		fmt.Fscan(input,&a);fmt.Fscan(input,&b);fmt.Fscan(input,&k)
		var boys []int=make([]int,k)
		var girls []int=make([]int,k)
		for i=0;i<k;i++{
			fmt.Fscan(input,&boys[i])
		}
		for i=0;i<k;i++{
			fmt.Fscan(input,&girls[i])
		}
		var temp_boy []int=make([]int,a)
		var temp_girl []int=make([]int,b)
		for i=0;i<k;i++{
			temp_boy[boys[i]-1]++
			temp_girl[girls[i]-1]++
		}
		var ans int
		for i=0;i<k;i++{
			ans+=k-temp_boy[boys[i]-1]-temp_girl[girls[i]-1]+1
		}
		fmt.Println(ans/2)
		t--

	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var N int
	var a, b, k, boy, girl int
	Fscan(in, &N)
	for tt:=0; tt < N; tt ++ {
		Fscan(in, &a)
		Fscan(in, &b)
		Fscan(in, &k)

		c1 := make([]int, a)
		c2 := make([]int, b)

		for i :=0; i<k; i++ {
			Fscan(in, &boy)
			c1[boy - 1]++
		}
		for i :=0; i<k; i++ {
			Fscan(in, &girl)
			c2[girl - 1]++
		}

		ans := k * (k - 1) / 2

		for _, v := range c1 {
			ans -= v * (v - 1) / 2
		}

		for _, v := range c2 {
			ans -= v * (v - 1) / 2
		}
		out.WriteString(Sprintf("%d\n", ans))
	}
}