package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    t := nextInt()
    k := nextInt()
    d := make([][]int, 2)
    mod := 1000000007
    maxn := 100001
    d[0] = make([]int, maxn)
    d[1] = make([]int, maxn)
    d[0][k] = 1
    for i := 1; i <= k; i++ {
        d[1][i] = 1
    }
    for i := k + 1; i < maxn; i++ {
        d[1][i] = (d[0][i - 1] + d[1][i - 1]) % mod
        if d[1][i] < 0 {
            d[1][i] += mod
        }
        d[0][i] = (d[0][i - k] + d[1][i - k]) % mod
        if d[0][i] < 0 {
            d[0][i] += mod
        }
    }
    sum := make([]int, maxn)
    for i := 1; i < maxn; i++ {
        sum[i] = ((sum[i] + sum[i - 1]) % mod + (d[0][i] + d[1][i]) % mod) % mod
        if sum[i] < 0 {
            sum[i] += mod
        }
    }
    for T := 0; T < t; T++ {
        a := nextInt()
        b := nextInt()
        ans := sum[b] - sum[a - 1]
        if ans < 0 {
            ans += mod
        }
        fmt.Fprintln(out, ans)
    }
}

package main

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

type range_s struct {
	a int
	b int
}

func main() {
	var t, k int
	fmt.Scan(&t, &k)

	ranges := make([]range_s, t, t)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	max := 0
	for i := 0; i < t; i++ {
		bs.Scan()
		ranges[i].a, _ = strconv.Atoi(bs.Text())

		bs.Scan()
		ranges[i].b, _ = strconv.Atoi(bs.Text())

		if ranges[i].b > max {
			max = ranges[i].b
		}
	}

	// eg, k = 2
	// when len >= k, if last==R, pre i-1 can be R/W, if last==W, pre should have k-1 W
	// len1: R
	// len2: RR, WW -- last_R + last_W = dp[i-1] + dp[i-k]
	var modulo uint64
	modulo = 1000000007
	dp := make([]uint64, max+1, max+1)
	for i := 0; i < k; i++ {
		dp[i] = 1
	}
	for i := k; i <= max; i++ {
		dp[i] = (dp[i-1] + dp[i-k]) % modulo
	}

	for i := 1; i <= max; i++ {
		dp[i] = (dp[i] + dp[i-1]) % modulo
	}

	for i := 0; i < t; i++ {
		ans := (dp[ranges[i].b] - dp[ranges[i].a-1] + modulo) % modulo
		fmt.Println(ans)
	}
}

package main

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

func main() {
	var t, k int
	if _, err := fmt.Scanf("%d %d\n", &t, &k); err != nil {
		return
	}

	test_cases := make([][2]int, t)
	max := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < t; i++ {
		for j := 0; j < 2; j++ {
			scanner.Scan()
			a, err := strconv.Atoi(scanner.Text())
			if err != nil {
				return
			}
			test_cases[i][j] = a
			if a > max {
				max = a
			}
		}
	}

	const modulo int64 = 1000000007

	ways := make([]int64, max+1)
	ways[0] = 1
	for i := 1; i <= max; i++ {
		if k == 1 {
			ways[i] = (ways[i-1] * 2) % modulo
		} else {
			if i < k {
				ways[i] = int64(1)
			} else {
				ways[i] = ways[i-1] + ways[i-k]
			}
		}
		if ways[i] >= modulo {
			ways[i] -= modulo
		}
	}

	ways[0] = 0
	for i := 1; i <= max; i++ {
		ways[i] += ways[i-1]
		if ways[i] >= modulo {
			ways[i] -= modulo
		}
	}

	for i := 0; i < t; i++ {
		w := ways[test_cases[i][1]] - ways[test_cases[i][0]-1]
		if w < 0 {
			w += modulo
		}
		fmt.Println(w)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF474D(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod int64 = 1e9 + 7
	const mx int = 1e5

	var q, k, l, r int
	Fscan(in, &q, &k)
	dp := [mx + 1]int64{}
	for i := range dp {
		if i < k {
			dp[i] = 1
		} else {
			dp[i] = (dp[i-1] + dp[i-k]) % mod
		}
	}
	for i := 1; i <= mx; i++ {
		dp[i] += dp[i-1]
	}
	for ; q > 0; q-- {
		Fscan(in, &l, &r)
		Fprintln(out, (dp[r]-dp[l-1])%mod)
	}
}

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

package main

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

func main() {
	var t, k int
	if _, err := fmt.Scanf("%d %d\n", &t, &k); err != nil {
		return
	}

	test_cases := make([][2]int, t)
	max := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < t; i++ {
		for j := 0; j < 2; j++ {
			scanner.Scan()
			a, err := strconv.Atoi(scanner.Text())
			if err != nil {
				return
			}
			test_cases[i][j] = a
			if a > max {
				max = a
			}
		}
	}

	const modulo int64 = 1000000007

	ways := make([]int64, max+1)
	ways[0] = 1
	for i := 1; i <= max; i++ {
		if k == 1 {
			ways[i] = int64(math.Pow(float64(2), float64(i)))
		} else {
			if i < k {
				ways[i] = int64(1)
			} else {
				ways[i] = ways[i-1] + ways[i-k]
			}
		}
		if ways[i] >= modulo {
			ways[i] -= modulo
		}
	}

	ways[0] = 0
	for i := 1; i <= max; i++ {
		ways[i] += ways[i-1]
		if ways[i] >= modulo {
			ways[i] -= modulo
		}
	}

	for i := 0; i < t; i++ {
		w := ways[test_cases[i][1]] - ways[test_cases[i][0]-1]
		if w < 0 {
			w += modulo
		}
		fmt.Println(w)
	}
}

package main

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

func main() {
	var t, k int
	if _, err := fmt.Scanf("%d %d\n", &t, &k); err != nil {
		return
	}

	test_cases := make([][2]int, t)
	max := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < t; i++ {
		for j := 0; j < 2; j++ {
			scanner.Scan()
			a, err := strconv.Atoi(scanner.Text())
			if err != nil {
				return
			}
			test_cases[i][j] = a
			if a > max {
				max = a
			}
		}
	}

	const modulo int64 = 1000000007

	ways := make([]int64, max+1)
	ways[0] = 1
	for i := 1; i <= max; i++ {
		if k == 1 {
			ways[i] = int64(math.Pow(float64(2), float64(i)))
		} else {
			if i < k {
				ways[i] = int64(1)
			} else {
				ways[i] = ways[i-1] + ways[i-k]
			}
		}
	}

	ways[0] = 0
	for i := 1; i <= max; i++ {
		ways[i] += ways[i-1]
	}

	for i := 0; i < t; i++ {
		w := ways[test_cases[i][1]] - ways[test_cases[i][0]-1]
		if w >= modulo {
			w = w % modulo
		}
		fmt.Println(w)
	}
}

package main

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

func main() {
	var t, k int
	if _, err := fmt.Scanf("%d %d\n", &t, &k); err != nil {
		return
	}

	test_cases := make([][2]int, t)
	max := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < t; i++ {
		for j := 0; j < 2; j++ {
			scanner.Scan()
			a, err := strconv.Atoi(scanner.Text())
			if err != nil {
				return
			}
			test_cases[i][j] = a
			if a > max {
				max = a
			}
		}
	}

	const modulo int64 = 1000000007

	ways := make([]int64, max+1)
	ways[0] = 1
	for i := 1; i <= max; i++ {
		if k == 1 {
			ways[i] = int64(math.Pow(float64(2), float64(i)))
		} else {
			if i < k {
				ways[i] = int64(1)
			} else {
				ways[i] = ways[i-1] + ways[i-k]
			}
		}

		if ways[i] >= modulo {
			ways[i] -= modulo
		}
	}

	ways[0] = 0
	for i := 1; i <= max; i++ {
		ways[i] += ways[i-1]
	}

	for i := 0; i < t; i++ {
		w := ways[test_cases[i][1]] - ways[test_cases[i][0]-1]
		fmt.Println(w)
	}
}

package main

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

type range_s struct {
	a int
	b int
}

func main() {
	var t, k int
	fmt.Scan(&t, &k)

	ranges := make([]range_s, t, t)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	max := 0
	for i := 0; i < t; i++ {
		bs.Scan()
		ranges[i].a, _ = strconv.Atoi(bs.Text())

		bs.Scan()
		ranges[i].b, _ = strconv.Atoi(bs.Text())

		if ranges[i].b > max {
			max = ranges[i].b
		}
	}

	// eg, k = 2
	// when len >= k, if last==R, pre i-1 can be R/W, if last==W, pre should have k-1 W
	// len1: R
	// len2: RR, WW -- last_R + last_W = dp[i-1] + dp[i-k]
	dp := make([]uint64, max+1, max+1)
	for i := 0; i < k; i++ {
		dp[i] = 1
	}
	for i := k; i <= max; i++ {
		dp[i] = dp[i-1] + dp[i-k]
	}

	var modulo uint64
	modulo = 1000000007
	for i := 1; i <= max; i++ {
		dp[i] = (dp[i] + dp[i-1]) % modulo
	}

	for i := 0; i < t; i++ {
		ans := dp[ranges[i].b] - dp[ranges[i].a-1]
		if dp[ranges[i].b] < dp[ranges[i].a-1] {
			ans = modulo + dp[ranges[i].b] - dp[ranges[i].a-1]
		}
		fmt.Println(ans)
	}
}

package main

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

type range_s struct {
	a int
	b int
}

func main() {
	var t, k int
	fmt.Scan(&t, &k)

	ranges := make([]range_s, t, t)
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)

	max := 0
	for i := 0; i < t; i++ {
		bs.Scan()
		ranges[i].a, _ = strconv.Atoi(bs.Text())

		bs.Scan()
		ranges[i].b, _ = strconv.Atoi(bs.Text())

		if ranges[i].b > max {
			max = ranges[i].b
		}
	}

	// eg, k = 2
	// when len >= k, if last==R, pre i-1 can be R/W, if last==W, pre should have k-1 W
	// len1: R
	// len2: RR, WW -- last_R + last_W = dp[i-1] + dp[i-k]
	dp := make([]uint64, max+1, max+1)
	for i := 0; i < k; i++ {
		dp[i] = 1
	}
	for i := k; i <= max; i++ {
		dp[i] = dp[i-1] + dp[i-k]
	}

	var modulo uint64
	modulo = 1000000007
	for i := 1; i <= max; i++ {
		dp[i] = (dp[i] + dp[i-1]) % modulo
	}

	for i := 0; i < t; i++ {
		ans := dp[ranges[i].b] - dp[ranges[i].a-1]
		if ans < 0 {
			ans += modulo
		}
		fmt.Println(ans)
	}
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    t := nextInt()
    k := nextInt()
    d := make([][]int, 2)
    mod := 1000000007
    maxn := 100001
    d[0] = make([]int, maxn)
    d[1] = make([]int, maxn)
    d[0][k] = 1
    for i := 1; i <= k; i++ {
        d[1][i] = 1
    }
    for i := k + 1; i < maxn; i++ {
        d[1][i] = (d[0][i - 1] + d[1][i - 1]) % mod
        if d[1][i] < 0 {
            d[1][i] += mod
        }
        d[0][i] = (d[0][i - k] + d[1][i - k]) % mod
        if d[0][i] < 0 {
            d[0][i] += mod
        }
    }
    sum := make([]int, maxn)
    for i := 1; i < maxn; i++ {
        sum[i] = (sum[i] + sum[i - 1] + d[0][i] + d[1][i]) % mod
        if sum[i] < 0 {
            sum[i] += mod
        }
    }
    for T := 0; T < t; T++ {
        a := nextInt()
        b := nextInt()
        ans := sum[b] - sum[a - 1]
        if ans < 0 {
            ans += mod
        }
        fmt.Fprintln(out, ans)
    }
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    t := nextInt()
    k := nextInt()
    d := make([][]int, 2)
    mod := 1000000007
    maxn := 100001
    d[0] = make([]int, maxn)
    d[1] = make([]int, maxn)
    d[0][k] = 1
    for i := 1; i <= k; i++ {
        d[1][i] = 1
    }
    for i := k + 1; i < maxn; i++ {
        d[1][i] = (d[0][i - 1] + d[1][i - 1]) % mod
        if d[1][i] < 0 {
            d[1][i] += mod
        }
        d[0][i] = (d[0][i - k] + d[1][i - k]) % mod
        if d[0][i] < 0 {
            d[0][i] += mod
        }
    }
    sum := make([]int, maxn)
    for i := 1; i < maxn; i++ {
        sum[i] = (sum[i] + sum[i - 1] + d[0][i] + d[1][i]) % mod
        if sum[i] < 0 {
            sum[i] += mod
        }
    }
    for T := 0; T < t; T++ {
        a := nextInt()
        b := nextInt()
        fmt.Fprintln(out, sum[b] - sum[a - 1])
    }
}

package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
    if !in.Scan() {
        panic("Scan error")
    }
    return in.Text()
}

func nextInt() int {
    ret, _ := strconv.Atoi(next())
    return ret
}

func nextFloat() float64 {
    ret, _ := strconv.ParseFloat(next(), 64)
    return ret
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    t := nextInt()
    k := nextInt()
    d := make([][]int, 2)
    mod := 1000000007
    maxn := 100001
    d[0] = make([]int, maxn)
    d[1] = make([]int, maxn)
    d[0][k] = 1
    for i := 1; i <= k; i++ {
        d[1][i] = 1
    }
    for i := k + 1; i < maxn; i++ {
        d[1][i] = (d[0][i - 1] + d[1][i - 1]) % mod
        d[0][i] = (d[0][i - k] + d[1][i - k]) % mod
    }
    sum := make([]int, maxn)
    for i := 1; i < maxn; i++ {
        sum[i] = (sum[i] + sum[i - 1] + d[0][i] + d[1][i]) % mod
    }
    for T := 0; T < t; T++ {
        a := nextInt()
        b := nextInt()
        fmt.Fprintln(out, sum[b] - sum[a - 1])
    }
}


package main

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

const cf = true

func solve() {
	var n int
	fmt.Fscan(in, &n)
	arr1, arr2 := make([]int, n), make([]int, n)
	for i := range arr1 {
		fmt.Fscan(in, &arr1[i])
	}
	ans1 := 0
	for i := range arr2 {
		fmt.Fscan(in, &arr2[i])
		if arr1[i] != arr2[i] {
			ans1++
		}
	}
	sort.Ints(arr1)
	sort.Ints(arr2)
	ans2 := 1
	for i := range arr2 {
		if arr1[i] != arr2[i] {
			ans2++
		}
	}
	fmt.Fprintln(out, min(ans1, ans2))
}

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

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

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

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

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

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

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

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

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

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

var exists = struct{}{}

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

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

type Float interface {
	~float32 | ~float64
}

type Integer interface {
	Signed | Unsigned
}

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

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

type Ordered interface {
	Integer | Float | ~string
}

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

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

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

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

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

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

package main

import (
	"fmt"
)

func main() {

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

		var arr1 []int
		var arr2 []int
		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr1 = append(arr1, num2)
		}

		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr2 = append(arr2, num2)
		}
		var res int
		res = first(arr1, arr2, num1)
		fmt.Println(res)
	}

}

func first(arr1 []int, arr2 []int, strlen int) int {
	diff := 0
	arr1One := 0
	arr1Zore := 0

	arr2One := 0
	arr2Zore := 0

	count := 0
	for i := 0; i < strlen; i++ {
		if arr1[i] == 1 {
			arr1One += 1
		} else {
			arr1Zore += 1
		}
		if arr2[i] == 1 {
			arr2One += 1
		} else {
			arr2Zore += 1
		}
		if arr1[i] == arr2[i] {
			count += 1
		}
	}
	if count == strlen {
		return 0
	}
	if count == strlen-1 || (arr1One == arr2One && arr1Zore == arr2Zore) {
		return 1
	}
	if arr1One == strlen {
		return arr2Zore
	} else if arr1Zore == strlen {
		return arr2One
	}
	if arr1One > arr2One {

		diff = arr1One - arr2One
	} else {
		diff = arr2One - arr1One
	}

	var noEqual int
	noEqual = strlen - count
	if (noEqual - diff) > 0 {
		return diff + 1
	} else {
		return diff
	}
}

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 solve() {
	var n int
	scanf("%d\n", &n)
	a := make([]int, n)
	b := make([]int, n)
	aCnt, bCnt := 0, 0
	for i:=0; i<n; i++ {
		scanf("%d ", &a[i])
		if a[i] == 1 {
			aCnt++
		}
	}
	scanf("\n")
	for i:=0; i<n; i++ {
		scanf("%d ", &b[i])
		if b[i] == 1 {
			bCnt++
		}
	}
	scanf("\n")

	exchange := 0
	if aCnt > bCnt {
		a, b = b, a
	}
	for i:=0; i<n; i++ {
		if a[i] == 1 {
			if b[i] == 0 {
				exchange = 1
				break
			}
		}
	}

	res := aCnt - bCnt
	if bCnt > aCnt {
		res = bCnt - aCnt
	}
	res += exchange
	printf("%d\n", res)
}

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for tt:=1; tt<=T; tt++ {
		solve()
	}
}

package main

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

func solve(_r io.Reader, _w io.Writer) {

	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	var n, T int
	Fscan(in, &T)
	for ; T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n+1)
		b := make([]int, n+1)
		var cnt [2][2]int
		for i := 1; i <= n; i++ {
			Fscan(in, &a[i])
			cnt[0][a[i]]++
		}
		res := 0
		for i := 1; i <= n; i++ {
			Fscan(in, &b[i])
			cnt[1][b[i]]++
			if a[i] == b[i] {
				continue
			}
			res++
		}

		if cnt[0][0] <= cnt[1][0] {
			res = min(res, cnt[0][1]-cnt[1][1]+1)
		} else {
			res = min(res, cnt[0][0]-cnt[1][0]+1)
		}
		Fprintln(out, res)
	}

}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n int
		fmt.Fscan(in,&n)
		var f,s int
		r1:= make([]int,n)
		r2:= make([]int,n)
		for j:=0;j<n;j++{
			fmt.Fscan(in,&r1[j])
			if r1[j] == 1 {
				f++
			}
		}
		for j:=0;j<n;j++{
			fmt.Fscan(in,&r2[j])
			if r2[j] == 1 {
				s++
			}
		}
		var tally int
		for j:=0;j<n;j++{
			if r1[j]^r2[j] == 1 {
				tally++
			}
		}
		if tally > abs(f-s) {
			fmt.Fprintln(out,abs(f-s)+1)
			continue
		}
		fmt.Fprintln(out,abs(f-s))

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

package main

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

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

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

	var T int
	var n int
	var x int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n)
		a := make([]int, n)
		b := make([]int, n)
		sa := 0
		sb := 0
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			a[i] = x
			sa += x
		}
		for i := 0; i < n; i++ {
			Fscan(in, &x)
			b[i] = x
			sb += x
		}
		if sa < sb {
			sa, sb = sb, sa
			a, b = b, a
		}

		ans := 0
		if sa == sb {
			for i := 0; i < n; i++ {
				if a[i] != b[i] {
					ans++
					break
				}
			}
		} else {
			for i := 0; i < n; i++ {
				if a[i] != b[i] {
					a[i] = b[i]
					ans++

					if ans == sa- sb {
						break
					}
				}
			}
			for i := 0; i < n; i++ {
				if a[i] != b[i] {
					ans++
					break
				}
			}
		}

		Fprintln(out, ans)
	}
}

package main

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

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

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func solve(n int, a, b []int) int {
	var v, w int
	for i := 0; i < n; i++ {
		if a[i] != b[i] {
			v++
		}
		w += a[i] - b[i]
	}
	if w < 0 {
		w = -w
	}
	return min(v, w+1)
}

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

package main

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

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

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

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

		arrA, arrB, countsA, countsB := make([]int, n), make([]int, n), make([]int, 2), make([]int, 2)

		for i := 0; i < n; i++ {
			var t int
			fmt.Fscan(r, &t)
			arrA[i] = t
			countsA[t]++
		}
		for i := 0; i < n; i++ {
			var t int
			fmt.Fscan(r, &t)
			arrB[i] = t
			countsB[t]++
		}

		output := solve(&arrA, &arrB, &countsA, &countsB, n)

		fmt.Fprintln(w, output)

	}
}

func solve(arrA, arrB, countsA, countsB *[]int, n int) int {
	ans := 0
	allSame := true
	// sort.Ints(*arrA)
	// sort.Ints(*arrB)

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

		if (*arrA)[i] != (*arrB)[i] {
			allSame = false
			break
		}

	}
	if allSame == true {
		return 0
	}

	if allSame == false {

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

			if (*arrA)[i] != (*arrB)[i] && (*countsA)[1] != (*countsB)[1] {
				if (*countsA)[1] > (*countsB)[1] && (*arrA)[i] == 1 {
					(*arrA)[i] = 1 - (*arrA)[i]
					if (*arrA)[i] == 1 {
						(*countsA)[1]++
						(*countsA)[0]--
					}
					if (*arrA)[i] == 0 {
						(*countsA)[0]++
						(*countsA)[1]--
					}
					ans++
				}
				if (*countsA)[1] < (*countsB)[1] && (*arrA)[i] == 0 {
					(*arrA)[i] = 1 - (*arrA)[i]
					if (*arrA)[i] == 1 {
						(*countsA)[1]++
						(*countsA)[0]--
					}
					if (*arrA)[i] == 0 {
						(*countsA)[0]++
						(*countsA)[1]--
					}
					ans++
				}
			}
			if (*countsA)[1] == (*countsB)[1] {
				break
			}

		}

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

			if (*arrA)[i] != (*arrB)[i] {
				allSame = false
				break
			} else {
				allSame = true
			}

		}

		if allSame == false {

			ans += 1
		}
	}

	return ans
}

package main

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

func main() {
	var t int
	fmt.Scanf("%d\n", &t)
	scanner := bufio.NewScanner(os.Stdin)
	// mod := int64(998244353998244353)
	for i := 0; i < t; i++ {
		var s string
		if scanner.Scan() {
			scanner.Text() // ignore n
		}
		var arrA, arrB []string
		if scanner.Scan() {
			s = scanner.Text()
			arrA = strings.Split(s, " ")
		}
		if scanner.Scan() {
			s = scanner.Text()
			arrB = strings.Split(s, " ")
		}
		var same bool = true
		var oneZero, zeroOne int
		for i := 0; i < len(arrA); i++ {
			if arrA[i] != arrB[i] {
				same = false
			}
			if arrA[i] == "0" && arrB[i] == "1" {
				oneZero++
			}
			if arrA[i] == "1" && arrB[i] == "0" {
				zeroOne++
			}
		}
		if same {
			fmt.Println(0)
		} else {
			if oneZero == zeroOne {
				fmt.Println(1)
			} else {
				var ans int
				if oneZero > 0 && zeroOne > 0 {
					ans++
				}
				fmt.Println(ans + int(math.Abs(float64(oneZero-zeroOne))))
			}
		}
	}
}

package main

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

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

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

		var n int
		fmt.Fscan(r, &n)
		x := make([]int, n)
		y := make([]int, n)

		for i := range x { fmt.Fscan(r, &x[i]) }
		for i := range x { fmt.Fscan(r, &y[i]) }

		cnt := 0
		for i := range x {
			if x[i] != y[i] { cnt++ }
		}

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

		cnt2 := 1
		for i := range x {
			if x[i] != y[i] { cnt2++ }
		}

		if cnt < cnt2 {
			fmt.Fprintln(w, cnt)
		} else {
			fmt.Fprintln(w, cnt2)
		}
	}

}

package main

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

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

	var T int
	fmt.Fscan(in, &T)
	for t := 0; t < T; t++ {
		var n int
		fmt.Fscan(in, &n)

		aa := make([]int, n)
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &aa[i])
		}
		bb := make([]int, n)
		var d int
		for i := 0; i < n; i++ {
			fmt.Fscan(in, &bb[i])
			if aa[i] != bb[i] {
				d++
			}
		}

		z := 1
		sort.Ints(aa)
		sort.Ints(bb)
		for i := range aa {
			if aa[i] != bb[i] {
				z++
			}
		}

		if d < z {
			fmt.Fprintln(out, d)
		} else {
			fmt.Fprintln(out, z)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	// var num int
	// arr1One := 0
	// arr1Zore := 0
	// arr2One := 0
	// arr2Zore := 0

	// count := 0

	// fmt.Scan(&num)
	// var arr1 []int
	// var arr2 []int
	// var arrlen int
	// for i := 0; i < num; i++ {
	// 	fmt.Scan(&arrlen)
	// 	for j := 0; j < arrlen; j++ {
	// 		var num1 int
	// 		fmt.Scan(&num1)
	// 		arr1 = append(arr1, num1)
	// 		var num2 int
	// 		fmt.Scan(&num2)
	// 		arr2 = append(arr2, num2)

	// 		if arr1[j] == 1 {
	// 			arr1One += 1
	// 		} else {
	// 			arr1Zore += 1
	// 		}
	// 		if arr2[j] == 1 {
	// 			arr2One += 1
	// 		} else {
	// 			arr2Zore += 1
	// 		}
	// 		if arr1[j] == arr2[j] {
	// 			count += 1
	// 		}
	// 	}
	// 	if count == arrlen {
	// 		fmt.Println(0)
	// 		continue
	// 	}
	// 	if count == (arrlen - 1) {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One == arr2One && arr1Zore == arr2Zore {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One > arr2One {
	// 		fmt.Println(arr1One - arr2One + 1)
	// 	} else {
	// 		fmt.Println(arr2One - arr1One + 1)
	// 	}

	// 	break

	// }

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

		var arr1 []int
		var arr2 []int
		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr1 = append(arr1, num2)
		}

		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr2 = append(arr2, num2)
		}
		var res int
		res = first(arr1, arr2, num1)
		fmt.Println(res)
	}

}

func first(arr1 []int, arr2 []int, strlen int) int {
	step := 0
	arr1One := 0
	arr1Zore := 0

	arr2One := 0
	arr2Zore := 0

	count := 0
	for i := 0; i < strlen; i++ {
		if arr1[i] == 1 {
			arr1One += 1
		} else {
			arr1Zore += 1
		}
		if arr2[i] == 1 {
			arr2One += 1
		} else {
			arr2Zore += 1
		}
		if arr1[i] == arr2[i] {
			count += 1
		}
	}
	if count == strlen {
		return 0
	}
	if count == strlen-1 || arr1One == arr2One && arr1Zore == arr2Zore {
		return 1
	}
	if arr1One == strlen {
		return arr2Zore
	} else if arr1Zore == strlen {
		return arr2One
	}
	if arr1One > arr2One {
		step = arr1One - arr2One + 1
	} else {
		step = arr2One - arr1One + 1
	}
	return step
}

package main

import (
	"fmt"
)

func main() {
	// var num int
	// arr1One := 0
	// arr1Zore := 0
	// arr2One := 0
	// arr2Zore := 0

	// count := 0

	// fmt.Scan(&num)
	// var arr1 []int
	// var arr2 []int
	// var arrlen int
	// for i := 0; i < num; i++ {
	// 	fmt.Scan(&arrlen)
	// 	for j := 0; j < arrlen; j++ {
	// 		var num1 int
	// 		fmt.Scan(&num1)
	// 		arr1 = append(arr1, num1)
	// 		var num2 int
	// 		fmt.Scan(&num2)
	// 		arr2 = append(arr2, num2)

	// 		if arr1[j] == 1 {
	// 			arr1One += 1
	// 		} else {
	// 			arr1Zore += 1
	// 		}
	// 		if arr2[j] == 1 {
	// 			arr2One += 1
	// 		} else {
	// 			arr2Zore += 1
	// 		}
	// 		if arr1[j] == arr2[j] {
	// 			count += 1
	// 		}
	// 	}
	// 	if count == arrlen {
	// 		fmt.Println(0)
	// 		continue
	// 	}
	// 	if count == (arrlen - 1) {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One == arr2One && arr1Zore == arr2Zore {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One > arr2One {
	// 		fmt.Println(arr1One - arr2One + 1)
	// 	} else {
	// 		fmt.Println(arr2One - arr1One + 1)
	// 	}

	// 	break

	// }

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

		var arr1 []int
		var arr2 []int
		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr1 = append(arr1, num2)
		}

		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr2 = append(arr2, num2)
		}
		var res int
		res = first(arr1, arr2, num1)
		fmt.Println(res)
	}

}

func first(arr1 []int, arr2 []int, strlen int) int {
	step := 0
	arr1One := 0
	arr1Zore := 0

	arr2One := 0
	arr2Zore := 0

	count := 0
	for i := 0; i < strlen; i++ {
		if arr1[i] == 1 {
			arr1One += 1
		} else {
			arr1Zore += 1
		}
		if arr2[i] == 1 {
			arr2One += 1
		} else {
			arr2Zore += 1
		}
		if arr1[i] == arr2[i] {
			count += 1
		}
	}
	if count == strlen {
		return 0
	}
	if count == strlen-1 || arr1One == arr2One && arr1Zore == arr2Zore {
		return 1
	}
	if arr1One == strlen {
		return arr2Zore
	} else if arr1Zore == strlen {
		return arr1One
	}
	if arr1One > arr2One {
		step = arr1One - arr2One + 1
	} else {
		step = arr2One - arr1One + 1
	}
	return step
}

package main

import (
	"fmt"
)

func main() {
	// var num int
	// arr1One := 0
	// arr1Zore := 0
	// arr2One := 0
	// arr2Zore := 0

	// count := 0

	// fmt.Scan(&num)
	// var arr1 []int
	// var arr2 []int
	// var arrlen int
	// for i := 0; i < num; i++ {
	// 	fmt.Scan(&arrlen)
	// 	for j := 0; j < arrlen; j++ {
	// 		var num1 int
	// 		fmt.Scan(&num1)
	// 		arr1 = append(arr1, num1)
	// 		var num2 int
	// 		fmt.Scan(&num2)
	// 		arr2 = append(arr2, num2)

	// 		if arr1[j] == 1 {
	// 			arr1One += 1
	// 		} else {
	// 			arr1Zore += 1
	// 		}
	// 		if arr2[j] == 1 {
	// 			arr2One += 1
	// 		} else {
	// 			arr2Zore += 1
	// 		}
	// 		if arr1[j] == arr2[j] {
	// 			count += 1
	// 		}
	// 	}
	// 	if count == arrlen {
	// 		fmt.Println(0)
	// 		continue
	// 	}
	// 	if count == (arrlen - 1) {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One == arr2One && arr1Zore == arr2Zore {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One > arr2One {
	// 		fmt.Println(arr1One - arr2One + 1)
	// 	} else {
	// 		fmt.Println(arr2One - arr1One + 1)
	// 	}

	// 	break

	// }

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

		var arr1 []int
		var arr2 []int
		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr1 = append(arr1, num2)
		}

		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr2 = append(arr2, num2)
		}
		var res int
		res = first(arr1, arr2, num1)
		fmt.Println(res)
	}

}

func first(arr1 []int, arr2 []int, strlen int) int {
	step := 0
	arr1One := 0
	arr1Zore := 0

	arr2One := 0
	arr2Zore := 0

	count := 0
	for i := 0; i < strlen; i++ {
		if arr1[i] == 1 {
			arr1One += 1
		} else {
			arr1Zore += 1
		}
		if arr2[i] == 1 {
			arr2One += 1
		} else {
			arr2Zore += 1
		}
		if arr1[i] == arr2[i] {
			count += 1
		}
	}
	if count == strlen {
		return 0
	}
	if count == strlen-1 || arr1One == arr2One && arr1Zore == arr2Zore {
		return 1
	}
	if arr1One == strlen || arr1Zore == strlen {
		return arr2One
	}
	if arr1One > arr2One {
		step = arr1One - arr2One + 1
	} else {
		step = arr2One - arr1One + 1
	}
	return step
}

package main

import (
	"fmt"
)

func main() {
	// var num int
	// arr1One := 0
	// arr1Zore := 0
	// arr2One := 0
	// arr2Zore := 0

	// count := 0

	// fmt.Scan(&num)
	// var arr1 []int
	// var arr2 []int
	// var arrlen int
	// for i := 0; i < num; i++ {
	// 	fmt.Scan(&arrlen)
	// 	for j := 0; j < arrlen; j++ {
	// 		var num1 int
	// 		fmt.Scan(&num1)
	// 		arr1 = append(arr1, num1)
	// 		var num2 int
	// 		fmt.Scan(&num2)
	// 		arr2 = append(arr2, num2)

	// 		if arr1[j] == 1 {
	// 			arr1One += 1
	// 		} else {
	// 			arr1Zore += 1
	// 		}
	// 		if arr2[j] == 1 {
	// 			arr2One += 1
	// 		} else {
	// 			arr2Zore += 1
	// 		}
	// 		if arr1[j] == arr2[j] {
	// 			count += 1
	// 		}
	// 	}
	// 	if count == arrlen {
	// 		fmt.Println(0)
	// 		continue
	// 	}
	// 	if count == (arrlen - 1) {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One == arr2One && arr1Zore == arr2Zore {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One > arr2One {
	// 		fmt.Println(arr1One - arr2One + 1)
	// 	} else {
	// 		fmt.Println(arr2One - arr1One + 1)
	// 	}

	// 	break

	// }

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

		var arr1 []int
		var arr2 []int
		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr1 = append(arr1, num2)
		}

		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr2 = append(arr2, num2)
		}
		var res int
		res = first(arr1, arr2, num1)
		fmt.Println(res)
	}

}

func first(arr1 []int, arr2 []int, strlen int) int {
	step := 0
	arr1One := 0
	arr1Zore := 0

	arr2One := 0
	arr2Zore := 0

	count := 0
	for i := 0; i < strlen; i++ {
		if arr1[i] == 1 {
			arr1One += 1
		} else {
			arr1Zore += 1
		}
		if arr2[i] == 1 {
			arr2One += 1
		} else {
			arr2Zore += 1
		}
		if arr1[i] == arr2[i] {
			count += 1
		}
	}
	if count == strlen {
		return 0
	}
	if count == strlen-1 {
		return 1
	}
	if arr1One == arr2One && arr1Zore == arr2Zore {
		return 1
	}
	if (arr1One == strlen && arr2Zore == strlen) || arr1Zore == strlen && arr2One == strlen {
		return strlen
	}
	if arr1One > arr2One {
		step = arr1One - arr2One + 1
	} else {
		step = arr2One - arr1One + 1
	}
	return step
}

package main

import (
	"fmt"
)

func main() {
	// var num int
	// arr1One := 0
	// arr1Zore := 0
	// arr2One := 0
	// arr2Zore := 0

	// count := 0

	// fmt.Scan(&num)
	// var arr1 []int
	// var arr2 []int
	// var arrlen int
	// for i := 0; i < num; i++ {
	// 	fmt.Scan(&arrlen)
	// 	for j := 0; j < arrlen; j++ {
	// 		var num1 int
	// 		fmt.Scan(&num1)
	// 		arr1 = append(arr1, num1)
	// 		var num2 int
	// 		fmt.Scan(&num2)
	// 		arr2 = append(arr2, num2)

	// 		if arr1[j] == 1 {
	// 			arr1One += 1
	// 		} else {
	// 			arr1Zore += 1
	// 		}
	// 		if arr2[j] == 1 {
	// 			arr2One += 1
	// 		} else {
	// 			arr2Zore += 1
	// 		}
	// 		if arr1[j] == arr2[j] {
	// 			count += 1
	// 		}
	// 	}
	// 	if count == arrlen {
	// 		fmt.Println(0)
	// 		continue
	// 	}
	// 	if count == (arrlen - 1) {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One == arr2One && arr1Zore == arr2Zore {
	// 		fmt.Println(1)
	// 		continue
	// 	}
	// 	if arr1One > arr2One {
	// 		fmt.Println(arr1One - arr2One + 1)
	// 	} else {
	// 		fmt.Println(arr2One - arr1One + 1)
	// 	}

	// 	break

	// }

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

		var arr1 []int
		var arr2 []int
		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr1 = append(arr1, num2)
		}

		for j := 0; j < num1; j++ {
			var num2 int
			fmt.Scan(&num2)
			arr2 = append(arr2, num2)
		}
		var res int
		res = first(arr1, arr2, num1)
		fmt.Println(res)
	}

}

func first(arr1 []int, arr2 []int, strlen int) int {
	step := 0
	arr1One := 0
	arr1Zore := 0

	arr2One := 0
	arr2Zore := 0

	count := 0
	for i := 0; i < strlen; i++ {
		if arr1[i] == 1 {
			arr1One += 1
		} else {
			arr1Zore += 1
		}
		if arr2[i] == 1 {
			arr2One += 1
		} else {
			arr2Zore += 1
		}
		if arr1[i] == arr2[i] {
			count += 1
		}
	}
	if count == strlen {
		return 0
	}
	if count == strlen-1 {
		return 1
	}
	if arr1One == arr2One && arr1Zore == arr2Zore {
		return 1
	}
	if arr1One > arr2One {
		step = arr1One - arr2One + 1
	} else {
		step = arr2One - arr1One + 1
	}
	return step
}

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 solve() {
	var n int
	scanf("%d\n", &n)
	a := make([]int, n)
	b := make([]int, n)
	aCnt, bCnt := 0, 0
	for i:=0; i<n; i++ {
		scanf("%d ", &a[i])
		if a[i] == 1 {
			aCnt++
		}
	}
	scanf("\n")
	for i:=0; i<n; i++ {
		scanf("%d ", &b[i])
		if b[i] == 1 {
			bCnt++
		}
	}
	scanf("\n")

	exchange := 0
	if aCnt > bCnt {
		a, b = b, a
	}
	for i:=0; i<n; i++ {
		if a[i] == 1 {
			if b[i] == 0 {
				exchange = 1
				break
			}
		}
	}

	res := aCnt - bCnt
	if bCnt > aCnt {
		res = bCnt - aCnt
	}
	res += exchange
	printf("%d\n", res)
}

func main() {
	defer writer.Flush()

	var T int
	scanf("%d\n", &T)
	for tt:=1; tt<=T; tt++ {
		printf("Case #%d: ", tt)
		solve()
	}
}

package main

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

func work(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	var t int
	Fscan(in, &t)
	for i := 1; i <= t; i++ {
		solve(_r, _w)
	}
}

// https://space.bilibili.com/206214
func solve(_r io.Reader, _w io.Writer) {

	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	var n int
	Fscan(in, &n)
	a := make([]int, n+1)
	b := make([]int, n+1)
	var cnt [2][2]int
	for i := 1; i <= n; i++ {
		Fscan(in, &a[i])
		cnt[0][a[i]]++
	}
	res := 0
	for i := 1; i <= n; i++ {
		Fscan(in, &b[i])
		cnt[1][b[i]]++
		if a[i] == b[i] {
			continue
		}
		res++
	}

	if cnt[0][0] <= cnt[1][0] {
		res = min(res, cnt[0][1]-cnt[1][1]+1)
	} else {
		res = min(res, cnt[0][0]-cnt[1][0]+1)
	}
	Fprintln(out, res)
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

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