Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1, b2, b3, ..., where for each i > 1 the respective term satisfies the condition bi = bi - 1·q, where q is called the common ratio of the progression. Progressions in Uzhlyandia are unusual: both b1 and q can equal 0. Also, Dvastan gave Masha m "bad" integers a1, a2, ..., am, and an integer l.Masha writes all progression terms one by one onto the board (including repetitive) while condition |bi| ≤ l is satisfied (|x| means absolute value of x). There is an exception: if a term equals one of the "bad" integers, Masha skips it (doesn't write onto the board) and moves forward to the next term.But the lesson is going to end soon, so Masha has to calculate how many integers will be written on the board. In order not to get into depression, Masha asked you for help: help her calculate how many numbers she will write, or print "inf" in case she needs to write infinitely many integers.

The first line of input contains four integers b1, q, l, m (-109 ≤ b1, q ≤ 109, 1 ≤ l ≤ 109, 1 ≤ m ≤ 105) — the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively. The second line contains m distinct integers a1, a2, ..., am (-109 ≤ ai ≤ 109) — numbers that will never be written on the board.

Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.

NoteIn the first sample case, Masha will write integers 3, 12, 24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer.In the third case, Masha will write infinitely integers 123.

package main

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

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

var in *bufio.Reader

func scanf(format string, a ...interface{}) (int, error) {
    return fmt.Fscanf(in, format, a...)
}

func scanln() string {
    s, _ := in.ReadString('\n')
    return strings.TrimSpace(s)
}

func scanints() []int64 {
    line := scanln()
    data := strings.Split(line, " ")
    res := make([]int64, len(data))
    for i := 0; i < len(data); i++ {
        v, _ := strconv.Atoi(data[i])
        res[i] = int64(v)
    }
    return res
}

func searchInt64(a []int64, v int64) bool {
    idx := sort.Search(len(a), func (i int) bool { return a[i] >= v })
    return idx < len(a) && a[idx] == v
}

type Int64s []int64

func (s Int64s) Len() int {
    return len(s)
}

func (s Int64s) Less(i, j int) bool {
    return s[i] < s[j]
}

func (s Int64s) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

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

    // your code here
    var b, q, l, m int64
    scanf("%d %d %d %d\n", &b, &q, &l, &m)
    am := scanints()
    sort.Sort(Int64s(am))
    counted := make(map[int64]struct{})
    skipped := make(map[int64]struct{})
    var used struct{}
    for abs(b) <= l {
        if _, ok := skipped[b]; ok {
            if q == -1 && len(counted) > 0 {
                fmt.Println("inf")
                return
            }
            break
        }
        if _, ok := counted[b]; ok {
            fmt.Println("inf")
            return
        }
        if searchInt64(am, b) {
            skipped[b] = used
        } else {
            counted[b] = used
        }
        b *= q
    }
    fmt.Println(len(counted))
}

// Codeforces 789 B
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var b1 int64
var l int64
var q,m int
var a []int
var nItems int
var aset map[int64]bool

func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading n
	var b1i int
	var li int
	b1i,q,li,m,_ = readFive()
	b1 = int64(b1i)
	l = int64(li)
	a = readLineNumbs(m)
}

func checkAddVal(v int64) {
	_,have := aset[v]
	if !have {
		nItems += 1
	}
}

func solve() {
	aset = make(map[int64]bool)
	for i:=0; i<m; i++ {
		aset[int64(a[i])] = true
	}
	nItems = 0
	if b1==0 {
		// only element 0
		_,have := aset[0]
		if !have {
			nItems = -1
		}
		return
	} else if b1>l || -b1>l {
		return
	} else if q==0 {
		// only element 0
		_,have := aset[0]
		if !have {
			nItems = -1
		} else {
			checkAddVal(b1)
		}
		return
	} else if q==1 {
		// always b1
		_,have := aset[b1]
		if !have {
			nItems = -1
		} else {
			nItems=0
		}
		return
	} else if q==-1 {
		// b1, -b1
		_,have := aset[b1]
		if !have {
			nItems = -1
		} else {
			_,have = aset[-b1]
			if !have {
				nItems = -1
			}
		}
		return
	} else {
		// normal geom sequence, count element
		for (b1<=l) && (-b1<=l) {
			checkAddVal(b1)
			b1 = b1*int64(q)
		}
	}
}

func printRes() {
	if nItems>=0 {
		fmt.Println(nItems)
	} else {
		fmt.Println("inf")
	}
}

func main() {
	readData()
	solve()
	printRes()
}

package main

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

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(a int64) int64 {
    if a < 0 {
        return -a
    }
    return a
}

var in *bufio.Reader

func scanf(format string, a ...interface{}) (int, error) {
    return fmt.Fscanf(in, format, a...)
}

func scanln() string {
    s, _ := in.ReadString('\n')
    return strings.TrimSpace(s)
}

func scanints() []int64 {
    line := scanln()
    data := strings.Split(line, " ")
    res := make([]int64, len(data))
    for i := 0; i < len(data); i++ {
        v, _ := strconv.Atoi(data[i])
        res[i] = int64(v)
    }
    return res
}

func searchInt64(a []int64, v int64) bool {
    idx := sort.Search(len(a), func (i int) bool { return a[i] >= v })
    return idx < len(a) && a[idx] == v
}

type Int64s []int64

func (s Int64s) Len() int {
    return len(s)
}

func (s Int64s) Less(i, j int) bool {
    return s[i] < s[j]
}

func (s Int64s) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

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

    // your code here
    var b1, q, l, m int64
    scanf("%d %d %d %d\n", &b1, &q, &l, &m)
    am := scanints()
    sort.Sort(Int64s(am))
    if q != 0 && int64(abs(b1)) > l {
        fmt.Println( 0)
        return
    }
    if abs(q) <= 1 || b1 == 0 {
        if searchInt64(am, b1) {
            fmt.Println(0)
            return
        }
        if q == -1 {
            if searchInt64(am, -b1) {
                fmt.Println(0)
                return
            }
        }
        fmt.Println("inf")
        return
    }
    var b int64 = int64(b1)
    count := 1
    for abs(b*q) <= l {
        b *= q
        if !searchInt64(am, b) {
            count++
        }
    }
    fmt.Println(count)
}

package main

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

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(a int64) int64 {
    if a < 0 {
        return -a
    }
    return a
}

var in *bufio.Reader

func scanf(format string, a ...interface{}) (int, error) {
    return fmt.Fscanf(in, format, a...)
}

func scanln() string {
    s, _ := in.ReadString('\n')
    return strings.TrimSpace(s)
}

func scanints() []int64 {
    line := scanln()
    data := strings.Split(line, " ")
    res := make([]int64, len(data))
    for i := 0; i < len(data); i++ {
        v, _ := strconv.Atoi(data[i])
        res[i] = int64(v)
    }
    return res
}

func searchInt64(a []int64, v int64) bool {
    idx := sort.Search(len(a), func (i int) bool { return a[i] >= v })
    return idx < len(a) && a[idx] == v
}

type Int64s []int64

func (s Int64s) Len() int {
    return len(s)
}

func (s Int64s) Less(i, j int) bool {
    return s[i] < s[j]
}

func (s Int64s) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

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

    // your code here
    var b, q, l, m int64
    scanf("%d %d %d %d\n", &b, &q, &l, &m)
    am := scanints()
    sort.Sort(Int64s(am))
    counted := make(map[int64]struct{})
    skipped := make(map[int64]struct{})
    var used struct{}
    if abs(b) <= l && !searchInt64(am, b) {
        counted[b] = used
    } else {
        skipped[b] = used
    }
    for {
        b *= q
        if abs(b) > l {
            break
        }
        if _, ok := skipped[b]; ok {
            break
        }
        if _, ok := counted[b]; ok {
            fmt.Println("inf")
            return
        }
        if searchInt64(am, b) {
            skipped[b] = used
        } else {
            counted[b] = used
        }
    }
    fmt.Println(len(counted))
}

package main

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

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

var in *bufio.Reader

func scanf(format string, a ...interface{}) (int, error) {
    return fmt.Fscanf(in, format, a...)
}

func scanln() string {
    s, _ := in.ReadString('\n')
    return strings.TrimSpace(s)
}

func scanints() []int64 {
    line := scanln()
    data := strings.Split(line, " ")
    res := make([]int64, len(data))
    for i := 0; i < len(data); i++ {
        v, _ := strconv.Atoi(data[i])
        res[i] = int64(v)
    }
    return res
}

func searchInt64(a []int64, v int64) bool {
    idx := sort.Search(len(a), func (i int) bool { return a[i] >= v })
    return idx < len(a) && a[idx] == v
}

type Int64s []int64

func (s Int64s) Len() int {
    return len(s)
}

func (s Int64s) Less(i, j int) bool {
    return s[i] < s[j]
}

func (s Int64s) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

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

    // your code here
    var b, q, l, m int64
    scanf("%d %d %d %d\n", &b, &q, &l, &m)
    am := scanints()
    sort.Sort(Int64s(am))
    counted := make(map[int64]struct{})
    skipped := make(map[int64]struct{})
    var used struct{}
    if abs(b) <= l && !searchInt64(am, b) {
        counted[b] = used
    } else {
        skipped[b] = used
    }
    for {
        b *= q
        if abs(b) > l {
            break
        }
        if _, ok := skipped[b]; ok {
            if q == -1 && len(counted) > 0 {
                fmt.Println("inf")
                return
            }
            break
        }
        if _, ok := counted[b]; ok {
            fmt.Println("inf")
            return
        }
        if searchInt64(am, b) {
            skipped[b] = used
        } else {
            counted[b] = used
        }
    }
    fmt.Println(len(counted))
}

package main

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

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(a int64) int64 {
    if a < 0 {
        return -a
    }
    return a
}

var in *bufio.Reader

func scanf(format string, a ...interface{}) (int, error) {
    return fmt.Fscanf(in, format, a...)
}

func scanln() string {
    s, _ := in.ReadString('\n')
    return strings.TrimSpace(s)
}

func scanints() []int64 {
    line := scanln()
    data := strings.Split(line, " ")
    res := make([]int64, len(data))
    for i := 0; i < len(data); i++ {
        v, _ := strconv.Atoi(data[i])
        res[i] = int64(v)
    }
    return res
}

func searchInt64(a []int64, v int64) bool {
    idx := sort.Search(len(a), func (i int) bool { return a[i] >= v })
    return idx < len(a) && a[idx] == v
}

type Int64s []int64

func (s Int64s) Len() int {
    return len(s)
}

func (s Int64s) Less(i, j int) bool {
    return s[i] < s[j]
}

func (s Int64s) Swap(i, j int) {
    s[i], s[j] = s[j], s[i]
}

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

    // your code here
    var b, q, l, m int64
    scanf("%d %d %d %d\n", &b, &q, &l, &m)
    am := scanints()
    sort.Sort(Int64s(am))
    counted := make(map[int64]struct{})
    skipped := make(map[int64]struct{})
    var used struct{}
    count := 0
    if abs(b) <= l && !searchInt64(am, b) {
        count++
        counted[b] = used
    } else {
        skipped[b] = used
    }
    for {
        b *= q
        if abs(b) > l {
            break
        }
        if _, ok := skipped[b]; ok {
            break
        }
        if _, ok := counted[b]; ok {
            fmt.Println("inf")
            return
        }
        if searchInt64(am, b) {
            skipped[b] = used
        } else {
            count++
            counted[b] = used
        }
    }
    fmt.Println(count)
}

// Codeforces 789 B
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for j:=0; j<n; j++ {
		aa,err := strconv.Atoi(ss[j])
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[j] = aa
	}
	return a
}

var b1,q,l,m int
var a []int
var nItems int
var aset map[int]bool

func readData() {
	in = bufio.NewReader(os.Stdin)
	// reading n
	b1,q,l,m,_ = readFive()
	a = readLineNumbs(m)
}

func checkAddVal(v int) {
	_,have := aset[v]
	if !have {
		nItems += 1
	}
}

func solve() {
	aset = make(map[int]bool)
	for i:=0; i<m; i++ {
		aset[a[i]] = true
	}
	nItems = 0
	if b1==0 {
		// only element 0
		_,have := aset[0]
		if !have {
			nItems = -1
		}
		return
	} else if b1>l || -b1>l {
		return
	} else if q==0 {
		// only element 0
		_,have := aset[0]
		if !have {
			nItems = -1
		} else {
			checkAddVal(b1)
		}
		return
	} else if q==1 {
		// always b1
		_,have := aset[b1]
		if !have {
			nItems = -1
		} else {
			nItems=0
		}
		return
	} else if q==-1 {
		// b1, -b1
		_,have := aset[b1]
		if !have {
			nItems = -1
		} else {
			_,have = aset[-b1]
			if !have {
				nItems = -1
			}
		}
		return
	} else {
		// normal geom sequence, count element
		for (b1<=l) && (-b1<=l) {
			checkAddVal(b1)
			b1 = b1*q
		}
	}
}

func printRes() {
	if nItems>=0 {
		fmt.Println(nItems)
	} else {
		fmt.Println("inf")
	}
}

func main() {
	readData()
	solve()
	printRes()
}


Polycarp plays a well-known computer game (we won't mention its name). In this game, he can craft tools of two types — shovels and swords. To craft a shovel, Polycarp spends two sticks and one diamond; to craft a sword, Polycarp spends two diamonds and one stick.Each tool can be sold for exactly one emerald. How many emeralds can Polycarp earn, if he has $$$a$$$ sticks and $$$b$$$ diamonds?

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The only line of each test case contains two integers $$$a$$$ and $$$b$$$ ($$$0 \le a, b \le 10^9$$$) — the number of sticks and the number of diamonds, respectively.

For each test case print one integer — the maximum number of emeralds Polycarp can earn.

NoteIn the first test case Polycarp can earn two emeralds as follows: craft one sword and one shovel.In the second test case Polycarp does not have any diamonds, so he cannot craft anything.

package main

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

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

	n := readNum(reader)

	for n > 0 {
		n--
		a, b := readTwoNums(reader)
		fmt.Println(solve(a, b))
	}
}

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

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

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

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

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

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

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

	return i
}

func solve(a, b int) int {
	return min(a, b, (a+b)/3)
}

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	//fmt.Println("debug", t)
	for tt := int64(0); tt < t; tt++ {
		a, b := 0, 0
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		if a < b {
			a, b = b, a
		}
		c := a - b
		//fmt.Println(a, b, c)
		ans := 0
		if c >= b {
			ans = b
		} else {
			p := (b - c) / 3
			ans = c + p*2
			b -= c
			b -= p * 3
			if b == 2 {
				ans++
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

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

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() uint64 {
		sc.Scan()
		i, _ := strconv.ParseUint(sc.Text(), 10, 64)
		return i
	}

	for t := in(); t > 0; t-- {
		a, b := in(), in()

		if 2*a < b {
			b = 2 * a
		}

		if 2*b < a {
			a = 2 * b
		}

		n := (2*b - a) / 3
		m := (a - n) / 2

		fmt.Println(m + n)

	}
}

package main

import (
	"fmt"
	"math"
)

func main(){
	var i, t int64
	var a, b float64

	fmt.Scan(&t)

	for i = 0; i<t; i++{
		fmt.Scan(&a)
		fmt.Scan(&b)

		res := math.Min(a, math.Min(b, (a+b)/3))
		fr := int64(res)

		fmt.Println(fr)
	}
}

package main

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

func main() {
	t := nextInt()
	for i := 0; i < t; i++ {
		fmt.Println(solve(nextInt64(), nextInt64()))
	}
}

func solve(a, b int64) int64 {
	return Min((a+b)/3, a, b)
}

func Min(xs ...int64) int64 {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

var sc = bufio.NewScanner(os.Stdin)

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

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

func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		panic(err)
	}
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextInt64() int64 {
	a, err := strconv.ParseInt(next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return a
}

func nextInt64s(n int) []int64 {
	ret := make([]int64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt64()
	}
	return ret
}

/*
URL:
https://codeforces.com/contest/1366/problem/A
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t    int
	a, b int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b = ReadInt2()

		solve()
	}
}

func solve() {
	if a < b {
		a, b = b, a
	}

	diff := a - b
	if diff > b {
		fmt.Println(b)
		return
	}

	ans := diff
	a -= 2 * diff
	b -= diff

	c := (a + b) / 3
	ans += c
	fmt.Println(ans)
}

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

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/contest/1366/problem/A
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t    int
	a, b int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b = ReadInt2()

		solve()
	}
}

func solve() {
	ans := BinarySearch(0, INF_BIT30, func(c int) bool {
		if a-c < 0 || b-c < 0 {
			return false
		}

		return (a-c)+(b-c) >= c
	})

	fmt.Println(ans)
}

func BinarySearch(initOK, initNG int, isOK func(mid int) bool) (ok int) {
	ng := initNG
	ok = initOK
	for int(math.Abs(float64(ok-ng))) > 1 {
		mid := (ok + ng) / 2
		if isOK(mid) {
			ok = mid
		} else {
			ng = mid
		}
	}

	return ok
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

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

var nTest, a, b int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &nTest)

	for i := 0; i < nTest; i++ {
		fmt.Fscan(in, &a, &b)

		if a < b {
			a, b = b, a
		}

		if a >= 2*b {
			fmt.Fprintln(out, b)
			continue
		}

		t := 0
		if a != b {
			t = a - b
		}

		res := t + (a-2*t)/3*2
		if (a-2*t)%3 == 2 {
			res++
		}
		fmt.Fprintln(out, res)
	}
	out.Flush()
}

package main

import "fmt"

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

func main () {
	var t, a, b, i int64
	var num1, num2 int64
	fmt.Scanf("%d\n", &t)
	for i = 0; i < t; i++ {
		fmt.Scanf("%d%d\n", &a, &b)
		num1 = Min(a, b)
		num2 = Min(num1, (a+b)/3)
		fmt.Println(num2)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF1366A(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	min := func(a, b int) int {
		if a < b {
			return a
		}
		return b
	}

	var t, a, b int
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &a, &b)
		if a > b {
			a, b = b, a
		}
		c := 2*a - b
		if c < 0 {
			c = 0
		}
		ans := 0
		for x := c / 3; x <= c/3+1; x++ {
			y := min(a-2*x, (b-x)/2)
			if y >= 0 && x+y > ans {
				ans = x + y
			}
		}
		Fprintln(out, ans)
	}
}

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

package main

import . "fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var t, a, b int
	for Scan(&t); t > 0; t-- {
		Scan(&a, &b)
		Println(min(min(a, b), (a+b)/3))
	}
}

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

package main
import "fmt"
func main(){
	var N int
	fmt.Scan(&N)
	ans := make([]int, N)
	for i:=0; i<N; i++{
		var A, B int
		fmt.Scan(&A, &B)
		ans[i] = min(A, min(B, (A+B)/3))
	}
	for _, a := range ans{
		fmt.Println(a)
	}
}
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
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int64
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var p, a, ans int64
		fmt.Fscanf(in, "%v %v\n", &p, &a)
		val := (p + a) / 3
		second := 2*val - p
		first := val - second
		if first < 0 || second < 0{
			otb := int(math.Max(math.Min(float64(p/2), float64(a)), math.Min(float64(a/2), float64(p))))
			fmt.Fprintln(out, otb)
			continue
		}
		ans = first + second
		fmt.Fprintln(out, ans)
	}
	return
}

/*
2* (a - 2x) <= b-x

2a - 4x <= b - x

2a-b <= 3x
x >= (2a-b)/3
*/

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 < b {
			a,b = b,a
		}
		if a > 2 * b {
			fmt.Println(b)
			continue
		}
		x := (2*a - b) / 3
		if x * 3 < 2*a - b {
			x ++
		}
		ans := x
		a -= 2*x
		ans += a
		fmt.Println(ans)

	}
}

// Codeforces - Shovels and Swords - 1366A
package main

import "fmt"

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

func main() {
	var t, a, b int
	fmt.Scan(&t)
	for i := 0; i < t; i++ {
		fmt.Scan(&a, &b)
		fmt.Println(Min(a, Min(b, (a+b)/3)))
	}
}

package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	t := getNextInt(scanner)
	for i := 0; i < t; i++ {
		testcase(scanner, writer)
	}
}
func testcase(scanner *bufio.Scanner, writer *bufio.Writer) {
	a := getNextInt(scanner)
	b := getNextInt(scanner)
	if a < b {
		a, b = b, a
	}
	d := min(a-b, b)
	a -= d << 1
	b -= d
	d += b / 3 * 2
	a -= b / 3 * 3
	b -= b / 3 * 3
	if b > 0 && a > 1 {
		d++
	}
	fmt.Fprintln(writer, d)
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    Int64() int64
    UInt64() uint64
    String() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    // adjust the following size as needed
    // 2 << 17 is good enough to scan strings of len 2*10^5
    // it could go as high as 2 << 26 before cf judge breaks
    size := 2 << 20
    buf := make([]byte, size)
    s.Buffer(buf, size)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) Int64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) UInt64() uint64 {
    impl.Scan()
    bb := impl.Bytes()
    i := uint64(0)
    for _, b := range bb {
        i *= 10
        i += uint64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) String() string {
    impl.Scan()
    return impl.Text()
}

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

func lcm(a, b int64) int64 {
    return a * b / gcd(a, b)
}

func abs(a int64) int64 {
    if a < 0 {
        return a * -1
    }
    return a
}

func min(a int64, rest ...int64) int64 {
    for _, r := range rest {
        if r < a {
            a = r
        }
    }
    return a
}

func max(a int64, rest ...int64) int64 {
    for _, r := range rest {
        if r > a {
            a = r
        }
    }
    return a
}

const (
    INF = int64(math.MaxInt64)
    MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
	t := reader.Int64()
	for ; t > 0; t-- {
		a := reader.Int64()
		b := reader.Int64()
		writer.Printf("%d\n", sol(a, b))
	}
}

func sol(a, b int64) int64 {
	return min(a, b, (a+b)/3)
}

package main

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

const (
	SCANNER_BUF_SIZE = 2 << 20

	INF = int64(math.MaxInt64)
	MOD = 1e9 + 7
)

var (
	writer  *bufio.Writer
	scanner *bufio.Scanner
)

func init() {
	writer = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, SCANNER_BUF_SIZE), SCANNER_BUF_SIZE)
}

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

func sint64() int64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func suint64() uint64 {
	scanner.Scan()
	bb := scanner.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func sstring() string {
	scanner.Scan()
	return scanner.Text()
}

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

func lcm(a, b int64) int64 {
	return a * b / gcd(a, b)
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

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

func sol(a, b int64) int64 {
	return min(a, b, (a+b)/3)
}

package main

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

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

	n := readNum(reader)

	for n > 0 {
		n--
		a, b := readTwoNums(reader)
		fmt.Println(solve(a, b))
	}
}

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

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

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

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

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

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

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

	return i
}

func solve(a, b int) int {
	if a <= b/2 {
		return a
	}

	if b <= a/2 {
		return b
	}

	x := b / 3
	y := a - 2*x

	if 2*y+x > b {
		y--
	}

	return x + y
}

package main

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

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

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

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := int64(1)
	fmt.Fscanf(in, "%d\n", &t)
	//fmt.Println("debug", t)
	for tt := int64(0); tt < t; tt++ {
		a, b := 0, 0
		fmt.Fscanf(in, "%d %d\n", &a, &b)
		if a < b {
			a, b = b, a
		}
		c := a - b
		//fmt.Println(a, b, c)
		ans := 0
		if c >= b {
			ans = b
		} else {
			p := (b - c) / 3
			ans = c + p*2
			b -= p * 3
			if b == 2 {
				ans++
			}
		}
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}

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

func same(s string, ss string) bool {
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		b := int(s[i] - 'a')
		a[b]++
	}
	for i := 0; i < len(ss); i++ {
		b := int(ss[i] - 'a')
		a[b]--
		if a[b] == -1 {
			return false
		}
	}
	for i := 0; i < 26; i++ {
		if a[i] != 0 {
			return false
		}
	}
	return true
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	for t := in(); t > 0; t-- {
		a, b := in(), in()

		if 2*a < b {
			b = 2 * a
		}

		if 2*b < a {
			a = 2 * b
		}

		n := (2*b - a) / 3
		m := (2*a - b) / 3

		if m < 0 || n < 0 {
			fmt.Println(0)
		} else {
			fmt.Println(m + n)
		}
	}
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	for t := in(); t > 0; t-- {
		a, b := in(), in()

		n := (2*b - a) / 3
		m := (2*a - b) / 3

		if m < 0 || n < 0 {
			fmt.Println(0)
		} else {
			fmt.Println(m + n)
		}
	}
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

	in := func() uint64 {
		sc.Scan()
		i, _ := strconv.ParseUint(sc.Text(), 10, 64)
		return i
	}

	for t := in(); t > 0; t-- {
		a, b := in(), in()

		if 2*a < b {
			b = 2 * a
		}

		if 2*b < a {
			a = 2 * b
		}

		n := (2*b - a) / 3
		m := (2*a - b) / 3

		fmt.Println(m + n)

	}
}

package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	bf := make([]byte, 1024*1024)
	sc.Buffer(bf, 10*1024*1024)
	sc.Split(bufio.ScanWords)

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

	for t := in(); t > 0; t-- {
		a, b := in(), in()

		n := (2*b - a) / 3
		m := (a - n) / 2

		if m < 0 || n < 0 {
			fmt.Println(0)
		} else {
			fmt.Println(m + n)
		}
	}
}

package main

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

var nTest, a, b int

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	fmt.Fscan(in, &nTest)

	for i := 0; i < nTest; i++ {
		fmt.Fscan(in, &a, &b)

		if a < b {
			a, b = b, a
		}

		if a >= 2*b {
			fmt.Fprintln(out, b)
			continue
		}

		t := 0
		if a != b {
			t = a - b
		}

		fmt.Fprintln(out, t+(a-2*t)/3*2)
	}
	out.Flush()
}

package main

import "fmt"

func main () {
	var t, a, b, ctr int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d%d\n", &a, &b)
		if a == 0 || b == 0 {
			ctr = 0
		}
		if a == 1 && b == 1 {
			ctr = 0
		} else {
			if a >= 2*b {
				ctr = b
			}
			if b >= 2*a {
				ctr = a
			} else {
				ctr = (a+b)/3
			}
		}
		fmt.Println(ctr)
	}
}

package main

import "fmt"

func main () {
	var t, a, b, ctr int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d%d\n", &a, &b)
		if a == 0 || b == 0 {
			ctr = 0
		} else {
			if a >= 2*b {
				ctr = b
			}
			if b >= 2*a {
				ctr = a
			} else {
				ctr = (a+b)/3
			}
		}
		fmt.Println(ctr)
	}
}

package main

import "fmt"

func main () {
	var t, a, b, ctr int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d%d\n", &a, &b)
		if a == 0 || b == 0 {
			ctr = 0
		} else if a == 1 && b == 1 {
			ctr = 0
		} else {
			if a >= 2*b {
				ctr = b
			}
			if b >= 2*a {
				ctr = a
			} else {
				ctr = (a+b)/3
			}
		}
		fmt.Println(ctr)
	}
}

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)
		fmt.Println(A, min(B, (A+B)/3))
	}
}
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
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var p, a, ans int
		fmt.Fscanf(in, "%v %v\n", &p, &a)
		val := int((p + a) / 3)
		second := 2*val - p
		first := val - second
		if first < 0 || second < 0{
			fmt.Fprintln(out, 0)
			continue
		}
		ans = first + second
		fmt.Fprintln(out, ans)
	}
	return
}

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t, now int
	fmt.Fscanf(in, "%d\n", &t)
	for now < t {
		now++
		var p, a, ans int
		fmt.Fscanf(in, "%v %v\n", &p, &a)
		val := (p + a) / 3
		second := 2*val - p
		first := val - second
		if first < 0 || second < 0{
			fmt.Fprintln(out, 0)
			continue
		}
		ans = first + second
		fmt.Fprintln(out, ans)
	}
	return
}

package main

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

type BufferedWriter interface {
    Printf(format string, a ...interface{})
    Flush()
}

type writerImpl struct {
    *bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
    return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
    fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
    impl.Writer.Flush()
}

type WordScanner interface {
    Int64() int64
    UInt64() uint64
    String() string
}

type wordScannerImpl struct {
    *bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
    s := bufio.NewScanner(reader)
    s.Split(bufio.ScanWords)
    // adjust the following size as needed
    // 2 << 17 is good enough to scan strings of len 2*10^5
    // it could go as high as 2 << 26 before cf judge breaks
    size := 2 << 20
    buf := make([]byte, size)
    s.Buffer(buf, size)
    return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) Int64() int64 {
    impl.Scan()
    bb := impl.Bytes()
    i := int64(0)
    if bb[0] == '-' {
        for _, b := range bb[1:] {
            i *= 10
            i -= int64(b - '0')
        }
        return i
    }
    for _, b := range bb {
        i *= 10
        i += int64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) UInt64() uint64 {
    impl.Scan()
    bb := impl.Bytes()
    i := uint64(0)
    for _, b := range bb {
        i *= 10
        i += uint64(b - '0')
    }
    return i
}

func (impl *wordScannerImpl) String() string {
    impl.Scan()
    return impl.Text()
}

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

func lcm(a, b int64) int64 {
    return a * b / gcd(a, b)
}

func abs(a int64) int64 {
    if a < 0 {
        return a * -1
    }
    return a
}

func min(a int64, rest ...int64) int64 {
    for _, r := range rest {
        if r < a {
            a = r
        }
    }
    return a
}

func max(a int64, rest ...int64) int64 {
    for _, r := range rest {
        if r > a {
            a = r
        }
    }
    return a
}

const (
    INF = int64(math.MaxInt64)
    MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
    defer writer.Flush()
	t := reader.Int64()
	for ; t > 0; t-- {
		a := reader.Int64()
		b := reader.Int64()
		writer.Printf("%d\n", sol(a, b))
	}
}

func sol(a, b int64) int64 {
	// make b larger
	if a > b {
		b, a = a, b
	}
	x := min(b-a, a)
	a -= x
	b -= x*2
	return x + min(a,b)/3*2
}


For some binary string $$$s$$$ (i.e. each character $$$s_i$$$ is either '0' or '1'), all pairs of consecutive (adjacent) characters were written. In other words, all substrings of length $$$2$$$ were written. For each pair (substring of length $$$2$$$), the number of '1' (ones) in it was calculated.You are given three numbers:  $$$n_0$$$ — the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$0$$$;  $$$n_1$$$ — the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$1$$$;  $$$n_2$$$ — the number of such pairs of consecutive characters (substrings) where the number of ones equals $$$2$$$. For example, for the string $$$s=$$$"1110011110", the following substrings would be written: "11", "11", "10", "00", "01", "11", "11", "11", "10". Thus, $$$n_0=1$$$, $$$n_1=3$$$, $$$n_2=5$$$.Your task is to restore any suitable binary string $$$s$$$ from the given values $$$n_0, n_1, n_2$$$. It is guaranteed that at least one of the numbers $$$n_0, n_1, n_2$$$ is greater than $$$0$$$. Also, it is guaranteed that a solution exists.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the input. Then test cases follow. Each test case consists of one line which contains three integers $$$n_0, n_1, n_2$$$ ($$$0 \le n_0, n_1, n_2 \le 100$$$; $$$n_0 + n_1 + n_2 > 0$$$). It is guaranteed that the answer for given $$$n_0, n_1, n_2$$$ exists.

Print $$$t$$$ lines. Each of the lines should contain a binary string corresponding to a test case. If there are several possible solutions, print any of them.

package main

import (
	"bufio"
	"fmt"
	"os"

	//"os"
	"strconv"
	"strings"
)

func CheckError(err error) {
	if err != nil {
		panic(err)
	}
}

func Assert(b bool) {
	if !b {
		panic("Assertion error")
	}
}

func main() {
	input := os.Stdin
	/*
		  input := strings.NewReader(`7
		1 3 5
		1 1 1
		3 9 3
		0 1 0
		3 1 2
		0 0 3
		2 0 0`)
	*/
	scanner := bufio.NewScanner(input)

	getLine := func() string {
		if !scanner.Scan() {
			panic("expected line")
		}
		return scanner.Text()
	}

	parseNumber := func(s string) int {
		t, err := strconv.ParseInt(s, 10, 64)
		CheckError(err)
		return int(t)
	}

	getNumber := func() int {
		return parseNumber(getLine())
	}

	t := getNumber()
	for i := 0; i < t; i++ {
		lst := strings.Split(getLine(), " ")
		n0 := parseNumber(lst[0])
		n1 := parseNumber(lst[1])
		n2 := parseNumber(lst[2])

		//fmt.Println(n0, n1, n2)
		constructBinary(n0, n1, n2)
	}

}

func constructBinary(n0, n1, n2 int) {
	var lst []byte
	if n0 > 0 {
		for i := 0; i < n0+1; i++ {
			lst = append(lst, '0')
		}
	}

	if n2 > 0 {
		for i := 0; i < n2+1; i++ {
			lst = append(lst, '1')
		}
	}

	if n0 > 0 && n2 > 0 {
		n1 -= 1
	}

	if len(lst) == 0 {
		for i := 0; i < n1+1; i++ {
			b := byte('0')
			if i%2 == 0 {
				b = '1'
			}
			lst = append(lst, b)
		}
	} else {
		bb := [2]byte{'0', '1'}
		if lst[len(lst)-1] == '0' {
			bb = [2]byte{'1', '0'}
		}

		for i := 0; i < n1; i++ {
			lst = append(lst, bb[i%2])
		}
	}

	fmt.Println(string(lst))
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int16
	fmt.Scan(&t)

	for t > 0 {
		var n0, n1, n2 int
		var output string
		fmt.Scan(&n0, &n1, &n2)

		if n1 == 0 {
			if n0 != 0 {
				output = strings.Repeat("0", n0+1)
			} else {
				output = strings.Repeat("1", n2+1)
			}
		} else if n1&1 == 1 {
			output = strings.Repeat("0", n0) + strings.Repeat("01", (n1+1)/2) + strings.Repeat("1", n2)
		} else {
			output = strings.Repeat("0", n0) + strings.Repeat("01", n1/2) + strings.Repeat("1", n2) + "0"
		}

		fmt.Println(output)
		t--
	}
}

package main

import (
	"bytes"
	"fmt"
)

func dfs(state [3]int) string {
	path := make([]byte, 0)
	var dfsInner func(byte, [3]int) bool
	dfsInner = func(prev byte, state [3]int) bool {
		if state[0] < 0 || state[1] < 0 || state[2] < 0 {
			return false
		}
		if state[0] == 0 && state[1] == 0 && state[2] == 0 {
			path = append(path, prev)
			return true
		}
		// state graph
		// 00 -> 00, 01
		// 01 -> 11, 10
		// 10 -> 00, 01
		// 11 -> 11, 10
		if prev == '1' {
			if dfsInner('0', [3]int{state[0], state[1]-1, state[2]}) || dfsInner('1', [3]int{state[0], state[1], state[2]-1}) {
				path = append(path, '1')
				return true
			}
		} else if prev == '0' {
			if dfsInner('0', [3]int{state[0]-1, state[1], state[2]}) || dfsInner('1', [3]int{state[0], state[1]-1, state[2]}) {
				path = append(path, '0')
				return true
			}
		}

		return false
	}

	if !dfsInner('0', state) {
		dfsInner('1', state)
	}

	buf := bytes.NewBuffer(path)
	return buf.String()
}

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

	for i := 0; i < t; i++ {
		// pairs with 0 ones, pairs with 1 one, pairs with 2 ones
		var state [3]int
		fmt.Scan(&state[0], &state[1], &state[2])

		// find a path through that hits nodes
		// with the required counts
		// dfs, state is remaining allowed transitions
		fmt.Println(dfs(state))
	}
}

/*
URL:
https://codeforces.com/contest/1352/problem/F
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t       int
	a, b, c int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b, c = ReadInt3()
		solve(a, b, c)
	}
}

func solve(a, b, c int) {
	A := []rune{}

	if c > 0 {
		for i := 0; i < c+1; i++ {
			A = append(A, '1')
		}
	}

	if a > 0 {
		if len(A) > 0 {
			b--
		}
		for i := 0; i < a+1; i++ {
			A = append(A, '0')
		}
	}

	if len(A) > 0 && A[len(A)-1] == '0' {
		for i := 0; i < b; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else if len(A) > 0 && A[len(A)-1] == '1' {
		for i := 0; i < b; i++ {
			if i%2 == 1 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else {
		for i := 0; i < b+1; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	}

	if len(A) > 0 {
		fmt.Println(string(A))
	} else {
		fmt.Println("10")
	}
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

package main

import (
	"bufio"
	. "fmt"
	"io"
	"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()

	var t, n0, n1, n2 int
	f := func() (s string) {
		if n1 == 0 {
			if n0 > 0 {
				return strings.Repeat("0", n0+1)
			}
			return strings.Repeat("1", n2+1)
		}
		s = strings.Repeat("0", n0)
		if n1&1 == 1 {
			s += strings.Repeat("01", (n1+1)/2) + strings.Repeat("1", n2)
		} else {
			s += strings.Repeat("01", n1/2) + strings.Repeat("1", n2) + "0"
		}
		return
	}
	for Fscan(in, &t); t > 0; t-- {
		Fscan(in, &n0, &n1, &n2)
		Fprintln(out, f())
	}
}

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

package main

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

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

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

func solve() {
	var n0, n1, n2 int
	scanf("%d %d %d\n", &n0, &n1, &n2)

	ans := ""

	if n1 == 0 {
		if n2 > 0 {
			ans = "1"
			for n2 > 0 {
				ans = ans + "1"
				n2--
			}
		}
		if n0 > 0 {
			ans = "0"
			for n0 > 0 {
				ans = ans + "0"
				n0--
			}
		}
	} else {
		if n1 & 1 == 0 {
			ans = "10"
			for n0 > 0 {
				ans = ans + "0"
				n0--
			}
			ans = ans + "1"
			n1 -= 2
			for n1 > 0 {
				ans = ans + "01"
				n1 -= 2
			}
			for n2 > 0 {
				ans = ans + "1"
				n2--
			}
		} else {
			ans = "1"
			for n2 > 0 {
				ans = ans + "1"
				n2--
			}
			ans = ans + "0"
			n1--
			for n1 > 0 {
				ans = ans + "10"
				n1 -= 2
			}
			for n0 > 0 {
				ans = ans + "0"
				n0--
			}
		}
	}
	printf("%s\n", ans)
	writer.Flush()
}

func main() {
	t := 0
	scanf("%d\n", &t)
	for t > 0 {
		solve()
		t--
	}
}

package main

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

type BufferedWriter interface {
	Printf(format string, a ...interface{})
	Flush()
}

type writerImpl struct {
	*bufio.Writer
}

func NewBufferedWriter(writer io.Writer) BufferedWriter {
	return &writerImpl{Writer: bufio.NewWriter(writer)}
}

func (impl *writerImpl) Printf(f string, a ...interface{}) {
	fmt.Fprintf(impl.Writer, f, a...)
}

func (impl *writerImpl) Flush() {
	impl.Writer.Flush()
}

type WordScanner interface {
	NextInt64() int64
	NextUInt64() uint64
	NextString() string
}

type wordScannerImpl struct {
	*bufio.Scanner
}

func NewWordScanner(reader io.Reader) WordScanner {
	s := bufio.NewScanner(reader)
	s.Split(bufio.ScanWords)
	// adjust the following size as needed
	// 2 << 17 is good enough to scan strings of len 2*10^5
	// it could go as high as 2 << 26 before cf judge breaks
	size := 2 << 20
	buf := make([]byte, size)
	s.Buffer(buf, size)
	return &wordScannerImpl{Scanner: s}
}

func (impl *wordScannerImpl) NextInt64() int64 {
	impl.Scan()
	bb := impl.Bytes()
	i := int64(0)
	if bb[0] == '-' {
		for _, b := range bb[1:] {
			i *= 10
			i -= int64(b - '0')
		}
		return i
	}
	for _, b := range bb {
		i *= 10
		i += int64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextUInt64() uint64 {
	impl.Scan()
	bb := impl.Bytes()
	i := uint64(0)
	for _, b := range bb {
		i *= 10
		i += uint64(b - '0')
	}
	return i
}

func (impl *wordScannerImpl) NextString() string {
	impl.Scan()
	return impl.Text()
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func abs(a int64) int64 {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r < a {
			a = r
		}
	}
	return a
}

func max(a int64, rest ...int64) int64 {
	for _, r := range rest {
		if r > a {
			a = r
		}
	}
	return a
}

const (
	INF = math.MaxInt64
	MOD = 1e9 + 7
)

var reader = NewWordScanner(os.Stdin)
var writer = NewBufferedWriter(os.Stdout)

func main() {
	defer writer.Flush()
	t := reader.NextInt64()
	for ; t > 0; t-- {
		n0 := reader.NextInt64() // 00
		n1 := reader.NextInt64() // 01 or 10
		n2 := reader.NextInt64() // 11
		writer.Printf("%s\n", sol(n0, n1, n2))
	}
}

func sol(n0, n1, n2 int64) string {
	ret := ""
	for ; n1 > 0; n1-- {
		if ret == "" {
			ret += "10"
		} else {
			last := ret[len(ret)-1]
			if last == '0' {
				ret += "1"
			} else {
				ret += "0"
			}
		}
	}
	// 00
	if n0 > 0 {
		if len(ret) == 0 {
			ret = strings.Repeat("0", int(n0)+1)
		} else {
			for i := 0; i < len(ret); i++ {
				if ret[i] == '0' {
					ret = ret[:i] + strings.Repeat("0", int(n0)) + ret[i:]
					break
				}
			}
		}
	}
	// 11
	if n2 > 0 {
		if len(ret) == 0 {
			ret = strings.Repeat("1", int(n2)+1)
		} else {
			for i := 0; i < len(ret); i++ {
				if ret[i] == '1' {
					ret = ret[:i] + strings.Repeat("1", int(n2)) + ret[i:]
					break
				}
			}
		}
	}
	return ret
}

package main

import (
	"fmt"
	"strings"
)

func main() {
	var t int16
	fmt.Scan(&t)

	for t > 0 {
		var n0, n1, n2 int
		var output string
		fmt.Scan(&n0, &n1, &n2)

		if n1 == 0 {
			if n0 != 0 {
				output = strings.Repeat("0", n0+1)
			} else {
				output = strings.Repeat("1", n2+1)
			}
		}

		if n1&1 == 1 {
			output = strings.Repeat("0", n0) + strings.Repeat("01", (n1+1)/2) + strings.Repeat("1", n2)
		} else {
			output = strings.Repeat("0", n0) + strings.Repeat("01", n1/2) + strings.Repeat("1", n2) + "0"
		}

		fmt.Println(output)
		t--
	}
}

/*
URL:
https://codeforces.com/contest/1352/problem/F
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t       int
	a, b, c int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b, c = ReadInt3()
		solve(a, b, c)
	}
}

func solve(a, b, c int) {
	A := []rune{}

	if c > 0 {
		for i := 0; i < c+1; i++ {
			A = append(A, '1')
		}
	}

	if a > 0 {
		for i := 0; i < a+1; i++ {
			A = append(A, '0')
		}
	}

	if len(A) > 0 && A[len(A)-1] == '0' {
		for i := 0; i < b-1; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else if len(A) > 0 && A[len(A)-1] == '1' {
		for i := 0; i < b-1; i++ {
			if i%2 == 1 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else {
		for i := 0; i < b; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	}

	if len(A) > 0 {
		fmt.Println(string(A))
	} else {
		fmt.Println("10")
	}
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/contest/1352/problem/F
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t       int
	a, b, c int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b, c = ReadInt3()
		solve(a, b, c)
	}
}

func solve(a, b, c int) {
	A := []rune{}

	if c > 0 {
		for i := 0; i < c+1; i++ {
			A = append(A, '1')
		}
	}

	if a > 0 {
		for i := 0; i < a+1; i++ {
			A = append(A, '0')
		}
	}

	if len(A) > 0 && A[len(A)-1] == '0' {
		for i := 0; i < b-1; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else if len(A) > 0 && A[len(A)-1] == '1' {
		for i := 0; i < b-1; i++ {
			if i%2 == 1 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else {
		for i := 0; i < b+1; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	}

	if len(A) > 0 {
		fmt.Println(string(A))
	} else {
		fmt.Println("10")
	}
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/contest/1352/problem/F
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t       int
	a, b, c int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b, c = ReadInt3()
		solve(a, b, c)
	}
}

func solve(a, b, c int) {
	A := []rune{}

	if c > 0 {
		for i := 0; i < c+1; i++ {
			A = append(A, '1')
		}
	}

	if a > 0 {
		for i := 0; i < a+1; i++ {
			A = append(A, '0')
		}
	}

	if a > 0 {
		for i := 0; i < b-1; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else {
		for i := 0; i < b-1; i++ {
			if i%2 == 1 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	}

	if len(A) > 0 {
		fmt.Println(string(A))
	} else {
		fmt.Println("10")
	}
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/contest/1352/problem/F
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t       int
	a, b, c int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b, c = ReadInt3()
		solve(a, b, c)
	}
}

func solve(a, b, c int) {
	A := []rune{}

	if c > 0 {
		for i := 0; i < c+1; i++ {
			A = append(A, '1')
		}
	}

	if a > 0 {
		for i := 0; i < a+1; i++ {
			A = append(A, '0')
		}
	}

	if len(A) > 0 && A[len(A)-1] == '0' {
		for i := 0; i < b-1; i++ {
			if i%2 == 0 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	} else {
		for i := 0; i < b-1; i++ {
			if i%2 == 1 {
				A = append(A, '1')
			} else {
				A = append(A, '0')
			}
		}
	}

	if len(A) > 0 {
		fmt.Println(string(A))
	} else {
		fmt.Println("10")
	}
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}

/*
URL:
https://codeforces.com/contest/1352/problem/F
*/

package main

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

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

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

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

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

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

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

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	t       int
	a, b, c int
)

func main() {
	t = ReadInt()
	for i := 0; i < t; i++ {
		a, b, c = ReadInt3()
		solve(a, b, c)
	}
}

func solve(a, b, c int) {
	A := []rune{}

	if c > 0 {
		for i := 0; i < c+1; i++ {
			A = append(A, '1')
		}
	}

	if a > 0 {
		for i := 0; i < a+1; i++ {
			A = append(A, '0')
		}
	}

	for i := 0; i < b-1; i++ {
		if i%2 == 0 {
			A = append(A, '1')
		} else {
			A = append(A, '0')
		}
	}

	if len(A) > 0 {
		fmt.Println(string(A))
	} else {
		fmt.Println("10")
	}
}

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

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

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

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

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

	return string(res)
}

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

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

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

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}