package main

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

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

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

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

	in.Scan();
	t, _ := strconv.Atoi(in.Text());
	for i:=0; i<t; i++ {
		a := int64(0);
		b := int64(0);

		in.Scan();
		n, _ :=strconv.ParseInt(in.Text(), 10, 64);

		for i:=int64(0); i<n; i++ {
			in.Scan();
			temp, _ :=strconv.ParseInt(in.Text(), 10, 64);
			a += (temp&1);
		}
		in.Scan();
		m, _ :=strconv.ParseInt(in.Text(), 10, 64);
		for i:=int64(0); i<m; i++ {
			in.Scan();
			temp, _ :=strconv.ParseInt(in.Text(), 10, 64);
			b += (temp&1);
		}

		out.WriteString(strconv.FormatInt(a*b+(n-a)*(m-b), 10));
		out.WriteByte('\n');
	}
}

package main

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

var (
	reader *bufio.Reader
)

func countOddAndEven() (int64, int64) {
	var odd, even, n, tmp int64
	fmt.Fscan(reader, &n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(reader, &tmp)
		if tmp%2 == 0 {
			even++
		} else {
			odd++
		}
	}
	return odd, even
}

func main() {

	var t int64
	reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

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

		var oddD, evenD, oddJ, evenJ int64

		oddD, evenD = countOddAndEven()
		oddJ, evenJ = countOddAndEven()

		fmt.Println(oddD*oddJ + evenD*evenJ)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t, n, m int64
	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		var no, nj, p int64 = 0, 0, 0
		for i := int64(1); i <= n; i++ {
			if i != n {
				fmt.Fscanf(reader, "%d", &p)
			} else {
				fmt.Fscanf(reader, "%d\n", &p)
			}

			if p%2 == 0 {
				no++
			} else {
				nj++
			}
		}

		fmt.Fscanf(reader, "%d\n", &m)
		var mo, mj, q int64 = 0, 0, 0
		for i := int64(1); i <= m; i++ {
			if i != m {
				fmt.Fscanf(reader, "%d", &q)
			} else {
				fmt.Fscanf(reader, "%d\n", &q)
			}

			if q%2 == 0 {
				mo++
			} else {
				mj++
			}
		}

		fmt.Printf("%d\n", no*mo+nj*mj)
	}

}

package main

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

var (
	reader *bufio.Reader
)

func countOddAndEven() (int64, int64) {
	var odd, even, n, tmp int64
	fmt.Fscan(reader, &n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(reader, &tmp)
		if tmp%2 == 0 {
			even++
		} else {
			odd++
		}
	}
	return odd, even
}

func main() {

	reader = bufio.NewReader(os.Stdin)
	var t int64
	fmt.Fscan(reader, &t)

	for i := int64(0); i < t; i++ {
		var pEven, pOdd, qEven, qOdd int64
		pOdd, pEven = countOddAndEven()
		qOdd, qEven = countOddAndEven()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		pns := readLine(reader)
		pn, _ := strconv.Atoi(string(pns))
		po, pnoto := int64(0), int64(0)
		line := readLine(reader)
		arr := strings.Split(string(line), " ")
		// fmt.Println(pn, arr)
		for j := 0; j < pn; j++ {
			got, _ := strconv.ParseInt(arr[j], 10, 64)
			if got%2 == 0 {
				po++
			} else {
				pnoto++
			}
		}
		qns := readLine(reader)
		qn, _ := strconv.Atoi(string(qns))
		qo, qnoto := int64(0), int64(0)
		line = readLine(reader)
		arr = strings.Split(string(line), " ")
		// fmt.Println(qn, arr)
		for j := 0; j < qn; j++ {
			got, _ := strconv.ParseInt(arr[j], 10, 64)
			// fmt.Println(got)
			if got%2 == 0 {
				qo++
			} else {
				qnoto++
			}
		}
		// fmt.Println(po, pnoto, qo, qnoto)
		result := po*qo + pnoto*qnoto
		fmt.Println(result)
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			// fmt.Println(string(result))
			break
		}
	}
	return result
}

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		// str := strconv.FormatInt(A[i], 10)  // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

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

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

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

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		n := ReadInt()
		P := ReadIntSlice(n)
		m := ReadInt()
		Q := ReadIntSlice(m)

		// PP := make([]int, n)
		// QQ := make([]int, m)
		// for j := 0; j < n; j++ {
		// }
		peven := 0
		qeven := 0
		for j := 0; j < n; j++ {
			if P[j]%2 == 0 {
				peven++
			}
		}
		for j := 0; j < m; j++ {
			if Q[j]%2 == 0 {
				qeven++
			}
		}

		ans := int64(peven)*int64(qeven) + int64(n-peven)*int64(m-qeven)

		fmt.Println(ans)
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		n := readi()
		p := make([]int, n)
		for i := range p {
			p[i] = readi()
		}
		m := readi()
		q := make([]int, m)
		for i := range q {
			q[i] = readi()
		}
		println(solve(n, m, p, q))

	}
}

func solve(n, m int, p, q []int) int64 {
	var pe, qe, po, qo int
	for _, v := range p {
		if v%2 == 0 {
			pe++
		}
	}
	po = n - pe
	for _, v := range q {
		if v%2 == 0 {
			qe++
		}
	}
	qo = m - qe

	return int64(pe)*int64(qe) + int64(po)*int64(qo)
}

    package main

    import (
    	"bufio"
    	"fmt"
    	"os"
    )
    var (
    	reader *bufio.Reader
    )
    func input() (int64, int64) {
        odd := int64(0)
	    even := int64(0)
    	var n int64
    	fmt.Fscan(reader, &n)
    	arr := make([]int64, n)
    	for i := int64(0); i < n; i++ {
    		fmt.Fscan(reader, &arr[i])
    		if (arr[i]%2 == 0){
    			even++
    		}else {
    			odd++
    		}
    	}
    	return even, odd
    }
    func main(){
    	var t int64
    	reader = bufio.NewReader(os.Stdin)
    	fmt.Fscan(reader, &t)
    	for i := int64(0); i < t; i ++ {
    		var pEven, pOdd, qEven, qOdd int64
    		pEven, pOdd = input()
    		qEven, qOdd = input()
    		fmt.Println(pEven*qEven + pOdd*qOdd)
    	}
    }

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main() {
	for t := ScanInt(); t > 0; t-- {
		n := ScanInt()
		p := ScanInt64Slice(n)

		m := ScanInt()
		q := ScanInt64Slice(m)

		ep, op := evnOdd(p)
		eq, oq := evnOdd(q)

		r := (ep*eq)+(op*oq)

		P(r)
	}

	close(O)
	oWg.Wait()
}

func evnOdd(a []int64) (int64, int64) {
	o, e := int64(0), int64(0)
	for i := 0; i < len(a); i++ {
	    if a[i] % 2 == 0 {
	    	e++
		} else {
			o++
		}
	}
	return e, o
}

func intersect(p, q int64) bool {
	if (p+q)%2 == 0 {
		return true
	}

	return false
}

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

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

func init() {
	P = fmt.Println

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

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

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

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

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

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

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

package main

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

var (
	reader *bufio.Reader
)

func input() (int64, int64) {
	odd := int64(0)
	even := int64(0)

	var n int64
	fmt.Fscan(reader, &n)
	for i := int64(0); i < n; i++ {
		var x int64
		fmt.Fscan(reader, &x)
		if x % 2 == 0 {
			even++
			continue
		}
		odd++
	}
	return odd, even
}
func main(){
	reader = bufio.NewReader(os.Stdin)
	var t int64
	fmt.Fscan(reader, &t)
	for i := int64(0); i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int64
		pOdd, pEven = input()
		qOdd, qEven = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

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

/* solution */

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

func solveOne() {
	var odd1, odd2 int
	n := readInt()
	for i := 0; i < n; i++ {
		v := readInt()
		if v%2 > 0 {
			odd1++
		}
	}
	m := readInt()
	for i := 0; i < m; i++ {
		v := readInt()
		if v%2 > 0 {
			odd2++
		}
	}
	printInt64(int64(odd1)*int64(odd2) + int64(n-odd1)*int64(m-odd2))
}

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

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

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

package main

import (
    "fmt"
    "bufio"
    "os"
)
var input *bufio.Reader

func solve() {
    var (
        N int
        M int
        ans int64
        N_mod1 int64
        N_mod0 int64
        M_mod1 int64
        M_mod0 int64
    )
    fmt.Fscanf(input, "%d\n", &N)
    p := make([]int, N)
    for i:=0 ; i<N ; i++ {
        fmt.Fscanf(input, "%d", &p[i])
        if p[i]%2==0 {
            N_mod0 += 1
        } else {
            N_mod1 += 1
        }
    }
    fmt.Fscanf(input, "\n")
    fmt.Fscanf(input, "%d\n", &M)
    q := make([]int, M)
    for i:=0 ; i<M ; i++ {
        fmt.Fscanf(input, "%d", &q[i])
        if q[i]%2==0 {
            M_mod0 += 1
        } else {
            M_mod1 += 1
        }
    }
    fmt.Fscanf(input, "\n")

    ans = N_mod0*M_mod0 + N_mod1*M_mod1

    fmt.Println(ans)
}

func main () {
    input = bufio.NewReader(os.Stdin)
    var T int
    fmt.Fscanf(input, "%d\n", &T)
    for i:=0; i<T; i++ {
        solve()
    }
}

package main

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

const (
	MX_INT int64 = math.MaxInt64
	MN_INT int64 = math.MinInt64
)

func main(){
	for testCases := ScanInt64(); testCases > 0; testCases--{
		n := ScanInt64()
		p := ScanInt64Slice(n)
		m := ScanInt64()
		q := ScanInt64Slice(m)

		pEven, qEven := int64(0), int64(0)

		for i := 0; i < len(p); i++{
			if p[i] % 2 == 0{
				pEven++
			}
		}

		for i := 0; i < len(q); i++{
			if q[i] % 2 == 0{
				qEven++
			}
		}

		fmt.Println(pEven * qEven + (n - pEven) * (m - qEven))

	}
	close(O)
	oWg.Wait()
}

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

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

func init() {
	Pl = fmt.Println

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

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

	writer := bufio.NewWriterSize(os.Stdout, int(1e5))
	go func(writer *bufio.Writer) {
		defer oWg.Done()
		defer writer.Flush()

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

func ScanWord() string {
	in.Scan()
	return in.Text()
}

func ScanStringSlice(n int64) []string {
	length := int(n)
	s := make([]string, n)
	for i := 0; i < length; i++ {
		s[i] = ScanWord()
	}
	return s
}

func ScanInt64() int64 {
	intStr := ScanWord()
	i, err := strconv.ParseInt(intStr, 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt() int {
	intStr := ScanWord()
	i, err := strconv.Atoi(intStr)
	if err != nil {
		panic(err)
	}
	return i
}

func ScanInt64Slice(n int64) []int64 {
	length := int(n)
	arr := make([]int64, n)
	for i := 0; i < length; i++ {
		arr[i] = ScanInt64()
	}
	return arr
}

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

func Mx(args ...int64) int64 {
	maxVal := MN_INT
	for _, v := range args {
		if v > maxVal {
			maxVal = v
		}
	}
	return maxVal
}

func Mn(args ...int64) int64 {
	minVal := MX_INT
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
	}
	return minVal
}

func LCM(a, b int64) int64 {
	return a / GCD(a, b) * b
}

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

func S(v interface{}) string {
	return fmt.Sprintf("%v", v)
}

package main

import "fmt"

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

func doSth(DLSLines, JLSLines []int) int {
	var oddD, evenD, oddJ, evenJ, odd, even int

	for i := range DLSLines {
		if DLSLines[i]%2 == 0 {
			evenD++
		} else {
			oddD++
		}
	}

	for i := range JLSLines {
		if JLSLines[i]%2 == 0 {
			evenJ++
		} else {
			oddJ++
		}
	}

	if oddD != 0 && oddJ != 0 {
		odd = max(oddD, oddJ)
	}

	if evenD != 0 && evenJ != 0 {
		even = max(evenD, evenJ)
	}

	return odd + even
}

func main() {

	var numOfTest int
	var DLS, JLS int
	var DLSLines, JLSLines []int

	fmt.Scan(&numOfTest)
	for i := 0; i < numOfTest; i++ {
		fmt.Scan(&DLS)
		DLSLines = make([]int, DLS)
		for i := range DLSLines {
			fmt.Scan(&DLSLines[i])
		}

		fmt.Scan(&JLS)
		JLSLines = make([]int, JLS)
		for i := range JLSLines {
			fmt.Scan(&JLSLines[i])
		}

		fmt.Println(doSth(DLSLines, JLSLines))
	}

}

package main

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

var (
	reader *bufio.Reader
)

func countOddAndEven(c chan int64) {
	var odd, even, n, tmp int64
	fmt.Fscan(reader, &n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(reader, &tmp)
		if tmp%2 == 0 {
			even++
		} else {
			odd++
		}
	}

	c <- odd
	c <- even
	close(c)
}

func main() {

	var t int64
	reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

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

		var pEven, pOdd, qEven, qOdd int64

		c1 := make(chan int64)
		c2 := make(chan int64)

		go countOddAndEven(c1)
		go countOddAndEven(c2)

		pOdd, pEven = <-c1, <-c1
		qOdd, qEven = <-c2, <-c2

		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t, n, m int64
	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		var no, nj, p int64 = 0, 0, 0
		for i := int64(1); i <= n; i++ {
			if i != n {
				fmt.Fscanf(reader, "%d", &p)
			} else {
				fmt.Fscanf(reader, "%d\n", &p)
			}

			if p%2 == 0 {
				no++
			} else {
				nj++
			}
		}

		fmt.Fscanf(reader, "%d\n", &m)
		var mo, mj, q int64 = 0, 0, 0
		for i := int64(1); i <= m; i++ {
			if i != n {
				fmt.Fscanf(reader, "%d", &q)
			} else {
				fmt.Fscanf(reader, "%d\n", &q)
			}

			if q%2 == 0 {
				mo++
			} else {
				mj++
			}
		}

		fmt.Printf("%d\n", no*mo+nj*mj)
	}

}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var t, n, m int64
	fmt.Fscanf(reader, "%d\n", &t)
	for ; t > 0; t-- {
		fmt.Fscanf(reader, "%d\n", &n)
		var no, nj, p int64
		for i := int64(1); i <= n; i++ {
			if i != n {
				fmt.Fscanf(reader, "%d ", &p)
			} else {
				fmt.Fscanf(reader, "%d\n", &p)
			}

			if p%2 == 0 {
				no++
			} else {
				nj++
			}
		}

		fmt.Fscanf(reader, "%d\n", &m)
		var mo, mj, q int64
		for i := int64(1); i <= m; i++ {
			if i != n {
				fmt.Fscanf(reader, "%d ", &q)
			} else {
				fmt.Fscanf(reader, "%d\n", &q)
			}

			if q%2 == 0 {
				mo++
			} else {
				mj++
			}
		}

		fmt.Printf("%d\n", no*mo+nj*mj)
	}

}

package main

import (
    "fmt"
    "bufio"
    "os"
)
var input *bufio.Reader

func solve() {
    var (
        N int
        M int
        ans int
        N_mod1 int
        N_mod0 int
        M_mod1 int
        M_mod0 int
    )
    fmt.Fscanf(input, "%d\n", &N)
    p := make([]int, N)
    for i:=0 ; i<N ; i++ {
        fmt.Fscanf(input, "%d", &p[i])
        if p[i]%2==0 {
            N_mod0 += 1
        } else {
            N_mod1 += 1
        }
    }
    fmt.Fscanf(input, "\n")
    fmt.Fscanf(input, "%d\n", &M)
    q := make([]int, M)
    for i:=0 ; i<M ; i++ {
        fmt.Fscanf(input, "%d", &q[i])
        if q[i]%2==0 {
            M_mod0 += 1
        } else {
            M_mod1 += 1
        }
    }
    fmt.Fscanf(input, "\n")

    ans = N_mod0*M_mod0 + N_mod1*M_mod1

    fmt.Println(ans)
}

func main () {
    input = bufio.NewReader(os.Stdin)
    var T int
    fmt.Fscanf(input, "%d\n", &T)
    for i:=0; i<T; i++ {
        solve()
    }
}

package main

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

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

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

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

	in.Scan();
	t, _ := strconv.Atoi(in.Text());
	for i:=0; i<t; i++ {
		a := 0;
		b := 0;

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

		for i:=0; i<n; i++ {
			in.Scan();
			temp, _ :=strconv.Atoi(in.Text());
			a += (temp&1);
		}
		in.Scan();
		m, _ :=strconv.Atoi(in.Text());
		for i:=0; i<m; i++ {
			in.Scan();
			temp, _ :=strconv.Atoi(in.Text());
			b += (temp&1);
		}

		out.WriteString(strconv.Itoa(a*b + (n-a)*(m-b)));
		out.WriteByte('\n');
	}
}

package main

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

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

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

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

	in.Scan();
	t, _ := strconv.Atoi(in.Text());
	for i:=0; i<t; i++ {
		a := 0;
		b := 0;

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

		for i:=0; i<n; i++ {
			in.Scan();
			temp, _ :=strconv.Atoi(in.Text());
			a += (temp&1);
		}
		in.Scan();
		m, _ :=strconv.Atoi(in.Text());
		for i:=0; i<m; i++ {
			in.Scan();
			temp, _ :=strconv.Atoi(in.Text());
			b += (temp&1);
		}

		out.WriteString(strconv.FormatInt(int64(a*b+(n-a)*(m-b)), 10));
		out.WriteByte('\n');
	}
}

package main

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

func main() {
	var cases int
	fmt.Scanf("%d\n", &cases)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < cases; i++ {
		pns := readLine(reader)
		pn, _ := strconv.Atoi(string(pns))
		po, pnoto := 0, 0
		line := readLine(reader)
		arr := strings.Split(string(line), " ")
		// fmt.Println(pn, arr)
		for j:=0;j<pn;j++ {
			got, _ := strconv.ParseInt(arr[j], 10, 64)
			if got % 2 == 0 {
				po++
			} else {
				pnoto++
			}
		}
		qns := readLine(reader)
		qn, _ := strconv.Atoi(string(qns))
		qo, qnoto := 0,0
		line = readLine(reader)
		arr = strings.Split(string(line), " ")
		// fmt.Println(qn, arr)
		for j:=0;j<qn;j++ {
			got, _ := strconv.ParseInt(arr[j], 10, 64)
			// fmt.Println(got)
			if got % 2 == 0 {
				qo++
			} else {
				qnoto++
			}
		}
		// fmt.Println(po, pnoto, qo, qnoto)
		result := po * qo + pnoto * qnoto
		fmt.Println(result)
	}
}

func readLine(reader *bufio.Reader) []byte {
	result := make([]byte, 0)
	for {
		s, isPrefix, err := reader.ReadLine()
		if err != nil {
			fmt.Printf("error=%+v\n", err)
			break
		}
		result = append(result, s...)
		if !isPrefix {
			// fmt.Println(string(result))
			break
		}
	}
	return result
}

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

/*********** DP sub-functions ***********/

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// ChMax accepts a pointer of integer and a target value.
// If target value is LARGER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMax(updatedValue *int, target int) bool {
	if *updatedValue < target {
		*updatedValue = target
		return true
	}
	return false
}

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

// Max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return m
}

// Min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func Min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// Sum returns multiple integers sum.
func Sum(integers ...int) int {
	s := 0

	for _, i := range integers {
		s += i
	}

	return s
}

// PowInt is integer version of math.Pow
// PowInt calculate a power by Binary Power (二分累乗法(O(log e))).
func PowInt(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := PowInt(a, halfE)
		return half * half
	}

	return a * PowInt(a, e-1)
}

// AbsInt is integer version of math.Abs
func AbsInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		// str := strconv.FormatInt(A[i], 10)  // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

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

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

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

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var t int

func main() {
	t = ReadInt()

	for i := 0; i < t; i++ {
		n := ReadInt()
		P := ReadIntSlice(n)
		m := ReadInt()
		Q := ReadIntSlice(m)

		// PP := make([]int, n)
		// QQ := make([]int, m)
		// for j := 0; j < n; j++ {
		// }
		peven := 0
		qeven := 0
		for j := 0; j < n; j++ {
			if P[j]%2 == 0 {
				peven++
			}
		}
		for j := 0; j < m; j++ {
			if Q[j]%2 == 0 {
				qeven++
			}
		}

		ans := peven*qeven + (n-peven)*(m-qeven)

		fmt.Println(ans)
	}
}

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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

package main

import "fmt"
func check(p int, q int) bool{
	var status bool
	if (p-q)%2 == 0 {
		status = true
	}
	return status
}
func input() ( []int)   {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for j := 0; j < n; j++ {
		fmt.Scan(&arr[j])
	}
	return arr

}
func main(){
	var t, count int
	count = 0
	fmt.Scan(&t)
	for i := 0; i < t; i ++ {
		p := input()
		q := input()
		for _, pi := range p {
			for _, qj := range q {
				if check(pi, qj) {
					count ++
				}
			}
		}
		fmt.Println(count)
	}
}

package main

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

func input() (int64, int64) {
	var n, even, odd int64
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	arr := make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(reader, &arr[i])
		if (arr[i]%2 == 0){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t int64
	fmt.Scan(&t)
	for i := int64(0); i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int64
		pEven, pOdd = input()
		qEven, qOdd = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

    package main

    import (
    	"bufio"
    	"fmt"
    	"os"
    )
    var (
    	reader *bufio.Reader
    )
    func input() (int64, int64) {
        odd := int64(0)
	    even := int64(0)
    	var n int64
    	reader = bufio.NewReader(os.Stdin)
    	fmt.Fscan(reader, &n)
    	arr := make([]int64, n)
    	for i := int64(0); i < n; i++ {
    		fmt.Fscan(reader, &arr[i])
    		if (arr[i]%2 == 0){
    			even++
    		}else {
    			odd++
    		}
    	}
    	return even, odd
    }
    func main(){
    	var t int64
    	reader = bufio.NewReader(os.Stdin)
    	fmt.Fscan(reader, &t)
    	for i := int64(0); i < t; i ++ {
    		var pEven, pOdd, qEven, qOdd int64
    		pEven, pOdd = input()
    		qEven, qOdd = input()
    		fmt.Println(pEven*qEven + pOdd*qOdd)
    	}
    }

package main

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

func check(p int) bool{
	if p%2 == 0 {
		return true
	}
	return false
}
func input() (int, int) {
	var n, even, odd int
	reader := bufio.NewReader(os.Stdin)
	fmt.Scan(&n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &arr[i])
		if check(arr[i]){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t, count int
	fmt.Scan(&t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		pEven, pOdd = input()
		qEven, qOdd = input()
		count = pEven*qEven + pOdd*qOdd
		fmt.Println(count)
	}
}

package main

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

func check(p int) bool{
	if p%2 == 0 {
		return true
	}
	return false
}

func numbers(s string) []int {
	var n []int
	for _, f := range strings.Fields(s) {
		i, err := strconv.Atoi(f)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}

func input() (int, int) {
	var n, even, odd, tmp int
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &tmp)
		if check(tmp){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t int
	fmt.Scan(&t)
	reader := bufio.NewReader(os.Stdin)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		var count int64
		var n, tmp int
		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &tmp)
			if check(tmp){
				pEven++
			}else {
				pOdd++
			}
		}

		for i := 0; i < n; i++ {
			fmt.Fscan(reader, &tmp)
			if check(tmp){
				qEven++
			}else {
				qOdd++
			}
		}

		//pEven, pOdd = input()
		//qEven, qOdd = input()
		count = int64(pEven*qEven) + int64(pOdd*qOdd)
		fmt.Println(count)
	}
}

package main

import (
	"fmt"
)

func check(p int) bool{
	var status bool
	if p%2 == 0 {
		status = true
	} else {
		status = false
	}
	return status
}
func input() ( []int)   {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for j := 0; j < n; j++ {
		fmt.Scan(&arr[j])
	}
	return arr

}
func main(){
	var t, even, odd, count int
	even = 0
	odd = 0
	fmt.Scan(&t)
	for i := 0; i < t; i ++ {
		p := input()
		q := input()
		for _, pi := range p {
			if check(pi){
				even ++
			}else {
				odd ++
			}
		}
		for _, qj := range q {
			if check(qj){
				even ++
			}else {
				odd ++
			}
		}
		count = even/2 + odd/2
		fmt.Println(count)
	}
}

package main

import (
	"fmt"
)

func check(p int) bool{
	var status bool
	if p%2 == 0 {
		status = true
	} else {
		status = false
	}
	return status
}
func input() ( []int)   {
	var n int
	fmt.Scan(&n)
	arr := make([]int, n)
	for j := 0; j < n; j++ {
		fmt.Scan(&arr[j])
	}
	return arr

}
func main(){
	var t, even, odd, count int
	even = 0
	odd = 0
	fmt.Scan(&t)
	for i := 0; i < t; i ++ {
		p := input()
		q := input()
		for _, pi := range p {
			if check(pi){
				even ++
			}else {
				odd ++
			}
		}
		for _, qj := range q {
			if check(qj){
				even ++
			}else {
				odd ++
			}
		}
		count = even/2 + odd/2
		fmt.Println(count)
		even = 0
		odd = 0
	}
}

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

func check(p int) bool{
	var status bool
	if p%2 == 0 {
		status = true
	} else {
		status = false
	}
	return status
}
func input() []int {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &arr[i])
	}
	return arr
}
func main(){
	var t, count int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		p := input()
		q := input()
		for _, pi := range p {
			if check(pi){
				pEven++
			}else {
				pOdd++
			}
		}
		for _, qj := range q {
			if check(qj){
				qEven++
			}else {
				qOdd++
			}
		}
		count = pEven*qEven + pOdd*qOdd
		fmt.Println(count)
	}
}

package main

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

func check(p int) bool{
	if p%2 == 0 {
		return true
	}
	return false
}

func numbers(s string) []int {
	var n []int
	for _, f := range strings.Fields(s) {
		i, err := strconv.Atoi(f)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}

func input() (int, int) {
	var n, even, odd, tmp int
	fmt.Scan(&n)
	reader := bufio.NewReader(os.Stdin)

	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &tmp)
		fmt.Println("WTF NGU HOC", tmp)
		if check(tmp){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		var count int64
		pEven, pOdd = input()
		qEven, qOdd = input()
		count = int64(pEven*qEven) + int64(pOdd*qOdd)
		fmt.Println(count)
	}
}

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

func check(p int) bool{
	var status bool
	if p%2 == 0 {
		status = true
	} else {
		status = false
	}
	return status
}
func input() []int {
	reader := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(reader, &n)
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &arr[i])
	}
	return arr
}
func main(){
	var t, count int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		p := input()
		q := input()
		for _, pi := range p {
			if check(pi){
				pEven++
			}else {
				pOdd++
			}
		}
		for _, qj := range q {
			if check(qj){
				qEven++
			}else {
				qOdd++
			}
		}
		count = pEven*qEven + pOdd*qOdd
		fmt.Println(count)
	}
}

package main

import (
	"bufio"
	"fmt"
	"os"
)
var (
	reader *bufio.Reader
)
func input() (int64, int64) {
	var n, even, odd int64
	reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	arr := make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(reader, &arr[i])
		if (arr[i]%2 == 0){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t int64
	reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)
	for i := int64(0); i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int64
		pEven, pOdd = input()
		qEven, qOdd = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

import (
	"fmt"
	"strconv"
	"strings"
)

func check(p int) bool{
	if p%2 == 0 {
		return true
	}
	return false
}

func numbers(s string) []int {
	var n []int
	for _, f := range strings.Fields(s) {
		i, err := strconv.Atoi(f)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}

func input() (int, int) {
	fmt.Println("-----------------------------------------")
	var n, even, odd, tmp int
	fmt.Scan(&n)
	fmt.Println("NGIU DEO CHIU", n)
	for i := 0; i < n; i++ {
		fmt.Scan(tmp)
		fmt.Println("WTF NGU HOC", tmp)
		if check(tmp){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		var count int64
		pEven, pOdd = input()
		qEven, qOdd = input()
		count = int64(pEven*qEven) + int64(pOdd*qOdd)
		fmt.Println(count)
	}
}

package main

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

func check(p int) bool{
	if p%2 == 0 {
		return true
	}
	return false
}

func numbers(s string) []int {
	var n []int
	for _, f := range strings.Fields(s) {
		i, err := strconv.Atoi(f)
		if err == nil {
			n = append(n, i)
		}
	}
	return n
}

func input() (int, int) {
	fmt.Println("NGIU DEO CHIU DUOC")
	var n, even, odd, tmp int
	fmt.Scan(&n)
	reader := bufio.NewReader(os.Stdin)
	fmt.Println("NGIU DEO CHIU", n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &tmp)
		fmt.Println("WTF NGU HOC", tmp)
		if check(tmp){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t int
	fmt.Scan(&t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		var count int64
		pEven, pOdd = input()
		qEven, qOdd = input()
		count = int64(pEven*qEven) + int64(pOdd*qOdd)
		fmt.Println(count)
	}
}

package main

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

func input() (int64, int64) {
	var n, even, odd int64
	reader := bufio.NewReader(os.Stdin)
	fmt.Scan(&n)
	arr := make([]int64, n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(reader, &arr[i])
		if (arr[i]%2 == 0){
			even++
		}else {
			odd++
		}
	}
	return even, odd
}
func main(){
	var t int64
	fmt.Scan(&t)
	for i := int64(0); i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int64
		pEven, pOdd = input()
		qEven, qOdd = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

    package main

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

    func input() (int64, int64) {
    	var n, even, odd int64
    	reader := bufio.NewReader(os.Stdin)
    	fmt.Fscan(reader, &n)
    	arr := make([]int64, n)
    	for i := int64(0); i < n; i++ {
    		fmt.Fscan(reader, &arr[i])
    		if (arr[i]%2 == 0){
    			even++
    		}else {
    			odd++
    		}
    	}
    	return even, odd
    }
    func main(){
    	var t int64
    	reader := bufio.NewReader(os.Stdin)
    	fmt.Fscan(reader, &t)
    	for i := int64(0); i < t; i ++ {
    		var pEven, pOdd, qEven, qOdd int64
    		pEven, pOdd = input()
    		qEven, qOdd = input()
    		fmt.Println(pEven*qEven + pOdd*qOdd)
    	}
    }

package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	t := readi()
	for i := 0; i < t; i++ {
		n := readi()
		p := make([]int, n)
		for i := range p {
			p[i] = readi()
		}
		m := readi()
		q := make([]int, m)
		for i := range q {
			q[i] = readi()
		}
		println(solve(n, m, p, q))

	}
}

func solve(n, m int, p, q []int) int {
	var pe, qe, po, qo int
	for _, v := range p {
		if v%2 == 0 {
			pe++
		}
	}
	po = n - pe
	for _, v := range q {
		if v%2 == 0 {
			qe++
		}
	}
	qo = m - qe

	return pe*qe + po*qo
}

package main

import (
	"fmt"
)

func main() {
	var numOfTestCase int64
	fmt.Scan(&numOfTestCase)
	for i := 0; int64(i) < numOfTestCase; i++ {
		var n int64
		var tmp int64
		var x1, y1 int64
		var x2, y2 int64

		fmt.Scanf("%d", &n)
		for j := 0; int64(j) < n; j++ {
			fmt.Scanf("%d", &tmp)
			if tmp % 2 == 0 {
			 	x1++
				continue
			}
			y1++
		}

		fmt.Scanf("%d", &n)
		for j := 0; int64(j) < n; j++ {
			fmt.Scanf("%d", &tmp)
			if tmp % 2 == 0 {
			 	x2++
				continue
			}
			y2++
		}
		fmt.Println(x1*x2+y1*y2)
	}

}

package main

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

var (
	reader *bufio.Reader
)

func input() (int, int) {
	odd := 0
	even := 0

	var n int
	fmt.Fscan(reader, &n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Fscan(reader, &x)
		if x % 2 == 0 {
			even++
			continue
		}
		odd++
	}
	return odd, even
}
func main(){
	reader = bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(reader, &t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		pOdd, pEven = input()
		qOdd, qEven = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

import "fmt"

func input() (int, int) {
	odd := 0
	even := 0

	var n int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scanf("%d", &x)
		if x % 2 == 0 {
			even++
			continue
		}
		odd++
	}
	return odd, even
}
func main(){
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		pOdd, pEven = input()
		qOdd, qEven = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

import "fmt"

func input() (int, int) {
	odd := 0
	even := 0

	var n int
	var x int
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &x)
		if x % 2 == 0 {
			even++
			continue
		}
		odd++
	}
	return odd, even
}
func main(){
	var t int
	fmt.Scanf("%d", &t)
	for i := 0; i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int
		pOdd, pEven = input()
		qOdd, qEven = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

import "fmt"

func input() (int64, int64) {
	odd := int64(0)
	even := int64(0)

	var n int
	var x int64
	fmt.Scanf("%d", &n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &x)
		if x % 2 == 0 {
			even++
			continue
		}
		odd++
	}
	return odd, even
}
func main(){
	var t int64
	fmt.Scanf("%d", &t)
	for i := int64(0); i < t; i ++ {
		var pEven, pOdd, qEven, qOdd int64
		pOdd, pEven = input()
		qOdd, qEven = input()
		fmt.Println(pEven*qEven + pOdd*qOdd)
	}
}

package main

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

var (
	reader *bufio.Reader
)

func countOddAndEven(c chan int64) {
	var odd, even, n, tmp int64
	fmt.Fscan(reader, &n)
	for i := int64(0); i < n; i++ {
		fmt.Fscan(reader, &tmp)
		if tmp%2 == 0 {
			even++
		} else {
			odd++
		}
	}

	c <- odd
	c <- even
	close(c)
}

func main() {

	var t int64
	reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &t)

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

		var oddD, evenD, oddJ, evenJ int64

		c1 := make(chan int64)
		c2 := make(chan int64)

		go countOddAndEven(c1)
		go countOddAndEven(c2)

		oddD, evenD = <-c1, <-c1
		oddJ, evenJ = <-c2, <-c2

		fmt.Println(oddD*oddJ + evenD*evenJ)
	}
}


package main

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

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

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

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

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

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

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

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		printf("%d\n", sol(n, a))
	}
}

func sol(n int64, a []int64) int64 {
	tmp := append(a, a...)
	st := BuildSparseTable(tmp, gcd)
	ans := n * 2
	l, r := int64(1), n*2
	for l <= r {
		m := (l + r) / 2
		// printf("l=%d r=%d m=%d\n", l, r, m)
		if possible(st, n*2, m) {
			ans = min(ans, m-1)
			r = m - 1
		} else {
			l = m + 1
		}
	}
	return ans
}

func possible(st SparseTable, n, m int64) bool {
	target := st.Query(0, m-1)
	for i := int64(1); i+m-1 < n; i++ {
		if st.Query(i, i+m-1) != target {
			return false
		}
	}
	return true
}

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

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	if a < 0 {
		a *= -1
	}
	return a
}

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

type SparseTable struct {
	vals [][]int64
	agg  func(int64, int64) int64
}

func BuildSparseTable(a []int64, agg func(int64, int64) int64) SparseTable {
	st := SparseTable{
		vals: [][]int64{a},
		agg:  agg,
	}
	prevRow := a
	for pow2 := 1 << 1; pow2 < len(a); pow2 <<= 1 {
		row := make([]int64, len(a)-pow2+1)
		for i := range row {
			row[i] = st.agg(prevRow[i], prevRow[i+pow2/2])
		}
		st.vals = append(st.vals, row)
		prevRow = row
	}
	return st
}

func (st SparseTable) Query(l, r int64) int64 {
	row := 0
	size := int64(1)
	for size<<1 < r-l+1 {
		row++
		size <<= 1
	}
	return st.agg(st.vals[row][l], st.vals[row][r-size+1])
}

package main

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

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

func main() {
	sc := NewScanner()
	wr := bufio.NewWriter(os.Stdout)
	defer wr.Flush()

	TC := sc.NextInt()
	for tc := 0; tc < TC; tc++ {
		N := sc.NextInt()
		arr := sc.NextInts(N)
		arr = append(arr, arr...)

		ans := 0
		for i := 0; i < N; i++ {
			x := arr[i]
			y := arr[i+1]
			gap := 0
			for x != y {
				gap++
				x = getGcd(x, arr[i+gap])
				y = getGcd(y, arr[i+1+gap])
			}
			ans = Max(ans, gap)
		}
		fmt.Fprintln(wr, ans)

	}

}

type Scanner struct {
	bScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bScanner := bufio.NewScanner(os.Stdin)
	bScanner.Split(bufio.ScanWords)
	bScanner.Buffer([]byte{}, math.MaxInt32)
	return &Scanner{
		bScanner,
	}
}
func (s *Scanner) Next() string {
	s.bScanner.Scan()
	return s.bScanner.Text()
}
func (s *Scanner) NextInt() int {
	s.bScanner.Scan()
	res, err := strconv.Atoi(s.bScanner.Text())
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInt64() int64 {
	s.bScanner.Scan()
	res, err := strconv.ParseInt(s.bScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextFloat() float64 {
	s.bScanner.Scan()
	res, err := strconv.ParseFloat(s.bScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return res
}
func (s *Scanner) NextInts(N int) []int {
	res := make([]int, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt()
	}
	return res
}
func (s *Scanner) NextInt64s(N int) []int64 {
	res := make([]int64, N)
	for i := 0; i < N; i++ {
		res[i] = s.NextInt64()
	}
	return res
}
func Min(num int, nums ...int) int {
	ans := num
	for _, num := range nums {
		if num < ans {
			ans = num
		}
	}
	return ans
}
func Max(num int, nums ...int) int {
	ans := num
	for _, num := range nums {
		if num > ans {
			ans = num
		}
	}
	return ans
}

func InitInts1D(n int, val int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = val
	}
	return res
}
func InitInts2D(n, m int, val int) [][]int {
	res := make([][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts1D(m, val)
	}
	return res
}
func InitInts3D(n, m, k int, val int) [][][]int {
	res := make([][][]int, n)
	for i := 0; i < n; i++ {
		res[i] = InitInts2D(m, k, val)
	}
	return res
}

type StepState struct {
	step, dist int
}
type PriorityQueue []*StepState

func (pq PriorityQueue) Len() int { return len(pq) }
func (pq PriorityQueue) Less(i, j int) bool {
	if pq[i].step != pq[j].step {
		return pq[i].step < pq[j].step
	}
	return pq[i].dist < pq[j].dist
}
func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
}
func (pq *PriorityQueue) Push(x interface{}) {
	item := x.(*StepState)
	*pq = append(*pq, item)
}
func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	*pq = old[0 : n-1]
	return item
}

package main

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

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

	var T, n int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		for i := range a {
			Fscan(in, &a[i])
		}
		ans := 0
		for i, x := range a {
			y := a[(i+1)%n]
			j := i
			for ; x != y; j++ {
				x = gcd(x, a[(j+1)%n])
				y = gcd(y, a[(j+2)%n])
			}
			if j-i > ans {
				ans = j - i
			}
		}
		Fprintln(out, ans)
	}
}

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

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

package main

import (
	"bufio"
	//	"container/heap" for heap.Init()
	"fmt"
	"os"
	"runtime"
)

func check(b bool) {
	if !b {
		_, _, line, _ := runtime.Caller(1)
		fmt.Printf("check failed line %d\n", line)
		os.Exit(-1)
	}
}

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

type IntHeap []int

func (h IntHeap) Len() int            { return len(h) }
func (h IntHeap) Less(i, j int) bool  { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *IntHeap) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

const (
	INIT  = -1
	MAX_A = 1000002
)

var (
	n      int
	arr    []int
	sieve  []int
	primes []int
	exists = struct{}{}
)

func pre() {
	sieve = make([]int, MAX_A)
	sieve[1] = 1
	var i, j int64 // int32 on win32
	for i = 2; i < MAX_A; i++ {
		if sieve[i] == 0 {
			sieve[i] = int(i)
			primes = append(primes, int(i))

			for j = i; i*j < MAX_A; j++ {
				sieve[i*j] = int(i)
			}
		}
	}

	// for i := 1; i < 50; i++ {
	// 	fmt.Printf("sieve[%d] %d\n", i, sieve[i])
	// }
}

func gcd(a, b int) int {
	for a > 0 {
		tmp := a
		a = b % a
		b = tmp
	}
	return b
}

func solve() int {
	pf := make([]map[int]struct{}, n)
	for i := 0; i < n; i++ {
		pf[i] = make(map[int]struct{})
		t := arr[i]
		for t > 1 {
			pf[i][sieve[t]] = exists
			t /= sieve[t]
		}
	}

	ans := 0
	for i := 0; i < n; i++ {
		for p := range pf[i] {

			cnt := 1
			j := (n + i - 1) % n
			for {
				if _, ok := pf[j][p]; ok {
					delete(pf[j], p)
					cnt++
					j = (n + j - 1) % n
				} else {
					break
				}
			}

			j = (i + 1) % n
			for {
				if _, ok := pf[j][p]; ok {
					delete(pf[j], p)
					cnt++
					j = (j + 1) % n
				} else {
					break
				}
			}

			delete(pf[i], p)

			if ans < cnt {
				ans = cnt
			}
		}
	}

	return ans
}

func main() {
	pre()

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

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

	for ; tc > 0; tc-- {
		fmt.Fscan(r, &n)

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

		com := arr[0]
		for i := 1; i < n; i++ {
			com = gcd(com, arr[i])
		}

		for i := 0; i < n; i++ {
			arr[i] /= com
		}

		fmt.Println(solve())
	}
}

package main

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

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

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

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

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

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

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

func main() {
	defer writer.Flush()
	for t := sint64(); t > 0; t-- {
		n := sint64()
		a := sint64s(n)
		printf("%d\n", sol(n, a))
	}
}

func sol(n int64, a []int64) int64 {
	p := int64(0)
	maxSoFar := int64(0)
	for p < n {
		curr := a[p]
		for offset := int64(1); offset < n; offset++ {
			nxtp := (p + offset) % n
			if curr == a[nxtp] {
				maxSoFar = max(maxSoFar, offset-1)
				p += offset
				break
			}
			if offset == n-1 {
				return n - 1
			}
			if curr == 1 {
				p++
				break
			}
			curr = gcd(curr, a[nxtp])
		}
	}
	return maxSoFar
}

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	if a < 0 {
		a *= -1
	}
	return a
}

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


package main

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

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

	var n int
	var q int
	fmt.Fscan(r, &n, &q)
	grid := make([][]int, 2)
	grid[0] = make([]int, n)
	grid[1] = make([]int, n)
	blocked := 0
	for ; q > 0; q-- {
		var y int
		var x int
		fmt.Fscan(r, &y, &x)
		y--
		x--
		grid[y][x] = 1 - grid[y][x]
		ny := 1 - y
		for dx := -1; dx <= 1; dx++ {
			nx := x + dx
			if ny < 0 || nx < 0 || ny >= 2 || nx >= n || grid[ny][nx] == 0 {
				continue
			}
			switch grid[y][x] {
			case 1:
				blocked++
			case 0:
				blocked--
			}
		}
		switch blocked {
		case 0:
			fmt.Fprintln(w, "Yes")
		default:
			fmt.Fprintln(w, "No")
		}
	}
}

package main

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

func checkOpenRoute(x int, y int) bool {
	var prefix int
	if check[x][y] {
		prefix = 1
	} else {
		prefix = -1
	}
	sum += (getCellParams(1 - x, y - 1) + getCellParams(1 - x, y) + getCellParams(1 - x, y + 1)) * prefix
	check[x][y] = !check[x][y]
	if sum >= 0 {
		return true
	} else {
		return false
	}
}

func getCellParams(x int, y int) int {
	if y < 0 { return 0 }
	if y == n { return 0 }
	if check[x][y] {
		return 1
	} else {
		return 0
	}
}

var check = make([][]bool, 2)
var sum = 0
var n, k int
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var x, y int
	fmt.Fscan(in, &n, &k)
	check[0] = make([]bool, n)
	check[1] = make([]bool, n)
	for i :=0; i < k; i++ {
		fmt.Fscan(in, &x, &y)
		if checkOpenRoute(x - 1, y - 1) {
			fmt.Fprintln(out, "Yes")
		} else {
			fmt.Fprintln(out, "No")
		}
	}
}

package main

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

//=====I/O=====

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

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

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

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪func•*¨*•.¸¸♪

//•*¨*•.¸¸♪main•*¨*•.¸¸♪

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	q := scanInt()

	// g := make([][]int, 2)
	// g[0] = make([]int, n)
	// g[1] = make([]int, n)

	f := make([][]bool, 2)
	f[0] = make([]bool, n)
	f[1] = make([]bool, n)

	cnt := 0
	for i := 0; i < q; i++ {
		r := scanInt()-1
		c := scanInt()-1

		if f[r][c] {
			ch := 0
			if f[1-r][c] {
				ch++
			}
			if c>0&&f[1-r][c-1] {
				ch++
			}
			if c<n-1&&f[1-r][c+1] {
				ch++
			}

			cnt-=ch

			f[r][c] = false
		} else {
			ch := 0
			if f[1-r][c] {
				ch++
			}
			if c>0&&f[1-r][c-1] {
				ch++
			}
			if c<n-1&&f[1-r][c+1] {
				ch++
			}

			cnt+=ch

			// g[r][c] = c

			f[r][c] = true
		}

		if cnt==0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}

		// fmt.Println(f[0])
		// fmt.Println(f[1])
		// fmt.Println(cnt)
	}
}

package main

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

type points struct {
	y1 int
	x1 int
	y2 int
	x2 int
}

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

	var n int
	var q int
	fmt.Fscan(r, &n, &q)
	grid := make([][]int, 2)
	grid[0] = make([]int, n)
	grid[1] = make([]int, n)
	blockers := make(map[points]bool)
	for ; q > 0; q-- {
		var y int
		var x int
		fmt.Fscan(r, &y, &x)
		y--
		x--
		grid[y][x] = 1 - grid[y][x]
		ny := 1 - y
		for dx := -1; dx <= 1; dx++ {
			nx := x + dx
			if ny < 0 || nx < 0 || ny >= 2 || nx >= n || grid[ny][nx] == 0 {
				continue
			}
			switch grid[y][x] {
			case 1:
				blockers[points{y, x, ny, nx}] = true
			case 0:
				delete(blockers, points{y, x, ny, nx})
				delete(blockers, points{ny, nx, y, x})
			}
		}
		switch len(blockers) {
		case 0:
			fmt.Fprintln(w, "Yes")
		default:
			fmt.Fprintln(w, "No")
		}
	}
}

package main

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

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

	var n int
	var q int
	fmt.Fscan(r, &n, &q)
	grid := make([][]int, 2)
	grid[0] = make([]int, n)
	grid[1] = make([]int, n)
	di := []int{-1, -1, -1, 1, 1, 1}
	dj := []int{-1, 0, 1, -1, 0, 1}
	blocked := 0
	for ; q > 0; q-- {
		var i int
		var j int
		fmt.Fscan(r, &i, &j)
		i--
		j--
		grid[i][j] = 1 - grid[i][j]
		for d := 0; d < 6; d++ {
			ni := i + di[d]
			nj := j + dj[d]
			if ni < 0 || nj < 0 || ni >= 2 || nj >= n || grid[ni][nj] == 0 {
				continue
			}
			switch grid[i][j] {
			case 1:
				blocked++
			case 0:
				blocked--
			}
		}
		switch blocked {
		case 0:
			fmt.Fprintln(w, "Yes")
		default:
			fmt.Fprintln(w, "No")
		}
	}
}

package main

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

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

func main(){
	defer writer.Flush()
	var n,q,r,c int
	var state [2][100010]bool
	var block [100010]bool
	var conn [100010]int
	scanf("%d%d\n",&n,&q)
	cnt:=0
	for ;q>0;q--{
		scanf("%d%d\n",&r,&c)
		if r==1{
			if state[0][c] {
				if block[c]{
					block[c]=false
					cnt--
				}
			}else{
				if conn[c]>0 {
					if(!block[c]){
						block[c]=true
						cnt++
					}
				}
			}
			state[0][c]=!state[0][c]
		}else{
			if state[1][c]{
				for i:=-1;i<=1;i++{
					if c+i>0 && c+i<=n {
						conn[c+i]--
						if conn[c+i]==0 && block[c+i]{
							block[c+i]=false
							cnt--
						}
					}
				}
			}else{
				for i:=-1;i<=1;i++{
					if c+i>0 && c+i<=n {
						conn[c+i]++
						if conn[c+i]==1 && state[0][c+i] && !block[c+i]{
							block[c+i]=true
							cnt++
						}
					}
				}
			}
			state[1][c]=!state[1][c]
		}
		if cnt>0 {printf("No\n")}else{printf("Yes\n")}
	}
}

package main

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

//=====I/O=====

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

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

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

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

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪func•*¨*•.¸¸♪

//•*¨*•.¸¸♪main•*¨*•.¸¸♪

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	n := scanInt()
	q := scanInt()

	// g := make([][]int, 2)
	// g[0] = make([]int, n)
	// g[1] = make([]int, n)

	f := make([][]bool, 2)
	f[0] = make([]bool, n)
	f[1] = make([]bool, n)

	cnt := 0
	for i := 0; i < q; i++ {
		r := scanInt()-1
		c := scanInt()-1

		if f[r][c] {
			ch := 0
			if f[1-r][c] {
				ch++
			}
			if c>0&&f[1-r][c-1] {
				ch++
			}
			if c<n-1&&f[1-r][c+1] {
				ch++
			}
			if ch>0 {
				cnt--
			}

			f[r][c] = false
		} else {
			ch := 0
			if f[1-r][c] {
				ch++
			}
			if c>0&&f[1-r][c-1] {
				ch++
			}
			if c<n-1&&f[1-r][c+1] {
				ch++
			}
			if ch>0 {
				cnt++
			}

			// g[r][c] = c

			f[r][c] = true
		}

		if cnt==0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}

		// fmt.Println(f[0])
		// fmt.Println(f[1])
		// fmt.Println(cnt)
	}
}


package main

import "fmt"

func main() {
	var n, k uint8
	var b []byte
	var i uint8

	fmt.Scanf("%d %d", &n, &k)

	b = make([]byte, n)

	for i = uint8(0); i < k; i++ {
		b[i] = i + 97
	}
	for ; i < n; i++ {
		b[i] = b[i%k]
	}

	fmt.Println(string(b))

}

package main

import (
	"fmt"
	"math/rand"
	"time"
)

func main() {
	var n, k uint8
	var b []byte
	var i uint8
	var r *rand.Rand
	var seedIndex int
	var tmp []int
	var before byte

	fmt.Scanf("%d %d", &n, &k)

	b = make([]byte, n)
	tmp = make([]int, 26)

	r = rand.New(rand.NewSource(time.Now().UnixNano()))

	i = uint8(0)

	for i < k {
		seedIndex = r.Intn(26)
		if tmp[seedIndex] == 1 {
			continue
		}
		tmp[seedIndex] = 1
		b[i] = byte(seedIndex) + 97
		i++
	}
	before = b[k-1]
	for i < n {
		seedIndex = r.Intn(int(k))
		// fmt.Println(i, seedIndex)
		if b[seedIndex%int(k)] == before {
			continue
		}
		b[i] = b[seedIndex%int(k)]
		before = b[i]
		i++
	}

	fmt.Println(string(b))

}

package main

import "fmt"

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	var pass string
	start := 97
	l := 0
	for i := 0; i < n; i++ {
		if l == k {
			l = 0
		}
		pass += string(rune(start + l))
		l++
	}
	fmt.Println(pass)
}

package main

import (
	"fmt"
)

func main() {
	var alphabet = []string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	var n, k int
	fmt.Scanln(&n, &k)

	letters := alphabet[:k]

	var ans string

	for i := 0; i < n; i++ {
		tempIndex := i
		for {
			if tempIndex < len(letters) {
				ans += letters[tempIndex]
				break
			} else {
				tempIndex -= len(letters)
			}
		}
	}

	fmt.Println(ans)
}

package main
import (
	"fmt"
	"strings"
)
func main() {
	var n, k int
	fmt.Scan(&n,&k)
	var str strings.Builder
	for i := 0; i < n; i++{
		str.WriteString(string((i%k)+97))
	}
	fmt.Println(str.String()[0:n])
}

package main
import (
	"fmt"
	"strings"
)
func main() {
	var n, k int
	fmt.Scan(&n,&k)
	var str strings.Builder
	for i := 0; i < n; i++{
		if i < k {
			str.WriteString(string((i)+97))
		}else{
			str.WriteString(str.String()[0:k])
		}
	}
	fmt.Println(str.String()[0:n])
}

package main

import (
  "fmt"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	baseCharCode := 97
	for i := 0; i < n; i++ {
		fmt.Print(string(baseCharCode + (i % k)))
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, k int
	dict := "abcdefghijklmnopqrstuvwxyz"
	fmt.Scan(&n, &k)
	newDict := dict[:k]
	result := ""
	j := 0
	for i := 0; i < n; i++ {
		if j >= k {
			j = 0
		}
		result += string(newDict[j])
		j++
	}
	fmt.Println(result)
}

package main

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

func main() {
	var n, k int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &k)
	var arr = [...]string{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}
	for index := 0; index < k; index++ {
		fmt.Print(arr[index])
	}
	wordlength := k
	for index := 1; index < n-k+1; index++ {
		fmt.Print(arr[index-1])
		wordlength++
		if index == k {
			index = 0

		}
		if wordlength == n {
			break
		}
	}
}

package main

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

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

	var n, k int
	fmt.Fscan(r, &n, &k)
	a := make([]byte, n)
	for i := 0; i < n;{
		for j := 0; j < k && i < n; j, i = j + 1, i + 1 {
			a[i] = 'a' + byte(j)
		}
	}
	fmt.Fprintln(w, string(a))
}

package main

import "fmt"

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	var pass string
	start := 'a'
	l := k
	for i := 0; i < n; i++ {
		if l == 0 {
			l = k
		}
		pass += string(start + rune(l))
		l--
	}
	fmt.Println(pass)
}

package main
import (
	"fmt"
	"strings"
    "math/rand"
)
func main() {
	var n, k int
	fmt.Scan(&n,&k)
	var str strings.Builder
	for j := 0; j < n; j++{
		str.WriteString(string(rand.Intn(k)+97))
	}
	fmt.Println(str.String())
}

package main
import (
	"fmt"
	"strings"
)
func main() {
	var n, k int
	fmt.Scan(&n,&k)
	var str strings.Builder
	var ss string
	for i := 0; i < n; i++{
		if i < k {
			str.WriteString(string((i)+97))
			ss = string((i)+97)
		}else{
			str.WriteString(ss)
		}
	}
	fmt.Println(str.String())
}

package main
import (
	"fmt"
	"strings"
)
func main() {
	var n, k int
	fmt.Scan(&n,&k)
	var str strings.Builder
	for i := 0; i < n; i++{
		if i < k {
			str.WriteString(string((i)+97))
		}else{
			str.WriteString(string(str.String()[0]))
		}
	}
	fmt.Println(str.String())
}

package main

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

func main() {
	var n, k int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &k)
	var arr = [...]string{"a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "l", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "z", "x", "c", "v", "b", "n", "m"}
	for index := 0; index < k; index++ {
		fmt.Print(arr[index])
	}
	wordlength := k
	for index := 1; index < n-k+1; index++ {
		fmt.Print(arr[index-1])
		wordlength++
		if index == k {
			index = 0

		}
		if wordlength == n {
			break
		}
	}
}

package main

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

func main() {
	var n, k int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &k)
	var arr = [...]string{"a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "l", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "z", "x", "c", "v", "b", "n", "m"}
	for index := 0; index < k; index++ {
		fmt.Print(arr[index])
	}
	wordlength := k
	for index := 1; index < n-k; index++ {
		fmt.Print(arr[index-1])
		wordlength++
		if index == k {
			index = 0

		}
		if wordlength == n {
			break
		}
	}
}

package main

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

func main() {
	var n, k int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &n)
	fmt.Fscan(reader, &k)
	var arr = [...]string{"a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "l", "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "z", "x", "c", "v", "b", "n", "m"}
	for index := 0; index < k; index++ {
		fmt.Print(arr[index])
	}
	for index := 0; index < n-k; index++ {
		fmt.Print(arr[index])
	}
}


package main

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

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscanln(in, &n)
	pos := map[int]int{}
	for i := 0; i < n; i++ {
		var part int
		fmt.Fscan(in, &part)
		pos[part] = i
	}
	ans := int64(0)
	for part := 2; part <= n; part++ {
		ans += int64(abs(pos[part] - pos[part - 1]))
	}
	fmt.Println(ans)
}

package main

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

func main() {
    stin := bufio.NewReader(os.Stdin)
    var n int
    fmt.Fscanln(stin, &n)
    var f [200000]int
    var p [200000]int64
    for i := 0; i < n; i++ {
        fmt.Fscan(stin, &f[i])
    }

    for i := 0; i < n; i++ {
        p[f[i]-1] = int64(i)
    }
    s := int64(0)
    for i := 1; i < n; i++ {
        //s += abs(p[i] - p[i-1])

        q := p[i] - p[i-1]
        if q > 0 {
            s += q
        } else {
            s -= q
        }
    }
    fmt.Printf("%v", s)
}

package main

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

//N _
const (
	N = 2*1e5 + 5
)

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

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

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

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	n , _ := strconv.ParseInt(*<-strs, 10, 64)

	a := make([]int64, n + 1)

	for i := int64(1); i < n + 1; i++ {
		x, _ := strconv.ParseInt(*<-strs, 10, 64)
		a[x] = i
	}

	tot := int64(0)

	for i := int64(1); i < n; i++ {
		tot += abs(a[i] - a[i + 1])
	}

	ws.WriteString(fmt.Sprint(tot))

	ws.Flush()
}

package main

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

func Abs(x int64) int64 {
	switch {
	case x < 0:
		return -x
	case x == 0:
		return 0 // return correctly abs(-0)
	}
	return x
}

func Scan(args ...interface{}) (e error)             { _, e = fmt.Fscan(in, args...); return }
func Scanf(ft string, args ...interface{}) (e error) { _, e = fmt.Fscanf(in, ft, args...); return }
func Scanln(args ...interface{}) (e error)           { _, e = fmt.Fscanln(in, args...); return }
func Print(args ...interface{})                      { out.WriteString(fmt.Sprint(args...)) }
func Printf(ft string, args ...interface{})          { out.WriteString(fmt.Sprintf(ft, args...)) }
func Println(args ...interface{})                    { out.WriteString(fmt.Sprintln(args...)) }

var (
	dataIn = "data.in"
	in     = bufio.NewReader(os.Stdin)
	//in, _ = os.Open(dataIn)
	out   = bufio.NewWriter(os.Stdout)
)

var n int
var loc []int

func read() {
	loc = make([]int, n)
	var sec int
	for i := 0; i < n; i++ {
		Scan(&sec)
		loc[sec-1] = i
	}
}

func solve() {
	ret := int64(0)
	for i := 0; i < n-1; i++ {
		ret += Abs(int64(loc[i] - loc[i+1]))
	}
	Println(ret)
}

func main() {
	defer out.Flush()
	for Scan(&n) != io.EOF {
		read()
		solve()
	}
	return
}

package main

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

func Abs(x int) int {
	switch {
	case x < 0:
		return -x
	case x == 0:
		return 0 // return correctly abs(-0)
	}
	return x
}

func Scan(args ...interface{}) (e error)             { _, e = fmt.Fscan(in, args...); return }
func Scanf(ft string, args ...interface{}) (e error) { _, e = fmt.Fscanf(in, ft, args...); return }
func Scanln(args ...interface{}) (e error)           { _, e = fmt.Fscanln(in, args...); return }
func Print(args ...interface{})                      { out.WriteString(fmt.Sprint(args...)) }
func Printf(ft string, args ...interface{})          { out.WriteString(fmt.Sprintf(ft, args...)) }
func Println(args ...interface{})                    { out.WriteString(fmt.Sprintln(args...)) }

var (
	dataIn = "data.in"
	in     = bufio.NewReader(os.Stdin)
	//in, _ = os.Open(dataIn)
	out   = bufio.NewWriter(os.Stdout)
)

var n int
var loc []int

func read() {
	loc = make([]int, n)
	var sec int
	for i := 0; i < n; i++ {
		Scan(&sec)
		loc[sec-1] = i
	}
}

func solve() {
	ret := 0
	for i := 0; i < n-1; i++ {
		ret += Abs(loc[i] - loc[i+1])
	}
	Println(ret)
}

func main() {
	defer out.Flush()
	for Scan(&n) != io.EOF {
		read()
		solve()
	}
	return
}

package main

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

var in = bufio.NewReader(os.Stdin)

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

func main() {
	var n int
	fmt.Fscanln(in, &n)
	pos := map[int]int{}
	for i := 0; i < n; i++ {
		var part int
		fmt.Fscan(in, &part)
		pos[part] = i
	}
	ans := 0
	for part := 2; part <= n; part++ {
		ans += abs(pos[part] - pos[part - 1])
	}
	fmt.Println(ans)
}