Amugae has a hotel consisting of $$$10$$$ rooms. The rooms are numbered from $$$0$$$ to $$$9$$$ from left to right.The hotel has two entrances — one from the left end, and another from the right end. When a customer arrives to the hotel through the left entrance, they are assigned to an empty room closest to the left entrance. Similarly, when a customer arrives at the hotel through the right entrance, they are assigned to an empty room closest to the right entrance.One day, Amugae lost the room assignment list. Thankfully Amugae's memory is perfect, and he remembers all of the customers: when a customer arrived, from which entrance, and when they left the hotel. Initially the hotel was empty. Write a program that recovers the room assignment list from Amugae's memory.

The first line consists of an integer $$$n$$$ ($$$1 \le n \le 10^5$$$), the number of events in Amugae's memory. The second line consists of a string of length $$$n$$$ describing the events in chronological order. Each character represents:    'L': A customer arrives from the left entrance.  'R': A customer arrives from the right entrance.  '0', '1', ..., '9': The customer in room $$$x$$$ ($$$0$$$, $$$1$$$, ..., $$$9$$$ respectively) leaves.  It is guaranteed that there is at least one empty room when a customer arrives, and there is a customer in the room $$$x$$$ when $$$x$$$ ($$$0$$$, $$$1$$$, ..., $$$9$$$) is given. Also, all the rooms are initially empty.

In the only line, output the hotel room's assignment status, from room $$$0$$$ to room $$$9$$$. Represent an empty room as '0', and an occupied room as '1', without spaces.

NoteIn the first example, hotel room's assignment status after each action is as follows.   First of all, all rooms are empty. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  L: one more customer from the left entrance. Assignment status is 1100000000.  R: one more customer from the right entrance. Assignment status is 1100000001.  L: one more customer from the left entrance. Assignment status is 1110000001.  1: the customer in room $$$1$$$ leaves. Assignment status is 1010000001.  R: one more customer from the right entrance. Assignment status is 1010000011.  L: one more customer from the left entrance. Assignment status is 1110000011.  1: the customer in room $$$1$$$ leaves. Assignment status is 1010000011. So after all, hotel room's final assignment status is 1010000011.In the second example, hotel room's assignment status after each action is as follows.   L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  0: the customer in room $$$0$$$ leaves. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000 again.  0: the customer in room $$$0$$$ leaves. Assignment status is 0000000000.  L: a customer arrives to the hotel through the left entrance. Assignment status is 1000000000.  L: one more customer from the left entrance. Assignment status is 1100000000.  R: one more customer from the right entrance. Assignment status is 1100000001.  R: one more customer from the right entrance. Assignment status is 1100000011.  9: the customer in room $$$9$$$ leaves. Assignment status is 1100000010. So after all, hotel room's final assignment status is 1100000010.

// 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() {
	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 (
	"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)
	}

}

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

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

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

}


The numbers $$$1, \, 2, \, \dots, \, n \cdot k$$$ are colored with $$$n$$$ colors. These colors are indexed by $$$1, \, 2, \, \dots, \, n$$$. For each $$$1 \le i \le n$$$, there are exactly $$$k$$$ numbers colored with color $$$i$$$.Let $$$[a, \, b]$$$ denote the interval of integers between $$$a$$$ and $$$b$$$ inclusive, that is, the set $$$\{a, \, a + 1, \, \dots, \, b\}$$$. You must choose $$$n$$$ intervals $$$[a_1, \, b_1], \, [a_2, \, b_2], \, \dots, [a_n, \, b_n]$$$ such that:   for each $$$1 \le i \le n$$$, it holds $$$1 \le a_i < b_i \le n \cdot k$$$;  for each $$$1 \le i \le n$$$, the numbers $$$a_i$$$ and $$$b_i$$$ are colored with color $$$i$$$;  each number $$$1 \le x \le n \cdot k$$$ belongs to at most $$$\left\lceil \frac{n}{k - 1} \right\rceil$$$ intervals. One can show that such a family of intervals always exists under the given constraints.

The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 100$$$, $$$2 \le k \le 100$$$) — the number of colors and the number of occurrences of each color. The second line contains $$$n \cdot k$$$ integers $$$c_1, \, c_2, \, \dots, \, c_{nk}$$$ ($$$1 \le c_j \le n$$$), where $$$c_j$$$ is the color of number $$$j$$$. It is guaranteed that, for each $$$1 \le i \le n$$$, it holds $$$c_j = i$$$ for exactly $$$k$$$ distinct indices $$$j$$$.

Output $$$n$$$ lines. The $$$i$$$-th line should contain the two integers $$$a_i$$$ and $$$b_i$$$. If there are multiple valid choices of the intervals, output any.

NoteIn the first sample, each number can be contained in at most $$$\left\lceil \frac{4}{3 - 1} \right\rceil = 2$$$ intervals. The output is described by the following picture:  In the second sample, the only interval to be chosen is forced to be $$$[1, \, 2]$$$, and each number is indeed contained in at most $$$\left\lceil \frac{1}{2 - 1} \right\rceil = 1$$$ interval.In the third sample, each number can be contained in at most $$$\left\lceil \frac{3}{3 - 1} \right\rceil = 2$$$ intervals. The output is described by the following picture:

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


At the school where Vasya is studying, preparations are underway for the graduation ceremony. One of the planned performances is a ball, which will be attended by pairs of boys and girls.Each class must present two couples to the ball. In Vasya's class, $$$a$$$ boys and $$$b$$$ girls wish to participate. But not all boys and not all girls are ready to dance in pairs.Formally, you know $$$k$$$ possible one-boy-one-girl pairs. You need to choose two of these pairs so that no person is in more than one pair.For example, if $$$a=3$$$, $$$b=4$$$, $$$k=4$$$ and the couples $$$(1, 2)$$$, $$$(1, 3)$$$, $$$(2, 2)$$$, $$$(3, 4)$$$ are ready to dance together (in each pair, the boy's number comes first, then the girl's number), then the following combinations of two pairs are possible (not all possible options are listed below):   $$$(1, 3)$$$ and $$$(2, 2)$$$;  $$$(3, 4)$$$ and $$$(1, 3)$$$; But the following combinations are not possible:   $$$(1, 3)$$$ and $$$(1, 2)$$$ — the first boy enters two pairs;  $$$(1, 2)$$$ and $$$(2, 2)$$$ — the second girl enters two pairs; Find the number of ways to select two pairs that match the condition above. Two ways are considered different if they consist of different pairs.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains three integers $$$a$$$, $$$b$$$ and $$$k$$$ ($$$1 \le a, b, k \le 2 \cdot 10^5$$$) — the number of boys and girls in the class and the number of couples ready to dance together. The second line of each test case contains $$$k$$$ integers $$$a_1, a_2, \ldots a_k$$$. ($$$1 \le a_i \le a$$$), where $$$a_i$$$ is the number of the boy in the pair with the number $$$i$$$. The third line of each test case contains $$$k$$$ integers $$$b_1, b_2, \ldots b_k$$$. ($$$1 \le b_i \le b$$$), where $$$b_i$$$ is the number of the girl in the pair with the number $$$i$$$. It is guaranteed that the sums of $$$a$$$, $$$b$$$, and $$$k$$$ over all test cases do not exceed $$$2 \cdot 10^5$$$. It is guaranteed that each pair is specified at most once in one test case.

For each test case, on a separate line print one integer — the number of ways to choose two pairs that match the condition above.

NoteIn the first test case, the following combinations of pairs fit:   $$$(1, 2)$$$ and $$$(3, 4)$$$;  $$$(1, 3)$$$ and $$$(2, 2)$$$;  $$$(1, 3)$$$ and $$$(3, 4)$$$;  $$$(2, 2)$$$ and $$$(3, 4)$$$. There is only one pair in the second test case.In the third test case, the following combinations of pairs fit:   $$$(1, 1)$$$ and $$$(2, 2)$$$;  $$$(1, 2)$$$ and $$$(2, 1)$$$.

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