package main

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

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

func main() {
	defer out.Flush()
	var t int
	fmt.Fscanf(in, "%d\n", &t)
	for t := t; t > 0; t-- {
		var a, b int
		fmt.Fscanf(in, "%d%d\n", &a, &b)
		res := b*2 + a + 1

		if a == 0 {
			res = 1
		}

		fmt.Fprintln(out, res)
	}
}

package main

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

func solve(scanner *bufio.Scanner, t int) {
	for i := 0; i < t; i++ {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())

		lowerBound := a + 1
		upperBound := a + 2*b + 1
		ans := upperBound

		for lowerBound <= upperBound {
			m := lowerBound + (upperBound-lowerBound)/2
			if !canDo(a, b, m) {
				ans = m
				upperBound = m - 1
			} else {
				lowerBound = m + 1
			}
		}
		fmt.Println(ans)
	}
}

func canDo(a, b, num int) bool {
	n := num / 2
	if n <= b && a > 0 {
		return true
	}
	if n > b && a >= num-2*b {
		return true
	}
	return false
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())

	solve(scanner, t)

}

package main

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

type Problem struct {
	Language   string
	Code       string
	OriginProb string
}

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 {
		var a, b int64
		fmt.Fscan(in, &a, &b)
		if a > 0 {
			fmt.Fprintln(out, a+2*b+1)
		} else {
			fmt.Fprintln(out, 1)
		}

		t--
	}

}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in, &t)
	for t > 0 {
		var a, b int64
		fmt.Fscan(in, &a, &b)
		if a > 0 {
			fmt.Fprintln(out, a+2*b+1)
		} else {
			fmt.Fprintln(out, 1)
		}
		t--
	}

}

package main

import ("fmt")

func solve(){
	var a,b int
	fmt.Scan(&a,&b)

	if (a==0) {
       fmt.Println(1)
	}else{
		fmt.Println(2*b+a+1)
	}

}
func main() {
	var tc int
    fmt.Scan(&tc)
	// fmt.Print(tc)
	for i:=0;i<tc;i++{
		solve()
	}
}

package main

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

func solve(cin *scanner, cout *writer, cerr *writer) {
	a, b := cin.NextInt(), cin.NextInt()
	if a > 0 {
		cout.Println(b + b + a + 1)
	} else {
		cout.Println(1)
	}
}

func main() {
	cin := NewScanner(os.Stdin)
	cout, cerr := NewWriter(os.Stdout), NewWriter(os.Stderr)
	defer cout.Flush()
	defer cerr.Flush()
	t := cin.NextInt()
	// t := 1
	for ti := 0; ti < t; ti++ {
		solve(cin, cout, cerr)
	}
}

// Template Bolierplate {{{
type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 1024*1024)
	return &scanner{s}
}

func (i *scanner) Next() string {
	i.Scan()
	return i.Text()
}

func (i *scanner) Nexts(n int) []string {
	res := make([]string, n)
	for j := range res {
		res[j] = i.Next()
	}
	return res
}

func (i *scanner) NextInt() int {
	v, _ := strconv.Atoi(i.Next())
	return v
}

func (i *scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(i.Next(), 10, 64)
	return v
}

func (i *scanner) NextInts(n int) []int {
	res := make([]int, n)
	for j := range res {
		res[j] = i.NextInt()
	}
	return res
}

func (i *scanner) NextInt64s(n int) []int64 {
	res := make([]int64, n)
	for j := range res {
		res[j] = i.NextInt64()
	}
	return res
}

type writer struct {
	w *bufio.Writer
}

func NewWriter(w io.Writer) *writer {
	return &writer{bufio.NewWriter(w)}
}

func (i *writer) Print(a ...interface{}) {
	fmt.Fprint(i.w, a...)
}

func (i *writer) Println(a ...interface{}) {
	fmt.Fprintln(i.w, a...)
}

func (i *writer) Printf(format string, a ...interface{}) {
	fmt.Fprintf(i.w, format, a...)
}

func (i *writer) Flush() {
	i.w.Flush()
}

// }}}

// vim: fdm=marker

package main

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

func main() {
	var (
		t int
		a int
		b int
	)
	fmt.Scanf("%d\n", &t)
	scanner := bufio.NewScanner(os.Stdin)
	for i := 0; i < t; i++ {
		scanner.Scan()
		sl := strings.Split(scanner.Text(), " ")
		a, _ = strconv.Atoi(sl[0])
		b, _ = strconv.Atoi(sl[1])
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(a + b*2 + 1)
		}
	}
}

package main
import(
    "fmt"
)
func main(){
	var t int
	fmt.Scan(&t)
	for i:=0;i<t;i++{
		var a,b int
		fmt.Scan(&a,&b)
		if a == 0 {
			fmt.Println(1)
		}else{
			fmt.Println(2*b+a+1)
		}
	}
}

package main

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

func main(){
	cin := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscan(cin, &t)
	for t > 0 {
		var a, b int
		fmt.Fscan(cin, &a, &b)
		ans := 0
		switch {
		case a == 0:
			ans = 1
		case a > 0:
			ans = 2*b + a + 1
		}
		fmt.Println(ans)
		 t -= 1
	}
}

package main

import "fmt"

func execute(OneCoin, TwoCoin int) int {

	if OneCoin == 0 && TwoCoin == 0 {
		return 1
	}
	if OneCoin == 0 {
		return 1
	}

	if TwoCoin == 0 {
		return 1 + OneCoin
	}

	return 2*TwoCoin + OneCoin + 1

}

func main() {

	var testcase int
	fmt.Scan(&testcase)
	// hehe :)
	var OneCoin int
	var TwoCoin int
	for i := 0; i < testcase; i++ {
		fmt.Scan(&OneCoin, &TwoCoin)
		fmt.Println(execute(OneCoin, TwoCoin))
	}
}

package main

import (
	"fmt"
)

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

	for i := 0; i < int(testCases); i++ {
		var a, b int
		fmt.Scanf("%d %d\n", &a, &b)
		if a == 0 {
			fmt.Println(1)
			continue
		}
		maximum := ((b * 2) + a) + 1
		fmt.Println(maximum)
	}
}

package main

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

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

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

	defer out.Flush()

	var t, x, y int
	for fmt.Fscan(in, &t); t > 0; t-- {
		fmt.Fscan(in, &x, &y)
		if x == 0 {
			fmt.Fprintln(out, 1)
		} else {
			fmt.Fprintln(out, x+2*y+1)
		}
	}
}

package main

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

func solve(r *bufio.Reader) {
	var a, b int
	fmt.Fscan(r, &a, &b)
	if a == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(a + 2*b + 1)
	}
}
func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	fmt.Fscan(r, &n)
	for i := 0; i < n; i++ {
		solve(r)
	}
}

package main

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

var (
	sc *bufio.Scanner
	wr *bufio.Writer
)

func init() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	wr = bufio.NewWriter(os.Stdout)
}

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

func main() {
	defer wr.Flush()

	for T := scanInt(); T > 0; T-- {
		a, b := scanInt(), scanInt()
		if a == 0 {
			fmt.Fprintln(wr, 1)
		} else {
			fmt.Fprintln(wr, a+b*2+1)
		}
	}
}

package main

import "fmt"

func main() {
	var t int

	fmt.Scan(&t)

	for ; t > 0 ; t--  {
		var a,b int
		fmt.Scan(&a,&b)
		if(a == 0){
			fmt.Print(1,"\n")
		} else{
			fmt.Print(2 * b + a + 1,"\n")
		}
	}

}

package main

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

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

	var T, a, b int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a, &b)
		if a == 0 {
			Fprintln(out, 1)
		} else {
			Fprintln(out, a+b*2+1)
		}
	}
}

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

package main

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

const mod = 998244353
const mx = 3000

func solve(in *bufio.Reader, out *bufio.Writer) {
	defer out.Flush()
	var a,b int
	fmt.Fscan(in,&a,&b)
	if a == 0{
		fmt.Fprintln(out,1)
		return
	}
	fmt.Fprintln(out,a + b * 2 + 1)
}

func abs(a,b int)int{
	if a > b{
		return a - b
	}
	return b - a
}
func sum(a,b int64)int64{
	return (b + a) * (b - a + 1) / 2
}

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

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

package main

import (
	"fmt"
)

func main() {
	var T, a, b int
	fmt.Scan(&T)
	for ; T > 0; T-- {
		fmt.Scan(&a, &b)
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(b*2 + a + 1)
		}
	}
}

package main

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

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

func (in *CF1660A) GetLine() string {
	line, err := in.sc.ReadString('\n')
	if err != nil {
		fmt.Println("error line:", line, " err: ", err)
	}
	in.split = []string{}
	in.index = 0
	return line
}
func (in *CF1660A) load() {
	if len(in.split) <= in.index {
		in.split = strings.Split(in.GetLine(), in.separator)
		in.index = 0
	}
}

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

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

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

/**
Run solve the problem CF1660A
Date: 2/04/22
User: pepradere
URL: https://codeforces.com/problemset/problem/1660/A
Problem: CF1660A
**/
func (in *CF1660A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b := in.NextInt(), in.NextInt()
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println((b * 2) + a + 1)
		}
	}
}

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

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

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 t int
  for scanf("%d\n", &t) ; t > 0 ; t-- {
    var a, b int
    scanf("%d %d\n", &a, &b)
    if a != 0 {
      printf("%d\n", a + b * 2 + 1)
    } else {
      printf("1\n")
    }
  }
}

package main

import "fmt"

func solve() {

	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)

	if a == 0 && b > 0 {
		fmt.Println(1)
		return
	} else if b == 0 && a > 0 {
		fmt.Println(a + 1)
		return
	}

	payA := a
	payB := b * 2

	total := payA + payB

	fmt.Println(total + 1)
}

func main() {

	var t int
	fmt.Scanf("%d\n", &t)

	for t > 0 {
		solve()
		t--
	}
}

package main

import (
	"fmt"
)

func main() {
	a := 1
	b := 2
	var n int
	var nC1, nC2 int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nC1)
		fmt.Scan(&nC2)
		if nC1 == 0 {
			fmt.Println(1)
			continue
		}

		sm := nC1*a + nC2*b
		sm += 1
		fmt.Println(sm)
	}
}

package main

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

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		line := scanner.Text()

		fields := strings.Fields(line)

		if len(fields) == 1 {
			continue
		} else if len(fields) == 0 {
			break
		}

		a, err := strconv.Atoi(fields[0])
		if err != nil {
			panic(err)
		}
		b, err := strconv.Atoi(fields[1])
		if err != nil {
			panic(err)
		}

		fmt.Println(firstChange(a, b))
	}

}

func firstChange(a int, b int) int {
	if a == 0 {
		return 1
	} else {
		return a*1 + b*2 + 1
	}
}

package main

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

const (
	INF = 3e5 + 10
)

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

	var t int
	Fscan(in, &t)

	for i := 0; i < t; i++ {
		var a, b int64

		Fscan(in, &a, &b)

		var ans int64

		if a == 0 {
			ans = 1
		} else {
			ans = a + b*2 + 1
		}
		Fprintln(out, ans)

	}

}

package main

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

/*

 */

//goland:noinspection GoUnhandledErrorResult
func solve() {
	var a, b int
	scanf("%d %d\n", &a, &b)

	ans := a + 2*b + 1

	if a == 0 {
		ans = 1
	}

	fmt.Fprintln(writer, ans)
}

//goland:noinspection GoUnhandledErrorResult
func main() {
	defer writer.Flush()

	t := 1
	scanf("%d\n", &t)

	for ; t > 0; t-- {
		solve()
	}
}

const maxUint = ^uint(0)

//goland:noinspection GoUnusedConst
const minUint = 0
const maxInt = int(maxUint >> 1)

//goland:noinspection GoUnusedConst
const minInt = -maxInt - 1

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

func scanf(f string, a ...interface{}) {
	if _, err := fmt.Fscanf(reader, f, a...); err != nil {
		panic(err)
	}
}

//goland:noinspection GoUnusedFunction
func reversed(s string) string {
	input := []rune(s)
	li := len(input)
	ret := make([]rune, li)
	for i, r := range input {
		ret[li-i-1] = r
	}
	return string(ret)
}

//goland:noinspection GoUnusedFunction
func divCeil(num, div int64) int64 {
	quot := num / div
	if num%div > 0 {
		quot++
	} else if num%div < 0 {
		quot--
	}
	return quot
}

//goland:noinspection GoUnusedFunction
func min(nums ...int) int {
	return nums[minIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func minIdx(nums ...int) int {
	minNumIdx := 0
	for i, num := range nums {
		if num < nums[minNumIdx] {
			minNumIdx = i
		}
	}

	return minNumIdx
}

//goland:noinspection GoUnusedFunction
func max(nums ...int) int {
	return nums[maxIdx(nums...)]
}

//goland:noinspection GoUnusedFunction
func maxIdx(nums ...int) int {
	maxNumIdx := 0
	for i, num := range nums {
		if num > nums[maxNumIdx] {
			maxNumIdx = i
		}
	}

	return maxNumIdx
}

//goland:noinspection GoUnusedFunction
func abs(num int) int {
	if num < 0 {
		return -num
	}
	return num
}

//goland:noinspection GoUnusedFunction
func isPrime(num int) bool {
	if num == 2 || num == 3 {
		return true
	}

	if num <= 1 || num%2 == 0 || num%3 == 0 {
		return false
	}

	for i := 5; i*i <= num; i += 6 {
		if num%i == 0 || num%(i+2) == 0 {
			return false
		}
	}

	return true
}

//goland:noinspection GoUnusedFunction
func gcd(a, b int) int {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

//goland:noinspection GoUnusedFunction
func lcm(a, b int) int {
	return abs(a) / gcd(a, b) * abs(b)
}

// Examples:
//	digitAt(1234, -1) -> panic!
//	digitAt(1234, 0) -> 4
//	digitAt(1234, 1) -> 3
//	digitAt(1234, 2) -> 2
//	digitAt(1234, 3) -> 1
//	digitAt(1234, 4) -> panic!
//goland:noinspection GoUnusedFunction
func digitAt(num, pos int) int {
	if num == 0 {
		return 0
	}

	num = abs(num)

	lenNum := int(math.Log10(float64(num))) + 1
	if pos < 0 || pos >= lenNum {
		err := fmt.Sprintf("Out of bound access for digit. Position passed %d, number %d", pos, num)
		panic(err)
	}

	rem := num % int(math.Pow10(pos+1))
	return rem / int(math.Pow10(pos))
}

package main

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

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

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

		if a == 0 {
			fmt.Fprintln(out, 1)
		} else if b == 0 {
			fmt.Fprintln(out, a+1)
		} else {
			fmt.Fprintln(out, b*2+a+1)
		}
	}
}

package main

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

func main() {
	in,out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t:=0
	fmt.Fscan(in, &t)
	for ii := 0; ii < t; ii++ {
		var m,n int
		fmt.Fscan(in, &m,&n)
		if m ==0{
			fmt.Fprintln(out, 1)
		}else {
			fmt.Fprintln(out, m+n*2+1)
		}
	}
}

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

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i > 0; i-- {
	    a, b := read(), read()
	    if a != 0 {
	        Fprintln(out, a+2*b+1)
	    } else {
	        Fprintln(out, 1)
	    }
	}
}

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

package main

import "fmt"

func solve() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == 0 {
		// fmt.Println(1)
		fmt.Printf("1\n")
	} else {
		// fmt.Println(2*b + a + 1)
		fmt.Printf("%d\n", 2*b+a+1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import "fmt"

func solve() {
	var a, b int
	fmt.Scan(&a, &b)
	if a == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(2*b + a + 1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scanf("%d\n", &t)
	for ; t > 0; t-- {
		fmt.Scanf("%d %d\n", &a, &b)
		if a == 0 {
			fmt.Printf("%d\n", 1)
		} else {
			fmt.Printf("%d\n", b*2+a+1)
		}
	}
}

// a == b == 2
// (a) (b) (ab) (bb) (abb) (aabb)
// a > b
// a=6 b=3
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (aabbb) (aaabbb) (aaaabb) (aaaaabb) (aaaaaabb)
// a=6 b=5
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (aabbbbb) (aaabbbbb) (aaaabbbbb) (aaaaabbbbb) (aaaaaabbbbb)
// a < b
// a=3 b=6
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (bbbbbb) (abbbbbb) (aabbbbbb) (aaabbbbbb)

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		a, b := 0, 0
		scan(&a, &b)
		if a == 0 {
			printf("1\n")
		} else {
			printf("%d\n", a+b*2+1)
		}
	}
}

package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var a, b int
		_, _ = fmt.Scan(&a, &b)
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(a + b*2 + 1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, a, b int;
	fmt.Scan(&n);

	for ; n > 0 ; n-- {
		fmt.Scan(&a, &b)
		if a == 0 {
			fmt.Println(1)
		} else {
			fmt.Println(a + 2*b + 1)
		}
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, a, b int64
	_, _ = fmt.Scan(&n)
	for ; n > 0; n -= 1 {
		_, _ = fmt.Scan(&a, &b)
		if a > 0 {
			fmt.Println(a + 2*b + 1)
		} else {
			fmt.Println(1)
		}
	}

}

package main

// Problem description URL https://atcoder.jp/contests/abc236/tasks/abc240_a

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

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

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

type pair struct {
	Color int
	Size  int
}

var (
	n   = 0
	res []int
	s   *list.List
	cur = 0
)

func solve() {
	scan(&n)
	for n != 0 {
		n--
		a, b := 0, 0
		scan(&a, &b)
		if(a == 0){
			printf("1\n")
		}else {
			printf("%d\n", b*2+(a+1))
		}
	}
}

func main() {
	defer out.Flush()
	solve()
}

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i >= 0; i-- {
	    a, b := read(), read()
	    if a != 0 {
	        Fprintln(out, a+2*b+1)
	    } else {
	        Fprintln(out, 1)
	    }
	}
}

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

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	for i := read(); i >= 0; i-- {
	    a, b := read(), read()
	    Fprintln(out, a+2*b+1)
	}
}

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

package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewScanner(_r)
	in.Split(bufio.ScanWords)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	read := func() (x int) {
		in.Scan()
		for _, b := range in.Bytes() {
			x = x*10 + int(b&15)
		}
		return
	}
	a, b:= read(), read()
	Fprintln(out, a + 2*b + 1)
}

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

package main

import "fmt"

func solve() {
	var a, b int
	// fmt.Scan(&a, &b)
	fmt.Scanf("%d%d", &a, &b)
	if a == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(2*b + a + 1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import "fmt"

func solve() {
	var a, b int
	// fmt.Scan(&a, &b)
	fmt.Scanf("%d%d", &a, &b)
	if a == 0 {
		// fmt.Println(1)
		fmt.Printf("1\n")
	} else {
		// fmt.Println(2*b + a + 1)
		fmt.Printf("%d\n", 2*b+a+1)
	}
}

func main() {
	var t int
	fmt.Scan(&t)
	for t > 0 {
		t--
		solve()
	}
}

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		fmt.Scanf("%d %d", &a, &b)
		if a == 0 {
			fmt.Printf("%d\n", 1)
		} else {
			fmt.Printf("%d\n", b*2+a+1)
		}
	}
}

// a == b == 2
// (a) (b) (ab) (bb) (abb) (aabb)
// a > b
// a=6 b=3
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (aabbb) (aaabbb) (aaaabb) (aaaaabb) (aaaaaabb)
// a=6 b=5
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (aabbbbb) (aaabbbbb) (aaaabbbbb) (aaaaabbbbb) (aaaaaabbbbb)
// a < b
// a=3 b=6
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (bbbbbb) (abbbbbb) (aabbbbbb) (aaabbbbbb)

package main

import (
	"fmt"
)

func main() {
	var t, a, b int
	fmt.Scanf("%d", &t)
	for ; t > 0; t-- {
		fmt.Scanf("%d %d", &a, &b)
		fmt.Printf("%d\n", Calculation(a, b))
	}
}

func Calculation(a, b int) int {
	if a == 0 {
		return 1
	}
	return b*2 + a + 1
}

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

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

// a == b == 2
// (a) (b) (ab) (bb) (abb) (aabb)
// a > b
// a=6 b=3
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (aabbb) (aaabbb) (aaaabb) (aaaaabb) (aaaaaabb)
// a=6 b=5
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (aabbbbb) (aaabbbbb) (aaaabbbbb) (aaaaabbbbb) (aaaaaabbbbb)
// a < b
// a=3 b=6
// (a) (b) (ab) (bb) (abb) (bbb) (abbb) (bbbb) (abbbb) (bbbbb) (abbbbb) (bbbbbb) (abbbbbb) (aabbbbbb) (aaabbbbbb)

package main

import (
	"fmt"
)

func main() {
	var n, a, b int;
	fmt.Scanf("%d", &n);

	for i := 0; i < n; i++ {
		fmt.Scanf("%d %d", &a, &b)
		fmt.Println(a + 2*b + 1)
	}
}

package main

import (
	"fmt"
)

func main() {
	var a, b int64
	_, _ = fmt.Scan(&a, &b)
	if a > 0 {
		fmt.Print(a + 2*b + 1)
	} else {
		fmt.Print(1)
	}
}

package main

// Problem description URL https://atcoder.jp/contests/abc236/tasks/abc240_a

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
)

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

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

type pair struct {
	Color int
	Size  int
}

var (
	n   = 0
	res []int
	s   *list.List
	cur = 0
)

func solve() {
	scan(&n)
	for n != 0 {
		n--
		a, b := 0, 0
		scan(&a, &b)
		if(a == 0){
			printf("1\n")
		}else {
			printf("%lld\n", b*2+(a+1))
		}
	}
}

func main() {
	defer out.Flush()
	solve()
}

package main

import ("fmt")

func solve(){
	var a,b int
	fmt.Scan(&a,&b)

	if (a==0) {
       fmt.Println(1)
	}else{
		fmt.Println(2*b+a+1)
	}

}
func main() {
	var tc int
    fmt.Scan(&tc)
	fmt.Print(tc)
	for i:=0;i<tc;i++{
		solve()
	}
}

package main

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

func solve(cin *scanner, cout *writer, cerr *writer) {
	a, b := cin.NextInt(), cin.NextInt()
	cout.Println(b + b + a + 1)
}

func main() {
	cin := NewScanner(os.Stdin)
	cout, cerr := NewWriter(os.Stdout), NewWriter(os.Stderr)
	defer cout.Flush()
	defer cerr.Flush()
	t := cin.NextInt()
	// t := 1
	for ti := 0; ti < t; ti++ {
		solve(cin, cout, cerr)
	}
}

// Template Bolierplate {{{
type scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 1024*1024)
	return &scanner{s}
}

func (i *scanner) Next() string {
	i.Scan()
	return i.Text()
}

func (i *scanner) Nexts(n int) []string {
	res := make([]string, n)
	for j := range res {
		res[j] = i.Next()
	}
	return res
}

func (i *scanner) NextInt() int {
	v, _ := strconv.Atoi(i.Next())
	return v
}

func (i *scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(i.Next(), 10, 64)
	return v
}

func (i *scanner) NextInts(n int) []int {
	res := make([]int, n)
	for j := range res {
		res[j] = i.NextInt()
	}
	return res
}

func (i *scanner) NextInt64s(n int) []int64 {
	res := make([]int64, n)
	for j := range res {
		res[j] = i.NextInt64()
	}
	return res
}

type writer struct {
	w *bufio.Writer
}

func NewWriter(w io.Writer) *writer {
	return &writer{bufio.NewWriter(w)}
}

func (i *writer) Print(a ...interface{}) {
	fmt.Fprint(i.w, a...)
}

func (i *writer) Println(a ...interface{}) {
	fmt.Fprintln(i.w, a...)
}

func (i *writer) Printf(format string, a ...interface{}) {
	fmt.Fprintf(i.w, format, a...)
}

func (i *writer) Flush() {
	i.w.Flush()
}

// }}}

// vim: fdm=marker


package main

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

var in *bufio.Reader

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

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

	x := n
	cnt := 0
	for x > 1 {
		x >>= 1
		cnt++
	}
	x <<= cnt
	if x != n {
		fmt.Println("Alice")
	} else {
		if cnt%2 == 0 {
			fmt.Println("Alice")
		} else {
			fmt.Println("Bob")
		}
	}
}

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

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	pow := [35]int{}
	pow[0]=1
	for i:=1;i<=31;i++{
		if i==1{
			pow[i]=2
		}else{
			pow[i]=pow[i-1]*2
		}
	}
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		if n%2==0{
			flag := false
			for i:=0;i<=31;i++{
				if n==pow[i]{
					flag= true
				}
			}
			if flag{
				cnt := 0
				for n>1{
					n/=2
					cnt++
				}
				if cnt%2==0{
					fmt.Fprintln(out,"Alice")
				}else{
					fmt.Fprintln(out,"Bob")
				}
			}else{
				fmt.Fprintln(out,"Alice")
			}
		}else{
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if n&(n-1) == 0 && bits.Len(uint(n))&1 == 0 {
			Fprintln(out, "Bob")
			return
		}
		if n&1==0 {
			Fprintln(out, "Alice")
		} else {
			Fprintln(out, "Bob")
		}
	}

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

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

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

package main

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

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

	solve := func(Case int) {
		var n int
		Fscan(in, &n)
		if n&(n-1) == 0 && bits.Len(uint(n))&1 == 0 {
			Fprintln(out, "Bob")
			return
		}
		if n&1==0 {
			Fprintln(out, "Alice")
		} else {
			Fprintln(out, "Bob")
		}
	}

	T := 1
	Fscan(in, &T) //
	for Case := 1; Case <= T; Case++ {
		solve(Case)
	}

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

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

package main

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

var in *bufio.Reader

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

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

	x := n
	cnt := 0
	for x > 0 {
		x >>= 1
		cnt++
	}
	x = 1
	x <<= cnt - 1
	if x != n {
		fmt.Println("Alice")
	} else {
		if cnt%2 == 1 {
			fmt.Println("Alice")
		} else {
			fmt.Println("Bob")
		}
	}
}

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

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

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

package main

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

// Math

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

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

	var n int
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		if n&1 == 1 {
			fmt.Fprintln(writer, "Bob")
			continue
		}
		cnt := 0
		for ; n&1 == 0; n >>= 1 {
			cnt++
		}
		if n > 1 || cnt&1 == 0 {
			fmt.Fprintln(writer, "Alice")
		} else {
			fmt.Fprintln(writer, "Bob")
		}
	}
}

package main

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	mn := make(map[int]bool)
	for i := 1; i < 32; i+=2 {
		mn[1<<i]=true
	}

	for t := io.ReadInt(); t > 0; t-- {
		s := io.ReadInt()
		if s % 2 == 0 && mn[s] == false {
			io.Println("Alice")
		} else {
			io.Println("Bob")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	pow := [35]int{}
	pow[0]=1
	for i:=1;i<=31;i++{
		if i==1{
			pow[i]=2
		}else{
			pow[i]=pow[i-1]*2
		}
	}
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		if n%2==0{
			x := n/2
			flag := false
			for i:=0;i<=31;i++{
				if pow[i]==x&&x!=2{
					flag = true
				}
			}
			if flag{
				fmt.Fprintln(out,"Bob")
			}else{
				fmt.Fprintln(out,"Alice")
			}
		}else{
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := os.Stdout
	var t int
	fmt.Fscan(in,&t)
	for u:=1;u<=t;u++{
		var n int
		fmt.Fscan(in,&n)
		if n%2==0{
			fmt.Fprintln(out,"Alice")
		}else{
			fmt.Fprintln(out,"Bob")
		}
	}
}

package main

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

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

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

	var n int
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n)
		if canWin(n) {
			fmt.Fprintln(writer, "Alice")
		} else {
			fmt.Fprintln(writer, "Bob")
		}
	}
}

func canWin(n int) bool {
	ok := false
LOOP:
	for i := 2; i*i <= n; i++ {
		if n%i > 0 {
			continue
		} else if i&1 == 0 {
			ok = true
			break LOOP
		}
		for ; n%i == 0; n /= i {
		}
	}
	return ok
}


package main

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

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

	var n, m, k, v, w, end, st int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	fa := make([]int, n+1)
	dep := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		fa[v] = p
		dep[v] = d
		for _, w := range g[v] {
			if dep[w] == 0 && f(w, v, d+1) {
				return true
			}
			if dep[w] > 0 && d-dep[w] >= k {
				end, st = v, w
				return true
			}
		}
		return false
	}
	f(1, 0, 1)

	ans := []interface{}{st}
	for v := end; v != st; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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

package main

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

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

	var n, m, k, v, w, end, st int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	fa := make([]int, n+1)
	dep := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		fa[v] = p
		dep[v] = d
		for _, w := range g[v] {
			if dep[w] == 0 {
				if f(w, v, d+1) {
					return true
				}
			} else if d-dep[w] >= k {
				end, st = v, w
				return true
			}
		}
		return false
	}
	f(1, 0, 1)

	ans := []interface{}{st}
	for v := end; v != st; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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

package main

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

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

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d >= k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] && f(w, v, d+1) {
				return true
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{1}
	for v := end; v > 1; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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

package main

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

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

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d >= k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] {
				if f(w, v, d+1) {
					return true
				}
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{}
	for v := end; v > 0; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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

package main

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

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

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d == k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] {
				if f(w, v, d+1) {
					return true
				}
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{}
	for v := end; v > 0; v = fa[v] {
		ans = append(ans, v)
	}
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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

package main

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

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

	var n, m, k, v, w, end int
	Fscan(in, &n, &m, &k)
	g := make([][]int, n+1)
	for ; m > 0; m-- {
		Fscan(in, &v, &w)
		g[v] = append(g[v], w)
		g[w] = append(g[w], v)
	}

	vis := make([]bool, n+1)
	fa := make([]int, n+1)
	var f func(v, p, d int) bool
	f = func(v, p, d int) bool {
		vis[v] = true
		fa[v] = p
		if d >= k {
			for _, w := range g[v] {
				if w == 1 {
					end = v
					return true
				}
			}
		}
		for _, w := range g[v] {
			if !vis[w] && f(w, v, d+1) {
				return true
			}
		}
		return false
	}
	f(1, 0, 0)

	ans := []interface{}{}
	for v := end; v > 1; v = fa[v] {
		ans = append(ans, v)
	}
	ans = append(ans, 1)
	Fprintln(out, len(ans))
	Fprint(out, ans...)
}

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


package main

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

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

	solve := func() (ans int64) {
		var n, ones int64
		Fscan(in, &n, &ones)

		if ones == 0 {
			return
		}

		zeros := n - ones
		segZero, plus1Cnt := zeros/(ones+1), zeros%(ones+1)
		segZeroCnt := ones + 1 - plus1Cnt
		//if segZero == 0 {
		//	return n*ones - (ones-1)*ones/2
		//}

		//if segZero == 0 {
		//	return n*ones-(ones-1)*ones/2
		//}

		//a := segZero +1
		//b := n- segZero
		//c := segZero +1
		//d := (ones-1)*ones/2
		//ans += a*(ones*b-c*d)

		ans += (segZero + 1) * (n*segZeroCnt - segZero*(segZeroCnt+1)*segZeroCnt/2 - (segZeroCnt-1)*segZeroCnt/2)
		if plus1Cnt > 0 {
			n -= (segZero + 1) * segZeroCnt

			segZeroCnt = plus1Cnt
			segZero++
			ans += (segZero + 1) * (n*segZeroCnt - segZero*(segZeroCnt+1)*segZeroCnt/2 - (segZeroCnt-1)*segZeroCnt/2)

		}

		return
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		if _case == 6 {
			//println()

		}
		Fprintln(out, solve())
	}
}

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

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	fmt.Fscanf(in, "%d\n", &t)
	var n, m int64
	for i := 0; i < t; i++ {
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		var result int64 = (n * (n + 1))/2
		var z int64 =  n - m
		var k int64 = z/(m + 1)
		result -= (m + 1) * k * (k + 1) / 2
		result -= (z % (m + 1)) * (k + 1)
		fmt.Fprintf(out, "%v\n", result)
	}
}

package main

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

type node struct {
	diff int
	time int
}

type ByTime []node

func (a ByTime) Len() int           { return len(a) }
func (a ByTime) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ByTime) Less(i, j int) bool { return a[i].time < a[j].time }

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	for tt := int64(0); tt < t; tt++ {
		n, m := int64(0), int64(0)
		fmt.Fscanf(in, "%d %d\n", &n, &m)
		remainingN := n - m
		parts := m + 1
		eachPartNum := remainingN / parts
		a := remainingN % parts
		ans := (1 + n) * n / 2
		//fmt.Println(ans, remainingN, parts, eachPartNum, a)
		ans -= a * (eachPartNum + 1 + 1) * (eachPartNum + 1) / 2
		ans -= (parts - a) * (eachPartNum + 1) * eachPartNum / 2
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	return scanner.Bytes()
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

type state struct {
	i   int
	res int
}

var dp [11][11]state

func solve(n, m int) int64 {
	// var s state
	for nn := 1; nn <= n; nn++ {
		for mm := 1; mm <= m; mm++ {
			for i := 1; i <= nn; i++ {
				if dp[nn][mm].res < dp[nn-i][mm-1].res+i*(nn-i+1) {
					dp[nn][mm].res = dp[nn-i][mm-1].res + i*(nn-i+1)
					dp[nn][mm].i = i
				}
			}
		}
	}
	return int64(dp[n][m].res)
}

func form(n, b, q int) int64 {
	if q <= 0 {
		return int64(0)
	}
	return int64(b) * (int64(n+1)*int64(q) - int64(q)*int64(q+1)/int64(2)*int64(b))
}

func solveFaster(n, m int) int64 {
	A := 1 + (n-m)/(m+1)
	B := A + 1
	cntB := (n - m) % (m + 1)
	cntA := (m + 1) - cntB
	// fmt.Fprintln(os.Stderr, A, B, cntA, cntB, n, m)
	res := form(n, B, cntB-1)
	// fmt.Fprintln(os.Stderr, res)
	res += form(n-B*cntB, A, cntA-1)
	// fmt.Fprintln(os.Stderr, res)
	if cntB > 0 && cntA > 0 {
		res += int64(B) * int64(n-B*cntB+1)
	}

	// n - baseLen * ()
	// for n > 0 && m > 0 {
	// 	i := 1 + (n-m)/(m+1)
	// 	res += i * (n - i + 1)
	// 	n -= i
	// 	m--
	// }
	return res
}

func main() {
	f := os.Stdin
	out := os.Stdout
	// f, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(f, 1000010)
	// solve(1000, 1000)
	// for nn := 0; nn <= 1000; nn++ {
	// 	for mm := 0; mm <= nn; mm++ {
	// 		fr := solveFaster(nn, mm)
	// 		if dp[nn][mm].res != int(fr) {
	// 			fmt.Fprintln(out, "n=", nn, "m=", mm, "i=", dp[nn][mm].i, dp[nn][mm].res, "fr=", fr)
	// 		}
	// 		// fmt.Fprint(out, dp[i][j].i, " ")
	// 	}
	// 	// fmt.Fprintln(out)
	// }

	// dp = make([][100]state, 100)

	// fmt.Fprintln(out, solveFaster(100, 50))
	T := NextInt()

	for t := 0; t < T; t++ {
		n := NextInt()
		m := NextInt()
		fmt.Fprintln(out, solveFaster(n, m))
	}
}

package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

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

	tests := scanInt()
	for t := 0; t < tests; t++ {
		n := scanInt64()
		m := scanInt64()

		c0 := (n-m)/(m+1)
		cnt1 := (n-m)%(m+1)
		cnt0 := m+1-cnt1

		ans := cnt1*(c0+2)*(n+1)-(c0+2)*(c0+2)*cnt1*(cnt1+1)/2
		ans += (c0+1)*(cnt0*(n+1-(c0+2)*cnt1)-(c0+1)*cnt0*(cnt0+1)/2)
		fmt.Println(ans)
	}
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	var t int
	var n, m int64
	fmt.Fscanln(in, &t)
	for t > 0 {
		fmt.Fscanln(in, &n, &m)

		zero := n - m
		div := m + 1

		k := (zero / div)
		l := (zero % div)

		res := n*(n+1)/2 - (k*(k+1)/2*(div-l) + (k+1)*(k+2)/2*l)
		fmt.Fprintln(out, res)
		t--
	}
	out.Flush()
}

package main

import (
	"fmt"
)

func solve() {
	var n, m int64
	fmt.Scan(&n)
	fmt.Scan(&m)
	fmt.Println(n, m)
	var result int64 = (n * (n + 1))/2
	var z int64 =  n - m
	var k int64 = z/(m + 1)
    result -= (m + 1) * k * (k + 1) / 2
    result -= (z % (m + 1)) * (k + 1)
    fmt.Println(result)
}

func main() {
	var testcases uint32
	fmt.Scan(&testcases)
	for testcases != 0 {
		solve()
		testcases--
	}
}

package main

import (
    "fmt"
)

func main() {
	var testcases uint32
	fmt.Scanf("%d", &testcases)
	for testcases > 0 {
		var n, m int64
		// defer writer.Flush()
		fmt.Scanf("%d %d", &n, &m)
		var result int64 = (n * (n + 1))/2
		var z int64 =  n - m
		var k int64 = z/(m + 1)
		result -= (m + 1) * k * (k + 1) / 2
		result -= (z % (m + 1)) * (k + 1)
		fmt.Printf("%v\n", result)
		testcases --
	}
}

package main

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

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

	solve := func() (ans int64) {
		var n, ones int64
		Fscan(in, &n, &ones)

		if ones == 0 {
			return
		}

		zeros := n-ones
		full,_ := zeros/(ones+1), zeros%(ones+1)
		a := full+1
		b := n-full
		c := full+1
		d := (ones-1)*ones/2
		ans = a*(ones*b-c*d)
		return
	}

	var t int
	Fscan(in, &t)
	for _case := 1; _case <= t; _case++ {
		if _case == 5 {
			//println()

		}
		Fprintln(out, solve())
	}
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	const M int = 2e7
	o := make([]int, M+1)
	for i := 2; i <= M; i++ {
		if o[i] == 0 {
			for j := i; j <= M; j += i {
				o[j]++
			}
		}
	}
	for T := r(); T > 0; T-- {
		C, D, X, s := r(), r(), r(), 0
		d := 1
		for ; d*d < X; d++ {
			if X%d == 0 {
				if (D+d)%C == 0 {
					s += 1 << o[(D+d)/C]
				}
				if (D+X/d)%C == 0 {
					s += 1 << o[(D+X/d)/C]
				}
			}
		}
		if d*d == X && (D+d)%C == 0 {
			s += 1 << o[(D+d)/C]
		}
		Fprintln(out, s)
	}
}

package main

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

var _rbuf = bufio.NewReader(os.Stdin)
var _wbuf = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { _wbuf.Flush(); fmt.Fscan(_rbuf, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_wbuf, f, a...) }

var T time.Time

func main() {
	defer _wbuf.Flush()

	var t int
	scan(&t)

	var factors []factor
	var divisors []int
	for ; t > 0; t-- {
		factors = factors[:0]
		divisors = divisors[:0]

		var c, d, x int
		scan(&c, &d, &x)

		sqx := int(math.Sqrt(float64(x)))
		n := x
		for i := 0; n > 1; i++ {
			p := primes[i]
			if p > sqx {
				break
			}
			if n%p == 0 {
				num := 1
				for n /= p; n%p == 0; n /= p {
					num++
				}
				factors = append(factors, factor{p, num})
			}
		}
		if n > 1 {
			factors = append(factors, factor{n, 1})
		}

		var res int
		divisors = dfs(factors, divisors)
		for _, f := range divisors {
			if m := (d + f) / c; (d+f)%c == 0 {
				res += 1 << numdivs[m]
			}
		}
		printf("%d\n", res)
	}

	println("time:", time.Since(T).Milliseconds())
}

func dfs(factors []factor, divisors []int) []int {
	if len(factors) == 0 {
		return append(divisors, 1)
	}
	divisors = dfs(factors[1:], divisors)
	p := factors[0]
	n := len(divisors)
	for i := 0; i < n; i++ {
		f := 1
		for j := 0; j < p.num; j++ {
			f *= p.prime
			divisors = append(divisors, divisors[i]*f)
		}
	}
	return divisors
}

type factor struct {
	prime int
	num   int
}

const N = 20000001

var primes []int
var numdivs [N]int

func init() {
	T = time.Now()

	mindiv := make([]int, N)
	maxdiv := make([]int, N)
	isPrime := make([]bool, N)
	for i := 2; i < N; i++ {
		isPrime[i] = true
	}
	primes = make([]int, 0, N/10)
	for i := 2; i < N; i++ {
		if isPrime[i] {
			primes = append(primes, i)
			mindiv[i] = i
			maxdiv[i] = i
			numdivs[i] = 1
			k := 2
			for j := i + i; j < N; j += i {
				if isPrime[j] {
					mindiv[j] = i
					maxdiv[j] = k
				}
				isPrime[j] = false
				k++
			}
		}
	}
	for i := 2; i < N; i++ {
		if isPrime[i] {
			continue
		}
		j := maxdiv[i]
		numdivs[i] = numdivs[j]
		if mindiv[i] != mindiv[j] {
			numdivs[i]++
		}
	}

	println("time:", time.Since(T).Milliseconds())
}

package main

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

var _rbuf = bufio.NewReader(os.Stdin)
var _wbuf = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { _wbuf.Flush(); fmt.Fscan(_rbuf, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_wbuf, f, a...) }

func main() {
	defer _wbuf.Flush()

	T := time.Now()

	var t int
	scan(&t)

	var factors []factor
	var divisors []int
	for ; t > 0; t-- {
		factors = factors[:0]
		divisors = divisors[:0]

		var c, d, x int
		scan(&c, &d, &x)

		sqx := int(math.Sqrt(float64(x)))
		n := x
		for i := 0; n > 1; i++ {
			p := primes[i]
			if p > sqx {
				break
			}
			if n%p == 0 {
				num := 1
				for n /= p; n%p == 0; n /= p {
					num++
				}
				factors = append(factors, factor{p, num})
			}
		}
		if n > 1 {
			factors = append(factors, factor{n, 1})
		}

		var res int
		divisors = dfs(factors, divisors)
		for _, f := range divisors {
			if m := (d + f) / c; (d+f)%c == 0 {
				res += 1 << numdivs[m]
			}
		}
		printf("%d\n", res)
	}

	println("time:", time.Since(T).Milliseconds())
}

func dfs(factors []factor, divisors []int) []int {
	if len(factors) == 0 {
		return append(divisors, 1)
	}
	divisors = dfs(factors[1:], divisors)
	p := factors[0]
	n := len(divisors)
	for i := 0; i < n; i++ {
		f := 1
		for j := 0; j < p.num; j++ {
			f *= p.prime
			divisors = append(divisors, divisors[i]*f)
		}
	}
	return divisors
}

type factor struct {
	prime int
	num   int
}

var N = 20000001
var primes []int
var mindiv []int
var numdivs []int

func init() {
	mindiv = make([]int, N)
	numdivs = make([]int, N)
	isPrime := make([]bool, N)
	for i := 2; i < N; i++ {
		isPrime[i] = true
	}
	for i := 2; i < N; i++ {
		if !isPrime[i] {
			continue
		}
		primes = append(primes, i)
		mindiv[i] = i
		for j := i + i; j < N; j += i {
			if isPrime[j] {
				mindiv[j] = i
			}
			isPrime[j] = false
		}
	}
	for i := 2; i < N; i++ {
		if isPrime[i] {
			numdivs[i] = 1
		} else {
			j := i / mindiv[i]
			numdivs[i] = numdivs[j]
			if mindiv[i] != mindiv[j] {
				numdivs[i]++
			}
		}
	}
}

package main

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

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

	tc := readNum(reader)

	var buf bytes.Buffer

	for tc > 0 {
		tc--
		c, d, x := readThreeNums(reader)
		res := solve(c, d, x)
		buf.WriteString(fmt.Sprintf("%d\n", res))
	}

	fmt.Print(buf.String())
}

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

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

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

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

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

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

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

	return i
}

const MAX_X = 20000010

var V [MAX_X]int

func init() {
	mind := make([]int, MAX_X)
	for i := 0; i < MAX_X; i++ {
		mind[i] = -1
	}
	for i := 2; i < MAX_X; i++ {
		if mind[i] < 0 {
			for j := i; j < MAX_X; j += i {
				if mind[j] < 0 {
					mind[j] = i
				}
			}
		}
	}
	for i := 2; i < MAX_X; i++ {
		j := i / mind[i]
		V[i] = V[j]
		if mind[i] != mind[j] {
			V[i]++
		}
	}
}

func solve(c, d, x int) int {
	var res int
	for i := 1; i*i <= x; i++ {
		if x%i != 0 {
			continue
		}
		k1 := x/i + d
		if k1%c == 0 {
			res += 1 << V[k1/c]
		}
		if i*i == x {
			continue
		}
		k2 := i + d
		if k2%c == 0 {
			res += 1 << V[k2/c]
		}
	}

	return res
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	primes := make([]int, 0, 1270607)
	const mx int = 2e7
	o := make([]int8, mx+1)
	o[mx] = 0
	for i := 2; i <= mx; i++ {
		if o[i] == 0 {
			o[i] = 1
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				o[p*i] = o[i]
				break
			}
			o[p*i] = o[i] + 1
		}
	}

	for T := r(); T > 0; T-- {
		C, D, X := r(), r(), r()
		s, d := 0, 1
		for ; d*d < X; d++ {
			if X%d == 0 {
				if (D+d)%C == 0 {
					s += 1<<o[(D+d)/C]
				}
				if (D+X/d)%C == 0 {
					s += 1<<o[(D+X/d)/C]
				}
			}
		}
		if d*d == X && (D+d)%C == 0 {
			s += 1<<o[(D+d)/C]
		}
		Fprintln(out, s)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	primes := make([]int, 0, 1270607)
	const mx int = 2e7
	o := make([]int, mx+1)
	o[1] = 1
	o[mx] = 0
	for i := 2; i <= mx; i++ {
		if o[i] == 0 {
			o[i] = 2
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				o[p*i] = o[i]
				break
			}
			o[p*i] = o[i] << 1
		}
	}

	for T := r(); T > 0; T-- {
		C, D, X := r(), r(), r()
		s, d := 0, 1
		for ; d*d < X; d++ {
			if X%d == 0 {
				if (D+d)%C == 0 {
					s += o[(D+d)/C]
				}
				if (D+X/d)%C == 0 {
					s += o[(D+X/d)/C]
				}
			}
		}
		if d*d == X && (D+d)%C == 0 {
			s += o[(D+d)/C]
		}
		Fprintln(out, s)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<15, make([]byte, 1<<15)
	rc := func() byte {
		if _i == 1<<15 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	const mx int = 2e7
	o := make([]int, mx+1)
	o[1] = 1
	primes := make([]int, 0, 1270607)
	for i := 2; i <= mx; i++ {
		if o[i] == 0 {
			o[i] = 2
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				o[p*i] = o[i]
				break
			}
			o[p*i] = o[i] << 1
		}
	}

	for T := r(); T > 0; T-- {
		C, D, X := r(), r(), r()
		s, d := 0, 1
		for ; d*d < X; d++ {
			if X%d == 0 {
				if (D+d)%C == 0 {
					s += o[(D+d)/C]
				}
				if (D+X/d)%C == 0 {
					s += o[(D+X/d)/C]
				}
			}
		}
		if d*d == X && (D+d)%C == 0 {
			s += o[(D+d)/C]
		}
		Fprintln(out, s)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	const mx int = 2e7
	o := make([]int, mx+1)
	o[1] = 1
	primes := make([]int, 0, 1270607)
	for i := 2; i <= mx; i++ {
		if o[i] == 0 {
			o[i] = 2
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				o[p*i] = o[i]
				break
			}
			o[p*i] = o[i] << 1
		}
	}

	for T := r(); T > 0; T-- {
		C, D, X := r(), r(), r()
		s, d := 0, 1
		for ; d*d < X; d++ {
			if X%d == 0 {
				if (D+d)%C == 0 {
					s += o[(D+d)/C]
				}
				if (D+X/d)%C == 0 {
					s += o[(D+X/d)/C]
				}
			}
		}
		if d*d == X && (D+d)%C == 0 {
			s += o[(D+d)/C]
		}
		Fprintln(out, s)
	}
}

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	const M int = 2e7
	o := make([]int, M+1)
	for i := 2; i <= M; i++ {
		if o[i] == 0 {
			for j := i; j <= M; j += i {
				o[j]++
			}
		}
	}
	var T, c, D, x int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &c, &D, &x)
		a := []int{}
		for d := 1; d*d <= x; d++ {
			if x%d == 0 {
				a = append(a, d)
				if d*d < x {
					a = append(a, x/d)
				}
			}
		}
		s := 0
		for _, d := range a {
			if (D+d)%c == 0 {
				s += 1 << o[(D+d)/c]
			}
		}
		Println(s)
	}
}

package main

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

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

	const mx int = 2e7
	omega := make([]int, mx+1)
	for i := 2; i <= mx; i++ {
		if omega[i] == 0 {
			for j := i; j <= mx; j += i {
				omega[j]++
			}
		}
	}

	solve := func(Case int) {
		var c, D, x, ans int
		Fscan(in, &c, &D, &x)
		ds := []int{}
		for d := 1; d*d <= x; d++ {
			if x%d == 0 {
				ds = append(ds, d)
				if d*d < x {
					ds = append(ds, x/d)
				}
			}
		}
		for _, dv := range ds {
			if (D+dv)%c == 0 {
				ans += 1 << omega[(D+dv)/c]
			}
		}
		Fprintln(out, ans)
	}

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

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

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

package main

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

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

	const mx int = 1e6
	phi := [mx + 1]int{}
	for i := 1; i <= mx; i++ {
		phi[i] = i
	}
	for i := 2; i <= mx; i++ {
		if phi[i] == i {
			for j := i; j <= mx; j += i {
				phi[j] = phi[j] / i * (i - 1)
			}
		}
	}

	const mx2 int = 2e7
	lpf := make([]int, mx2+1)
	for i := 2; i <= mx2; i++ {
		if lpf[i] == 0 {
			for j := i; j <= mx2; j += i {
				if lpf[j] == 0 {
					lpf[j] = i
				}
			}
		}
	}
	o := func(x int) int {
		c := 1
		for x > 1 {
			p := lpf[x]
			for x /= p; lpf[x] == p; x /= p {
			}
			c++
		}
		return c
	}

	solve := func(Case int) {
		var c, d, x int
		Fscan(in, &c, &d, &x)
		ans := 0

		ds := []int{}
		for d := 1; d*d <= x; d++ {
			if x%d == 0 {
				ds = append(ds, d)
				if d*d < x {
					ds = append(ds, x/d)
				}
			}
		}
		for _, dv := range ds {
			if (d+dv)%c != 0 {
				continue
			}
			k := (d + dv) / c
			ans += phi[1<<o(k)]
		}
		Fprintln(out, ans)
	}

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

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

func main() { run(os.Stdin, os.Stdout) }
func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

package main

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

var _rbuf = bufio.NewReader(os.Stdin)
var _wbuf = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { _wbuf.Flush(); fmt.Fscan(_rbuf, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_wbuf, f, a...) }

var T time.Time

func main() {
	defer _wbuf.Flush()

	var t int
	scan(&t)

	var factors []factor
	var divisors []int
	for ; t > 0; t-- {
		factors = factors[:0]
		divisors = divisors[:0]

		var c, d, x int
		scan(&c, &d, &x)

		sqx := int(math.Sqrt(float64(x)))
		n := x
		for i := 0; n > 1; i++ {
			p := primes[i]
			if p > sqx {
				break
			}
			if n%p == 0 {
				num := 1
				for n /= p; n%p == 0; n /= p {
					num++
				}
				factors = append(factors, factor{p, num})
			}
		}
		if n > 1 {
			factors = append(factors, factor{n, 1})
		}

		var res int
		divisors = dfs(factors, divisors)
		for _, f := range divisors {
			if (d+f)%c == 0 {
				m := (d + f) / c
				res += 1 << numdivs[m]
			}
		}
		printf("%d\n", res)
	}

	println("time:", time.Since(T).Milliseconds())
}

func dfs(factors []factor, divisors []int) []int {
	if len(factors) == 0 {
		return append(divisors, 1)
	}
	divisors = dfs(factors[1:], divisors)
	p := factors[0]
	n := len(divisors)
	for i := 0; i < n; i++ {
		f := 1
		for j := 0; j < p.num; j++ {
			f *= p.prime
			divisors = append(divisors, divisors[i]*f)
		}
	}
	return divisors
}

type factor struct {
	prime int
	num   int
}

const N = 20000001

var primes []int
var numdivs [N]int

func init() {
	T = time.Now()

	isPrime := make([]bool, N)
	for i := 2; i < N; i++ {
		isPrime[i] = true
	}
	primes = make([]int, 0, N/10)
	mindiv := make([]struct{ min, max int }, N)
	for i := 2; i < N; i++ {
		if isPrime[i] {
			primes = append(primes, i)
			mindiv[i].min = i
			mindiv[i].max = i
			numdivs[i] = 1
			k := 2
			for j := i + i; j < N; j += i {
				if isPrime[j] {
					mindiv[j].min = i
					mindiv[j].max = k
				}
				isPrime[j] = false
				k++
			}
		}
	}
	for i := 2; i < N; i++ {
		if isPrime[i] {
			continue
		}
		j := mindiv[i].max
		numdivs[i] = numdivs[j]
		if mindiv[i].min != mindiv[j].min {
			numdivs[i]++
		}
	}

	println("time:", time.Since(T).Milliseconds())
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	const mx int = 2e7
	o := make([]int, mx+1)
	primes := make([]int, 0, 1270607)
	for i := 2; i <= mx; i++ {
		if o[i] == 0 {
			o[i] = 2
			primes = append(primes, i)
		}
		for _, p := range primes {
			if p*i > mx {
				break
			}
			if i%p == 0 {
				o[p*i] = o[i]
				break
			}
			o[p*i] = o[i] << 1
		}
	}

	for T := r(); T > 0; T-- {
		C, D, X := r(), r(), r()
		s, d := 0, 1
		for ; d*d < X; d++ {
			if X%d == 0 {
				if (D+d)%C == 0 {
					s += o[(D+d)/C]
				}
				if (D+X/d)%C == 0 {
					s += o[(D+X/d)/C]
				}
			}
		}
		if d*d == X && (D+d)%C == 0 {
			s += o[(D+d)/C]
		}
		Fprintln(out, s)
	}
}

package main

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

var _rbuf = bufio.NewReader(os.Stdin)
var _wbuf = bufio.NewWriter(os.Stdout)

func scan(a ...interface{})             { _wbuf.Flush(); fmt.Fscan(_rbuf, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_wbuf, f, a...) }

func main() {
	defer _wbuf.Flush()

	T := time.Now()

	var t int
	scan(&t)

	var factors []factor
	var all []int
	for ; t > 0; t-- {
		factors = factors[:0]
		all = all[:0]

		var c, d, x int
		scan(&c, &d, &x)

		sqx := int(math.Sqrt(float64(x)))
		n := x
		for i := 1; n > 1; i++ {
			p := primes[i]
			if p > sqx {
				break
			}
			if n%p == 0 {
				num := 1
				for n /= p; n%p == 0; n /= p {
					num++
				}
				factors = append(factors, factor{p, num})
			}
		}
		if n > 1 {
			factors = append(factors, factor{n, 1})
		}

		var res int
		all = dfs(factors, all)
		for _, f := range all {
			if m := (d + f) / c; (d+f)%c == 0 {
				res += numPairs(m)
			}
		}
		printf("%d\n", res)
	}

	println("time:", time.Since(T).Milliseconds())
}

func dfs(factors []factor, all []int) []int {
	if len(factors) == 0 {
		return append(all, 1)
	}
	all = dfs(factors[1:], all)
	prev := all
	p := factors[0]
	f := 1
	for i := 0; i < p.num; i++ {
		f *= p.prime
		for j := range prev {
			all = append(all, prev[j]*f)
		}
	}
	return all
}

type factor struct {
	prime int
	num   int
}

func numPairs(n int) int {
	if saves[n] != -1 {
		return saves[n]
	}
	m := n
	pow := 0
	sqn := int(math.Sqrt(float64(n)))
	for i := 0; n > 1; i++ {
		p := primes[i]
		if p > sqn {
			break
		}
		if n%p == 0 {
			pow++
			for n /= p; n%p == 0; n /= p {
			}
		}
	}
	if n > 1 {
		pow++
	}
	saves[m] = 1 << pow
	return saves[m]
}

var N = 20000001
var primes []int
var saves []int

func init() {
	saves = make([]int, N)
	for i := 0; i < N; i++ {
		saves[i] = -1
	}

	isPrime := make([]bool, N)
	for i := 2; i < N; i++ {
		isPrime[i] = true
	}
	for i := 2; i < N; i++ {
		if !isPrime[i] {
			continue
		}
		primes = append(primes, i)
		for j := i + i; j < N; j += i {
			isPrime[j] = false
		}
	}
}


package main

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

func main() {
	var n int
	fmt.Scan(&n)
	array := make([]int, n)

	// new way to read arrays
	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		bs.Scan()
		array[i], _ = strconv.Atoi(bs.Text())
	}

	sort.Ints(array)
	mex := 1
	for i := 0; i < n; i++ {
		if array[i] >= mex {
			mex++
		}
	}
	fmt.Print(mex)
}

package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"sort"
)
var (
	r *bufio.Scanner
	w *bufio.Writer
)

const ISDEBUG = false

func readLine() string {
	r.Scan()
	return r.Text()
}

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

func readInts(n int) []int {
	var res []int
	for i:=0; i<n; i++ {
		if !r.Scan() {
			fmt.Println(r.Err())
		}
		x, _ := strconv.Atoi(r.Text())
		res = append(res, x)
	}
	return res
}

func main() {
	if ISDEBUG {
		fi, err := os.Open("input100000.txt")
		if err != nil {
			panic(err)
		}
		fo, _ := os.OpenFile("output.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
		r = bufio.NewScanner(fi)
		w = bufio.NewWriter(fo)

		defer fi.Close()
		defer fo.Close()
	} else {
		r = bufio.NewScanner(os.Stdin)
		w = bufio.NewWriter(os.Stdout)
	}
	r.Split(bufio.ScanWords)
	defer w.Flush()

	n := readInt()
	a := readInts(n)
	sort.Ints(a)

	result := 1
	for _, i := range a {
		if i >= result {
			result += 1
		}
	}
	w.WriteString(fmt.Sprintf("%v", result))
}

package main

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

func main() {
	var n int
	fmt.Scan(&n)

	bs := bufio.NewScanner(os.Stdin)
	bs.Split(bufio.ScanWords)
	an := make([]int, n, n)
	for i := 0; i < n; i++ {
		bs.Scan()
		an[i], _ = strconv.Atoi(bs.Text())
	}

	sort.Sort(sort.IntSlice(an))
	cur := 1
	for i := 0; i < n; i++ {
		if cur <= an[i] {
			cur++
		}
	}

	fmt.Println(cur)
}

package main

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

func main() {
	n := getInt()
	a := getNint(n)
	sort.Ints(a)

	mex := 1
	for _, x := range a {
		if mex <= x {
			mex++
		}
	}
	fmt.Println(mex)
}

type Input struct {
	*bufio.Scanner
}

var globalInput = wrapStdin()

func wrapStdin() Input {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return Input{Scanner: sc}
}
func getInt() int {
	globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x
}
func getIntOk() (int, bool) {
	ok := globalInput.Scan()
	x, _ := strconv.Atoi(globalInput.Text())
	return x, ok
}
func getNint(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		v[i] = getInt()
	}
	return v
}
func getVint(v []int) bool {
	var ok bool
	for i := 0; i < len(v); i++ {
		v[i], ok = getIntOk()
	}
	return ok
}
func getWord() string {
	globalInput.Scan()
	return globalInput.Text()
}
func getWordOk() (string, bool) {
	ok := globalInput.Scan()
	return globalInput.Text(), ok
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func minStr(a, b string) string {
	if a < b {
		return a
	}
	return b
}
func maxStr(a, b string) string {
	if a < b {
		return b
	}
	return a
}
func remin(a *int, b int) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax(a *int, b int) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func remin64(a *int64, b int64) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remax64(a *int64, b int64) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}
func reminStr(a *string, b string) bool {
	if b < *a {
		*a = b
		return true
	}
	return false
}
func remaxStr(a *string, b string) bool {
	if b > *a {
		*a = b
		return true
	}
	return false
}

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

type (
	FLess    func(i, j int) bool
	FSwap    func(i, j int)
	wrapSort struct {
		Length int
		FLess
		FSwap
	}
)

func (w *wrapSort) Len() int           { return w.Length }
func (w *wrapSort) Less(i, j int) bool { return w.FLess(i, j) }
func (w *wrapSort) Swap(i, j int)      { w.FSwap(i, j) }
func wsort(length int, fless func(i, j int) bool, fswap func(i, j int)) {
	sort.Sort(&wrapSort{length, fless, fswap})
}

package main

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

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

	array := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		array[i] = a
	}

	merge_sort(array, 0, n-1)

	current := 1
	for i := 0; i < n; i++ {
		if array[i] >= current {
			array[i] = current
			current++
		}
	}
	fmt.Println(current)
}

func merge(buffer []int, start, middle, end int) {
	sorted := make([]int, end-start+1)

	i := start
	j := middle + 1
	k := 0
	for i <= middle && j <= end {
		if buffer[i] <= buffer[j] {
			sorted[k] = buffer[i]
			i++
		} else {
			sorted[k] = buffer[j]
			j++
		}
		k++
	}
	for i <= middle {
		sorted[k] = buffer[i]
		k++
		i++
	}
	for j <= end {
		sorted[k] = buffer[j]
		k++
		j++
	}

	i = start
	k = 0
	for i <= end {
		buffer[i] = sorted[k]
		i++
		k++
	}
}

func merge_sort(buffer []int, start, end int) {
	if end > start {
		middle := (end + start) / 2
		merge_sort(buffer, start, middle)
		merge_sort(buffer, middle+1, end)
		merge(buffer, start, middle, end)
	}
}

package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 10000000)
	byte, _, _ := reader.ReadLine()
	n , _ := strconv.Atoi(string(byte))
	li := make([]int , n+1)
	byte, _, _ = reader.ReadLine()
	strs := strings.Split(string(byte), " ")
	for i:=1; i<=  n; i++ {
		li[i], _ = strconv.Atoi(strs[i-1])
	}
	sort.Ints(li[:n+1])
	for i:=1; i<= n; i++ {
		if li[i] > li[i-1] {
			li[i] = li[i-1] + 1
		}
	}
	fmt.Println(li[n] + 1)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	li := make([]int , 100001)
	fmt.Scanf("%d", &n)
	for i:=1; i<= n; i++ {
		fmt.Scanf("%d", &li[i])
	}
	sort.Ints(li[:n+1])
	for i:=1; i<= n; i++ {
		if li[i] > li[i-1] {
			li[i] = li[i-1] + 1
		}
	}
	fmt.Printf("%d", li[n] + 1)
}

package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	li := make([]int , 100001)
	fmt.Scanf("%d", &n)
	for i:=1; i<= n; i++ {
	 	fmt.Scanf("%d", &li[i])
	}
	sort.Ints(li[:n+1])
	for i:=1; i<= n; i++ {
		if li[i] > li[i-1] {
			li[i] = li[i-1] + 1
		}
	}
	fmt.Printf("%d", li[n] + 2)
}

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	li := make([]int , 100001)
	byte, _, _ := reader.ReadLine()
	n , _ := strconv.Atoi(string(byte))
	byte, _, _ = reader.ReadLine()
	strs := strings.Split(string(byte), " ")
	for i:=1; i<  n; i++ {
		li[i], _ = strconv.Atoi(strs[i])
	}
	sort.Ints(li[:n+1])
	for i:=1; i<= n; i++ {
		if li[i] > li[i-1] {
			li[i] = li[i-1] + 1
		}
	}
	fmt.Printf("%d", li[n] + 1)
}

package main

import (
	"fmt"
	"sort"
)

func main(){
	var n int
	fmt.Scan(&n)
	array := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&array[i])
	}

	sort.Ints(array)
	var mex int
	for i := 0; i < n; i++ {
		if array[i] >= mex {
			mex++
		}
	}
	fmt.Print(mex)
}

package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
	"sort"
)
var (
	r *bufio.Scanner
	w *bufio.Writer
)

const ISDEBUG = false

func readLine() string {
	r.Scan()
	return r.Text()
}

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

func readInts() []int {
	r.Scan()
	res := make([]int, 0)
	for _, istr := range strings.Split(r.Text(), " ") {
		x, _ := strconv.Atoi(istr)
		res = append(res, x)
	}
	return res
}

func main() {
	if ISDEBUG {
		fi, err := os.Open("input.txt")
		if err != nil {
			panic(err)
		}
		fo, _ := os.OpenFile("output.txt", os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0755)
		r = bufio.NewScanner(fi)
		w = bufio.NewWriter(fo)

		defer fi.Close()
		defer fo.Close()
	} else {
		r = bufio.NewScanner(os.Stdin)
		w = bufio.NewWriter(os.Stdout)
	}
	defer w.Flush()

	_ = readInt()
	a := readInts()
	sort.Ints(a)

	result := 1
	for _, i := range a {
		if i >= result {
			result += 1
		}
	}
	w.WriteString(fmt.Sprintf("%d", result))
}