There are $$$n$$$ weighted points on the $$$OX$$$-axis. The coordinate and the weight of the $$$i$$$-th point is $$$x_i$$$ and $$$w_i$$$, respectively. All points have distinct coordinates and positive weights. Also, $$$x_i < x_{i + 1}$$$ holds for any $$$1 \leq i < n$$$. The weighted distance between $$$i$$$-th point and $$$j$$$-th point is defined as $$$|x_i - x_j| \cdot (w_i + w_j)$$$, where $$$|val|$$$ denotes the absolute value of $$$val$$$.You should answer $$$q$$$ queries, where the $$$i$$$-th query asks the following: Find the minimum weighted distance among all pairs of distinct points among the points in subarray $$$[l_i,r_i]$$$.

The first line contains 2 integers $$$n$$$ and $$$q$$$ $$$(2 \leq n \leq 3 \cdot 10^5; 1 \leq q \leq 3 \cdot 10^5)$$$ — the number of points and the number of queries. Then, $$$n$$$ lines follows, the $$$i$$$-th of them contains two integers $$$x_i$$$ and $$$w_i$$$ $$$(-10^9 \leq x_i \leq 10^9; 1 \leq w_i \leq 10^9)$$$ — the coordinate and the weight of the $$$i$$$-th point. It is guaranteed that the points are given in the increasing order of $$$x$$$. Then, $$$q$$$ lines follows, the $$$i$$$-th of them contains two integers $$$l_i$$$ and $$$r_i$$$ $$$(1 \leq l_i < r_i \leq n)$$$ — the given subarray of the $$$i$$$-th query.

For each query output one integer, the minimum weighted distance among all pair of distinct points in the given subarray.

NoteFor the first query, the minimum weighted distance is between points $$$1$$$ and $$$3$$$, which is equal to $$$|x_1 - x_3| \cdot (w_1 + w_3) = |-2 - 1| \cdot (2 + 1) = 9$$$.For the second query, the minimum weighted distance is between points $$$2$$$ and $$$3$$$, which is equal to $$$|x_2 - x_3| \cdot (w_2 + w_3) = |0 - 1| \cdot (10 + 1) = 11$$$.For the fourth query, the minimum weighted distance is between points $$$3$$$ and $$$4$$$, which is equal to $$$|x_3 - x_4| \cdot (w_3 + w_4) = |1 - 9| \cdot (1 + 2) = 24$$$.

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

//github.com/EndlessCheng/codeforces-go
func main(){
	in:=bufio.NewReader(os.Stdin)
	var n,m,l,r int
	Fscan(in,&n,&m)
	var x,w,t [4e5]int64
	for i:=0;i<n;i++{Fscan(in,&x[i],&w[i]);t[i+1]=9e18}
	type Q struct{r,i int}
	q:=make([][]Q,n)
	ans:=make([]interface{},m)
	for i:=range ans{
		Fscan(in,&l,&r)
		q[l-1]=append(q[l-1],Q{r,i})
	}
	s:=[]int{}
	for i:=n-1;i>=0;i--{
		for len(s)>0{
			r:=s[len(s)-1]
			v:=(x[r]-x[i])*(w[i]+w[r])
			for r:=r+1;r<=n;r+=r&-r{if v<t[r]{t[r]=v}}
			if w[r]<w[i]{break}
			s=s[:len(s)-1]
		}
		s=append(s,i)
		for _,q:=range q[i]{
			v:=int64(9e18)
			for r:=q.r;r>0;r&=r-1{if t[r]<v{v=t[r]}}
			ans[q.i]=v
		}
	}
	Println(ans...)
}

package main

import (
	"bufio"
	. "fmt"
	"os"
	"runtime/debug"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	debug.SetGCPercent(-1)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	rn := func() (x int) {
		b := rc()
		neg := false
		for ; '0' > b; b = rc() {
			if b == '-' {
				neg = true
			}
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		if neg {
			return -x
		}
		return
	}

	n, m := r(), r()
	x := make([]int, n)
	w := make([]int, n)
	t := make([]int64, n+1)
	for i := range x {
		x[i] = rn()
		w[i] = r()
		t[i+1] = 9e18
	}
	type Q struct{ r, i int }
	q := make([][]Q, n)
	ans := make([]int64, m)
	for i := range ans {
		l, r := r(), r()
		q[l-1] = append(q[l-1], Q{r, i})
	}
	s := []int{}
	for i := n - 1; i >= 0; i-- {
		for len(s) > 0 {
			r := s[len(s)-1]
			v := int64(x[r]-x[i]) * int64(w[i]+w[r])
			for r := r + 1; r <= n; r += r & -r {
				if v < t[r] {
					t[r] = v
				}
			}
			if w[r] < w[i] {
				break
			}
			s = s[:len(s)-1]
		}
		s = append(s, i)
		for _, q := range q[i] {
			v := int64(9e18)
			for r := q.r; r > 0; r &= r - 1 {
				if t[r] < v {
					v = t[r]
				}
			}
			ans[q.i] = v
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	rn := func() (x int) {
		b := rc()
		neg := false
		for ; '0' > b; b = rc() {
			if b == '-' {
				neg = true
			}
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		if neg {
			return -x
		}
		return
	}

	n, m := r(), r()
	type pair struct{ x, w int }
	ps := make([]pair, n)
	for i := range ps {
		ps[i] = pair{rn(), r()}
	}
	t := make([]int64, n+1)
	for i := range t {
		t[i] = 9e18
	}
	type Q struct{ r, i int }
	q := make([][]Q, n)
	ans := make([]int64, m)
	for i := range ans {
		l, r := r(), r()
		q[l-1] = append(q[l-1], Q{r, i})
	}
	s := []int{}
	for i := n - 1; i >= 0; i-- {
		pl := ps[i]
		for len(s) > 0 {
			r := s[len(s)-1]
			pr := ps[r]
			v := int64(pr.x-pl.x) * int64(pr.w+pl.w)
			for r := r + 1; r <= n; r += r & -r {
				if v < t[r] {
					t[r] = v
				}
			}
			if pr.w < pl.w {
				break
			}
			s = s[:len(s)-1]
		}
		s = append(s, i)
		for _, q := range q[i] {
			v := int64(9e18)
			for r := q.r; r > 0; r &= r - 1 {
				if t[r] < v {
					v = t[r]
				}
			}
			ans[q.i] = v
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	rn := func() (x int) {
		b := rc()
		neg := false
		for ; '0' > b; b = rc() {
			if b == '-' {
				neg = true
			}
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		if neg {
			return -x
		}
		return
	}

	n, m := r(), r()
	x := make([]int, n)
	w := make([]int, n)
	t := make([]int64, n+1)
	for i := range x {
		x[i] = rn()
		w[i] = r()
		t[i+1] = 9e18
	}
	type Q struct{ r, i int }
	q := make([][]Q, n)
	ans := make([]int64, m)
	for i := range ans {
		l, r := r(), r()
		q[l-1] = append(q[l-1], Q{r, i})
	}
	s := []int{}
	for i := n - 1; i >= 0; i-- {
		for len(s) > 0 {
			r := s[len(s)-1]
			v := int64(x[r]-x[i]) * int64(w[i]+w[r])
			for r := r + 1; r <= n; r += r & -r {
				if v < t[r] {
					t[r] = v
				}
			}
			if w[r] < w[i] {
				break
			}
			s = s[:len(s)-1]
		}
		s = append(s, i)
		for _, q := range q[i] {
			v := int64(9e18)
			for r := q.r; r > 0; r &= r - 1 {
				if t[r] < v {
					v = t[r]
				}
			}
			ans[q.i] = v
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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

// github.com/EndlessCheng/codeforces-go
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n, m, l, r int
	Fscan(in, &n, &m)
	t := make([]int64, n+1)
	x := make([]int64, n)
	w := make([]int64, n)
	for i := range w {
		Fscan(in, &x[i], &w[i])
		t[i+1] = 9e18
	}
	type Q struct{ r, i int }
	q := make([][]Q, n)
	ans := make([]int64, m)
	for i := range ans {
		Fscan(in, &l, &r)
		q[l-1] = append(q[l-1], Q{r, i})
	}
	s := []int{}
	for i := n - 1; i >= 0; i-- {
		for len(s) > 0 {
			r := s[len(s)-1]
			v := (x[r] - x[i]) * (w[i] + w[r])
			for r := r + 1; r <= n; r += r & -r {
				if v < t[r] {
					t[r] = v
				}
			}
			if w[r] < w[i] {
				break
			}
			s = s[:len(s)-1]
		}
		s = append(s, i)
		for _, q := range q[i] {
			v := int64(9e18)
			for r := q.r; r > 0; r &= r - 1 {
				if t[r] < v {
					v = t[r]
				}
			}
			ans[q.i] = v
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

package main

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

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

	var n, m, l, r int
	Fscan(in, &n, &m)
	tree := make([]int64, n+1)
	pos := make([]int64, n)
	wt := make([]int64, n)
	update := func(l, r int) {
		v := (pos[r] - pos[l]) * (wt[l] + wt[r])
		for r++; r <= n; r += r & -r {
			if v < tree[r] {
				tree[r] = v
			}
		}
	}
	for i := range wt {
		Fscan(in, &pos[i], &wt[i])
		tree[i+1] = 9e18
	}
	type query struct{ r, i int }
	qs := make([][]query, n)
	ans := make([]int64, m)
	for i := range ans {
		Fscan(in, &l, &r)
		qs[l-1] = append(qs[l-1], query{r, i})
	}
	stk := []int{}
	for i := n - 1; i >= 0; i-- {
		for len(stk) > 0 && wt[stk[len(stk)-1]] > wt[i] {
			update(i, stk[len(stk)-1])
			stk = stk[:len(stk)-1]
		}
		if len(stk) > 0 {
			update(i, stk[len(stk)-1])
		}
		stk = append(stk, i)
		for _, q := range qs[i] {
			mi := int64(9e18)
			for r := q.r; r > 0; r &= r - 1 {
				if tree[r] < mi {
					mi = tree[r]
				}
			}
			ans[q.i] = mi
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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

package main

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

// github.com/EndlessCheng/codeforces-go
func main() {
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	_i, buf := 1<<12, make([]byte, 1<<12)
	rc := func() byte {
		if _i == 1<<12 {
			os.Stdin.Read(buf)
			_i = 0
		}
		b := buf[_i]
		_i++
		return b
	}
	r := func() (x int) {
		b := rc()
		for ; '0' > b; b = rc() {
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		return
	}
	rn := func() (x int) {
		b := rc()
		neg := false
		for ; '0' > b; b = rc() {
			if b == '-' {
				neg = true
			}
		}
		for ; '0' <= b; b = rc() {
			x = x*10 + int(b&15)
		}
		if neg {
			return -x
		}
		return
	}

	n := r()
	x := make([]int, n)
	w := make([]int, n)
	t := make([]int64, n+1)
	for i := range x {
		x[i] = rn()
		w[i] = r()
		t[i+1] = 9e18
	}
	type Q struct{ r, i int }
	q := make([][]Q, n)
	ans := make([]int64, r())
	for i := range ans {
		l, r := r(), r()
		q[l-1] = append(q[l-1], Q{r, i})
	}
	s := []int{}
	for i := n - 1; i >= 0; i-- {
		for len(s) > 0 {
			r := s[len(s)-1]
			v := int64(x[r]-x[i]) * int64(w[i]+w[r])
			for r := r + 1; r <= n; r += r & -r {
				if v < t[r] {
					t[r] = v
				}
			}
			if w[r] < w[i] {
				break
			}
			s = s[:len(s)-1]
		}
		s = append(s, i)
		for _, q := range q[i] {
			v := int64(9e18)
			for r := q.r; r > 0; r &= r - 1 {
				if t[r] < v {
					v = t[r]
				}
			}
			ans[q.i] = v
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

package main

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

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

	var n, m, l, r int
	Fscan(in, &n, &m)
	tree := make([]int64, n+1)
	pos := make([]int64, n)
	wt := make([]int64, n)
	update := func(l, r int) {
		v := (pos[r] - pos[l]) * (wt[l] + wt[r])
		for ; r <= n; r += r & -r {
			if v < tree[r] {
				tree[r] = v
			}
		}
	}
	for i := range wt {
		Fscan(in, &pos[i], &wt[i])
		tree[i+1] = 9e18
	}
	type query struct{ r, i int }
	qs := make([][]query, n)
	ans := make([]int64, m)
	for i := range ans {
		Fscan(in, &l, &r)
		qs[l-1] = append(qs[l-1], query{r, i})
	}
	stk := []int{}
	for i := n - 1; i >= 0; i-- {
		for len(stk) > 0 && wt[stk[len(stk)-1]] > wt[i] {
			update(i, stk[len(stk)-1])
			stk = stk[:len(stk)-1]
		}
		if len(stk) > 0 {
			update(i, stk[len(stk)-1])
		}
		stk = append(stk, i)
		for _, q := range qs[i] {
			mi := int64(9e18)
			for r := q.r; r > 0; r &= r - 1 {
				if tree[r] < mi {
					mi = tree[r]
				}
			}
			ans[q.i] = mi
		}
	}
	for _, v := range ans {
		Fprintln(out, v)
	}
}

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


You are given two integers $$$a$$$ and $$$b$$$.In one move, you can choose some integer $$$k$$$ from $$$1$$$ to $$$10$$$ and add it to $$$a$$$ or subtract it from $$$a$$$. In other words, you choose an integer $$$k \in [1; 10]$$$ and perform $$$a := a + k$$$ or $$$a := a - k$$$. You may use different values of $$$k$$$ in different moves.Your task is to find the minimum number of moves required to obtain $$$b$$$ from $$$a$$$.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains two integers $$$a$$$ and $$$b$$$ ($$$1 \le a, b \le 10^9$$$).

For each test case, print the answer: the minimum number of moves required to obtain $$$b$$$ from $$$a$$$.

NoteIn the first test case of the example, you don't need to do anything.In the second test case of the example, the following sequence of moves can be applied: $$$13 \rightarrow 23 \rightarrow 32 \rightarrow 42$$$ (add $$$10$$$, add $$$9$$$, add $$$10$$$).In the third test case of the example, the following sequence of moves can be applied: $$$18 \rightarrow 10 \rightarrow 4$$$ (subtract $$$8$$$, subtract $$$6$$$).

package main

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

func main() {
	sc := NewScanner()
	T := sc.NextInt()
	for i := 0; i < T; i++ {
		a, b := sc.NextInt(), sc.NextInt()
		k := abs(b - a)
		fmt.Println((k + 9) / 10)
	}

}

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

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

package main

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

func main() {
	// DEBUG ONLY
	// f, _ := os.Open("data.txt")
	// scanner := bufio.NewScanner(f)

	scanner := bufio.NewScanner(os.Stdin)

	var nCount int64
	if !scanner.Scan() {
		fmt.Println("Scanner error")
	}

	fmt.Sscanf(scanner.Text(), "%d", &nCount)

	var a, b int64

	for ; nCount > 0; nCount-- {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)

		a = a - b
		if a < 0 {
			a = -a
		}

		// calculate in how many steps we can reach 0
		res := a / 10
		if (a % 10) != 0 {
			res += 1
		}
		fmt.Println(res)
	}

}

package main

// A. Yet Another Two Integers Problem
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// You are given two integers a
// and b

// .

// In one move, you can choose some integer k
// from 1 to 10 and add it to a or subtract it from a. In other words, you choose an integer k∈[1;10] and perform a:=a+k or a:=a−k. You may use different values of k

// in different moves.

// Your task is to find the minimum number of moves required to obtain b
// from a

// .

// You have to answer t

// independent test cases.
// Input

// The first line of the input contains one integer t
// (1≤t≤2⋅104) — the number of test cases. Then t

// test cases follow.

// The only line of the test case contains two integers a
// and b (1≤a,b≤109

// ).
// Output

// For each test case, print the answer: the minimum number of moves required to obtain b
// from a.

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

var (
    bufStdin  = bufio.NewReader(os.Stdin)
    bufStdout = bufio.NewWriter(os.Stdout)
)

func main() {
    defer bufStdout.Flush()

    var t int
    _, _ = fmt.Fscan(bufStdin, &t)

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

        // the minimum number of steps from a to b is the absolute difference divided by 10 (using integer division) plus 1 if there is a remainder
        // we want to take the largest possible steps (of size 10) until we need to take a step of less than 10
        // e.g. 78 -> 112 we go 78 -> 88 -> 98 -> 108 -> 114, 4 steps
        // 112 - 78 = 34, 34/10 = 3, since there is a remainder of this division (4), that is one more step we must take

        absDiff := intAbs(a - b)

        steps := absDiff / 10 // size 10 steps
        if absDiff % 10 != 0 {
            steps++ // final step if the size 10 steps did not suffice
        }

        _, _ = fmt.Fprintln(bufStdout, steps)
    }
}

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

package main

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

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

// parse integer from byte slice
func parseInt(a []byte, pos int) (ans, newpos int) {
	for pos < len(a) && a[pos] >= '0' && a[pos] <= '9' {
		pos, ans = pos+1, 10*ans+int(a[pos]-'0')
	}
	return ans, pos + 1
}

// https://codeforces.com/problemset/problem/1409/A
// комментарии к решению
// fmt.Scan для нас удобнее, но на большом входном потоке он падает по TLE,
// поэтому читаем []byte и парсим самостоятельно.
// Для буферизованного вывода используем fmt.Sprint , с заменой пробелов
// на \n. Кол-во замен и их размер (1 байт == ' ' на 1 байт == '\n') известно,
// поэтому будет сгенерирован оптимальный код без большого оверхеда
func taskSolution(in []byte, t int) string {
	ans := make([]int, t)
	var a, b, diff int
	for i, pos := 0, 0; i < t; i += 1 {
		for in[pos] < '0' || in[pos] > '9' {
			pos += 1
		}
		a, pos = parseInt(in, pos)
		b, pos = parseInt(in, pos)
		diff = abs(b - a)
		ans[i] = diff / 10
		if diff%10 != 0 {
			ans[i] += 1
		}
	}
	res := fmt.Sprint(ans)
	return strings.Replace(res[1:len(res)-1], " ", "\n", len(ans)-1)
}

func main() {
	var t int
	if _, err := fmt.Scan(&t); err != nil {
		panic(err)
	}

	inRaw, err := ioutil.ReadAll(os.Stdin)
	if err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(inRaw, t))
}

package main

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

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

	scanInt := func(n *int) {
		scanner.Scan()
		num, _ := strconv.ParseInt(scanner.Text(), 10, 32)
		*n = int(num)
	}
	scanInt64 := func(n *int64) {
		scanner.Scan()
		num, _ := strconv.ParseInt(scanner.Text(), 10, 64)
		*n = num
	}

	var n int
	var a, b int64
	scanInt(&n) // number of cases

	for i := 0; i < n; i++ {
		scanInt64(&a)
		scanInt64(&b)

		diff := math.Abs(float64(a) - float64(b))
		moves := math.Ceil(diff / 10)
		fmt.Println(int64(moves))
	}
}

package main

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

func main() {
	var t, a, b int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		fmt.Fscan(in, &a, &b)
		fmt.Printf("%.0f\n", math.Ceil(float64(abs(a-b))/10.0))
	}
}

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

package main

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

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

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

func main() {
	var t int
	var a, b, diff, count int

	//Scan the testcase numbers
	scanf("%d\n", &t)

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

		// Scan the two integers
		scanf("%d %d\n", &a, &b)

		// Calculate the result
		if a < b {
			diff = b - a
		} else if b < a {
			diff = a - b
		} else {
			printf("0\n")
			writer.Flush()
			continue
		}

		count = diff / 10
		if diff%10 != 0 {
			count++
		}
		printf("%d\n", count)
		writer.Flush()
	}

}

package main

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

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

	T:= 0
	for Fscan(in, &T); T > 0; T-- {
		var a,b int
		Fscan(in, &a, &b);
		a-=b;
		if a<0 {
			a*=-1;
		}
		Fprintln(out,(a+9)/10)
	}
}

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

package main

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

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

package main

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

func readLine(reader *bufio.Reader) string {
	line, _ := reader.ReadString('\n')

	return strings.Replace(line, "\r\n", "", -1)
}

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

	n, _ := strconv.Atoi(readLine(reader))

	for i := 0; i < n; i++ {
		nmrs := strings.Split(readLine(reader), " ")

		n1, _ := strconv.Atoi(nmrs[0])
		n2, _ := strconv.Atoi(nmrs[1])

		n3 := (int)(math.Abs((float64)(n1 - n2)))

		result := (n3 + 9) / 10

		fmt.Println(result)
	}
}

package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    text, _, _ := reader.ReadLine()
    zn, _ := strconv.Atoi(string(text))
    for i := 1; i <= zn; i++ {
        text, _, _ = reader.ReadLine()
        m := strings.Split(string(text), " ")
        a, _ := strconv.Atoi(m[0])
        b, _ := strconv.Atoi(m[1])
        r := math.Floor(math.Abs(float64(a-b))/10)
        if r*10 != math.Abs(float64(a-b)) {
            r ++
        }
        fmt.Printf("%0.0f\n", r)
    }
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for tt := io.NextInt(); tt > 0; tt-- {
		a, b := io.NextInt(), io.NextInt()
		v := a - b
		if a < b {
			v = -v
		}
		ans := v / 10
		if v%10 != 0 {
			ans++
		}
		io.Println(ans)
	}
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}

package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	for t := io.NextInt(); t > 0; t-- {
		a, b := io.NextInt(), io.NextInt()
		if a < b {
			a, b = b, a
		}
		io.Println((a - b + 9) / 10)
	}
}

type FastIO struct {
	*bufio.Writer
	r    io.Reader
	buf  [8192]byte
	i, n int
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{r: r, Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	if f.i == f.n {
		f.n, _ = f.r.Read(f.buf[:])
		if f.n == 0 {
			panic("EOF")
		}
		f.i = 0
	}
	f.i++
	return f.buf[f.i-1]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f, a...)
}

package main

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

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

	return i
}

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

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

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

		d := abs(a - b)

		n := d/10

		if d%10 != 0 {
			n++
		}

		fmt.Println(n)
	}

}

package main

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

func main(){
	var (
		t,a,b int
	)
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i:=1;i<=t;i++{
		fmt.Fscan(in, &a, &b)
		a=a-b
		if a<0 {
			a=a*-1
		}
		if a%10==0{
			fmt.Println(a/10)
		}else{
			fmt.Println((a+10)/10)
		}
	}
}

package main

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

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

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

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

package main

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var a, b int

		fmt.Fscan(input, &a, &b)

		if a == b {
			fmt.Println(0)
			continue
		}

		ans := 0
		tp := math.Abs(float64(a - b))

		if tp > 10 {
			ans += int(tp / 10)
			if (int(tp) % 10) > 0 {
				ans++
			}
		} else {
			ans++
		}

		fmt.Println(ans)
	}
}

package main

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

func main() {
	var t int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &t)
	for i := 0; i < t; i++ {
		var a, b uint
		fmt.Fscan(in, &a, &b)
		if a == b {
			fmt.Println(0)
		} else if a > b {
			fmt.Println(int(math.Ceil(float64(a-b) / 10)))
		} else if a < b {
			fmt.Println(int(math.Ceil(float64(b-a) / 10)))
		}
	}
}

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() {
	a, b := 0, 0
	scanf("%d %d\n", &a, &b)

	if a > b {
		a, b = b, a
	}

	q := (b - a) / 10
	if q * 10 != b - a {
		q++
	}
	printf("%d\n", q)
}

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

	writer.Flush()
}

package main

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

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

func main() {
	var t,i int
	scanf("%d\n", &t)
	ans  := make([] int, t)
	for i = 1; i<=t; i++ {

		var a, b, temp int
		scanf("%d %d\n", &a, &b)

		if a == b { ans[i-1] = 0 }

		if b > a {
			temp  = b
			b = a
			a = temp
		}

		interest := a - b

		if interest%10 == 0 {
			ans[i-1] = interest/10
		} else {
			ans[i-1] = interest/10 + 1
		}
	}
	for i = 0; i<t; i++ {
		fmt.Println( ans[i])
	}

}

package main

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

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

func main() {

	 defer writer.Flush()

	var t,i int
	scanf("%d\n", &t)
	ans  := make([] int, t)
	for i = 1; i<=t; i++ {

		var a, b, temp int
		scanf("%d %d\n", &a, &b)

		if a == b { ans[i-1] = 0 }

		if b > a {
			temp  = b
			b = a
			a = temp
		}

		interest := a - b

		if interest%10 == 0 {
			ans[i-1] = interest/10
		} else {
			ans[i-1] = interest/10 + 1
		}
	}
	for i = 0; i<t; i++ {
		printf("%d\n", ans[i])
	}

}

package main

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

func main() {
	// DEBUG ONLY
	// f, _ := os.Open("data.txt")
	// scanner := bufio.NewScanner(f)

	scanner := bufio.NewScanner(os.Stdin)

	var nCount int64
	if !scanner.Scan() {
		println("Scanner error")
	}

	fmt.Sscanf(scanner.Text(), "%d", &nCount)
	println("nCount is ", nCount)

	var a, b int64

	for ; nCount > 0; nCount-- {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)
		println("Data ", a, b)

		a = a - b
		if a < 0 {
			a = -a
		}

		// calculate in how many steps we can reach 0
		res := a / 10
		if (a % 10) != 0 {
			res += 1
		}
		print(res, "\n")
	}

}

package main

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

func main() {
	// DEBUG ONLY
	// f, _ := os.Open("data.txt")
	// scanner := bufio.NewScanner(f)

	println("Starting the program!")

	scanner := bufio.NewScanner(os.Stdin)

	var nCount int64
	if !scanner.Scan() {
		println("Scanner error")
	}

	fmt.Sscanf(scanner.Text(), "%d", &nCount)
	println("nCount is ", nCount)

	var a, b int64

	for ; nCount > 0; nCount-- {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)
		println("Data ", a, b)

		a = a - b
		if a < 0 {
			a = -a
		}

		// calculate in how many steps we can reach 0
		res := a / 10
		if (a % 10) != 0 {
			res += 1
		}
		print(res, "\n")
	}

}

package main

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

func main() {
	// DEBUG ONLY
	// f, _ := os.Open("data.txt")
	// scanner := bufio.NewScanner(f)

	scanner := bufio.NewScanner(os.Stdin)

	var nCount int64
	scanner.Scan()

	fmt.Sscanf(scanner.Text(), "%d", &nCount)
	var a, b int64

	for ; nCount > 0; nCount-- {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)

		a = a - b
		if a < 0 {
			a = -a
		}

		// calculate in how many steps we can reach 0
		res := a / 10
		if (a % 10) != 0 {
			res += 1
		}
		print(res, "\n")
	}

}

package main

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

func main() {
	// DEBUG ONLY
	// f, _ := os.Open("data.txt")
	// scanner := bufio.NewScanner(f)

	scanner := bufio.NewScanner(os.Stdin)

	var nCount int64
	scanner.Scan()

	fmt.Sscanf(scanner.Text(), "%d", &nCount)
	var a, b int64

	for ; nCount > 0; nCount-- {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)

		a = a - b
		if a < 0 {
			a = -a
		}

		// calculate in how many steps we can reach 0
		res := a / 10
		if (a % 10) != 0 {
			res += 1
		}
		println(res)
	}

}

package main

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

func main() {
	// DEBUG ONLY
	// f, _ := os.Open("data.txt")
	// scanner := bufio.NewScanner(f)

	fmt.Println("Starting the program!")

	scanner := bufio.NewScanner(os.Stdin)

	var nCount int64
	if !scanner.Scan() {
		fmt.Println("Scanner error")
	}

	fmt.Sscanf(scanner.Text(), "%d", &nCount)
	fmt.Println("nCount is ", nCount)

	var a, b int64

	for ; nCount > 0; nCount-- {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d %d", &a, &b)
		fmt.Println("Data ", a, b)

		a = a - b
		if a < 0 {
			a = -a
		}

		// calculate in how many steps we can reach 0
		res := a / 10
		if (a % 10) != 0 {
			res += 1
		}
		fmt.Println(res)
	}

}

package main

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

func readLine(reader *bufio.Reader) string {
	line, _ := reader.ReadString('\n')

	return strings.Replace(line, "\r\n", "", -1)
}

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

	n, _ := strconv.Atoi(readLine(reader))

	for i := 0; i < n; i++ {
		nmrs := strings.Split(readLine(reader), " ")

		n1, _ := strconv.Atoi(nmrs[0])
		n2, _ := strconv.Atoi(nmrs[1])

		n3 := (int)(math.Abs((float64)(n1 - n2)))

		result := n3 / 10

		if (result % 10) > 0 {
			result++
		}

		fmt.Println(result)
	}
}

package main

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

func readLine(reader *bufio.Reader) string {
	line, _ := reader.ReadString('\n')

	return strings.Replace(line, "\r\n", "", -1)
}

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

	n, _ := strconv.Atoi(readLine(reader))

	for i := 0; i < n; i++ {
		nmrs := strings.Split(readLine(reader), " ")

		n1, _ := strconv.Atoi(nmrs[0])
		n2, _ := strconv.Atoi(nmrs[1])

		n3 := (int)(math.Abs((float64)(n1 - n2)))

		result := (n3 + 9) / 10

		if (result % 10) > 0 {
			result++
		}

		fmt.Println(result)
	}
}

package main

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

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

	return i
}

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

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

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

		d := abs(a - b)

		n := d/10 + d%10

		fmt.Println(n)
	}

}

package main

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

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &t)

	for o := 0; o < t; o++ {
		var a, b int

		fmt.Fscan(input, &a, &b)

		ans := 0
		tp := math.Abs(float64(a - b))

		if tp > 10 {
			ans += int(tp / 10)
			if (int(tp) % 10) > 0 {
				ans++
			}
		} else {
			ans++
		}

		fmt.Println(ans)
	}
}


Burenka came to kindergarden. This kindergarten is quite strange, so each kid there receives two fractions ($$$\frac{a}{b}$$$ and $$$\frac{c}{d}$$$) with integer numerators and denominators. Then children are commanded to play with their fractions.Burenka is a clever kid, so she noticed that when she claps once, she can multiply numerator or denominator of one of her two fractions by any integer of her choice (but she can't multiply denominators by $$$0$$$). Now she wants know the minimal number of claps to make her fractions equal (by value). Please help her and find the required number of claps!

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases. Then follow the descriptions of each test case. The only line of each test case contains four integers $$$a$$$, $$$b$$$, $$$c$$$ and $$$d$$$ ($$$0 \leq a, c \leq 10^9$$$, $$$1 \leq b, d \leq 10^9$$$) — numerators and denominators of the fractions given to Burenka initially.

For each test case print a single integer — the minimal number of claps Burenka needs to make her fractions equal.

NoteIn the first case, Burenka can multiply $$$c$$$ by $$$2$$$, then the fractions will be equal.In the second case, fractions are already equal.In the third case, Burenka can multiply $$$a$$$ by $$$4$$$, then $$$b$$$ by $$$3$$$. Then the fractions will be equal ($$$\frac{1 \cdot 4}{2 \cdot 3} = \frac{2}{3}$$$).

package main

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

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

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

		if (a == 0 && c == 0) || (a == c && b == d) || (a*d == c*b) {
			fmt.Fprintln(out, 0)
		} else if a == 0 || c == 0 || (a*d)%(b*c) == 0 || (b*c)%(a*d) == 0 {
			fmt.Fprintln(out, 1)
		} else {
			fmt.Fprintln(out, 2)
		}
	}
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var a, b, c, d int64
		fmt.Fscan(r, &a, &b, &c, &d)
		w1 := do(a, b, c, d)
		fmt.Fprintln(w, w1)
	}
}

func do(a, b, c, d int64) int {
	if a == 0 && c == 0 {
		return 0
	}
	if a == 0 || c == 0 {
		return 1
	}
	a, b = frac(a, b)
	c, d = frac(c, d)
	bd := lcm(b, d)
	a *= bd / b
	c *= bd / d
	ac := lcm(a, c)
	if a == ac && c == ac {
		return 0
	}
	if a == ac || c == ac {
		return 1
	}
	return 2
}

func frac(a, b int64) (int64, int64) {
	ab := gcd(a, b)
	return a / ab, b / ab
}

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

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

package main

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

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

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

// func min3(a, b, c int) int {
// 	return min(min(a, b), c)
// }

// func maxSquare(a int) int {
// 	tmp := int(math.Sqrt(float64(a)))
// 	if tmp*tmp == a {
// 		return tmp * tmp
// 	} else {
// 		return (tmp + 1) * (tmp + 1)
// 	}
// }

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var niter int
	fmt.Fscan(in, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var a, b, c, d int64
		fmt.Fscan(in, &a, &b, &c, &d)
		fr1 := a * d
		fr2 := c * b
		if fr1 == fr2 {
			fmt.Fprintln(out, "0")
		} else {
			if fr1 == 0 || fr2 == 0 || fr2%fr1 == 0 || fr1%fr2 == 0 {
				fmt.Fprintln(out, "1")
			} else {
				fmt.Fprintln(out, "2")
			}
		}
	}
}

	package main

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

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

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

		var T int
		var a int64
		var b int64
		var c int64
		var d int64

		for Fscan(in, &T); T > 0; T-- {
			Fscan(in, &a)
			Fscan(in, &b)
			Fscan(in, &c)
			Fscan(in, &d)

			if a == 0 && c == 0 {
				Fprintln(out, 0)
			} else if a == 0 || c == 0 {
				Fprintln(out, 1)
			} else {
				if a * d == b * c {
					Fprintln(out, 0)
				} else if (c * b) % (a *d) == 0 || (a * d) % (c * b) == 0 {
					Fprintln(out, 1)
				} else {
					Fprintln(out, 2)
				}
			}

		}
	}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		arr := readArrInt64(input)
		fmt.Println(solve(arr))
	}
}

func solve(arr []int64) int64 {
	a := arr[0]
	b := arr[1]
	c := arr[2]
	d := arr[3]
	ad := a * d
	bc := b * c
	if ad == bc {
		return 0
	} else if (a == 0 && c != 0) || (c == 0 && a != 0) || ad%bc == 0 || bc%ad == 0 {
		return 1
	}
	return 2
}

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

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return int64(n)
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1720A
Date: 8/27/2022
User: wotan
URL: https://codeforces.com/contest/1720/problem/A
Problem: CF1720A
**/
func (in *CF1720A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		a, b, c, d := in.NextInt64(), in.NextInt64(), in.NextInt64(), in.NextInt64()
		x := a * d
		y := b * c
		if x == y {
			fmt.Println(0)
		} else if y != 0 && x%y == 0 || x != 0 && y%x == 0 {
          fmt.Println(1)
		}else{
          fmt.Println(2)
      }
	}
}

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

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

package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanln(in, &t)
	for t > 0 {
		var a, b, c, d int64
		fmt.Fscanln(in, &a, &b, &c, &d)
		solve(a, b, c, d)
		t--
	}
}
func solve(a, b, c, d int64) {
	a, c = a*d, c*b
	if a == c {
		fmt.Println(0)
	} else if a == 0 || c == 0 || a%c == 0 || c%a == 0 {
		fmt.Println(1)
	} else {
		fmt.Println(2)
	}
}

package main

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

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

func solve(a, b, c, d int64) int {
	if a*d == b*c {
		return 0
	}
	if a == 0 || c == 0 || a*d%(b*c) == 0 || b*c%(a*d) == 0 {
		return 1
	}
	return 2
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		var a, b, c, d int64
		fmt.Fscan(reader, &a, &b, &c, &d)
		fmt.Println(solve(a, b, c, d))
	}
}

package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}
func solve() {
	var a,b,c,d int64
	scan(&a, &b, &c, &d)
	p1 := a*d
	p2 := b*c
	if p1 == p2{
		printf("0\n")
	} else if p1*p2 == 0 || p1 % p2 == 0 || p2 % p1 == 0{
		printf("1\n")
	} else {
		printf("2\n")
	}

}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}

package main

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

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

	var t int
	Fscan(in, &t)
	for t > 0 {
		t--
		var a, b, c, d int64
		Fscan(in, &a, &b, &c, &d)
		a = a * d
		c = c * b
		if a == c {
			Fprintln(out, 0)
		} else if a == 0 || c == 0 || a % c == 0 || c % a == 0 {
			Fprintln(out, 1)
		} else {
			Fprintln(out, 2)
		}
	}
}

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

package main

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

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

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

		if (a == 0 && c == 0) || (a == c && b == d) {
			fmt.Fprintln(out, 0)
		} else if a == 0 || c == 0 || (a*d)%(b*c) == 0 || (b*c)%(a*d) == 0 {
			fmt.Fprintln(out, 1)
		} else {
			fmt.Fprintln(out, 2)
		}
	}
}

package main

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

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

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

		if (a == 0 && c == 0) || (a == c && b == d) || (a/b == c/d && a/b > 0) {
			fmt.Fprintln(out, 0)
		} else if a == 0 || c == 0 || (a*d)%(b*c) == 0 || (b*c)%(a*d) == 0 {
			fmt.Fprintln(out, 1)
		} else {
			fmt.Fprintln(out, 2)
		}
	}
}

package main

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

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

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

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

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

		if (a == 0 && c == 0) || (a == c && b == d) || (a/b == c/d && a/b > 0) {
			fmt.Fprintln(out, 0)
		} else if a == 0 || c == 0 || (a*d)%(b*c) == 0 || (b*c)%(a*d) == 0 {
			fmt.Fprintln(out, 1)
		} else {
			fmt.Fprintln(out, 2)
		}
	}
}

package main

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

var _, _, _ = main, rw, do

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

func rw(r io.Reader, w io.Writer) {
	var t int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		var a, b, c, d int64
		fmt.Fscan(r, &a, &b, &c, &d)
		w1 := do(a, b, c, d)
		fmt.Fprintln(w, w1)
	}
}

func do(a, b, c, d int64) int {
	if a == 0 && c == 0 {
		return 0
	}
	if a == 0 || c == 0 {
		return 1
	}
	bd := lcm(b, d)
	a *= bd / b
	c *= bd / d
	ac := lcm(a, c)
	if a == ac && c == ac {
		return 0
	}
	if a == ac || c == ac {
		return 1
	}
	return 2
}

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

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

package main

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

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

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

// func min3(a, b, c int) int {
// 	return min(min(a, b), c)
// }

// func maxSquare(a int) int {
// 	tmp := int(math.Sqrt(float64(a)))
// 	if tmp*tmp == a {
// 		return tmp * tmp
// 	} else {
// 		return (tmp + 1) * (tmp + 1)
// 	}
// }

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var niter int
	fmt.Fscan(in, &niter)
	for iiter := 0; iiter < niter; iiter++ {
		var a, b, c, d float64
		fmt.Fscan(in, &a, &b, &c, &d)
		eps := 0.0000000001
		if math.Abs((a/b)-(c/d)) < eps {
			fmt.Fprintln(out, "0")
		} else {
			first := a / b
			second := c / d
			if math.Abs(first-0) < eps || math.Abs(second-0) < eps {
				fmt.Fprintln(out, "1")
			} else {
				_, frac1 := math.Modf(second / first)
				_, frac2 := math.Modf(first / second)
				if math.Abs(frac1-0) < eps || math.Abs(frac2-0) < eps {
					fmt.Fprintln(out, "1")
				} else {
					fmt.Fprintln(out, "2")
				}
			}
		}
	}
}

package main

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

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

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

	var T int
	var a int
	var b int
	var c int
	var d int

	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &a)
		Fscan(in, &b)
		Fscan(in, &c)
		Fscan(in, &d)

		if a == 0 && c == 0 {
			Fprintln(out, 0)
		} else if a == 0 || c == 0 {
			Fprintln(out, 1)
		} else {
			if a * d == b * c {
				Fprintln(out, 0)
			} else if (c * b) % (a *d) == 0 || (a * d) % (c * b) == 0 {
				Fprintln(out, 1)
			} else {
				Fprintln(out, 2)
			}
		}

	}
}

package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	cases := readInt(input)
	for asdf := 0; asdf < cases; asdf++ {
		arr := readArrInt(input)
		fmt.Println(solve(arr))
	}
}

func solve(arr []int) int {
	a := arr[0]
	b := arr[1]
	c := arr[2]
	d := arr[3]
	ad := a * d
	bc := b * c
	if ad == bc {
		return 0
	} else if (a == 0 && c != 0) || (c == 0 && a != 0) || ad%bc == 0 || bc%ad == 0 {
		return 1
	}
	return 2
}

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

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

func readInt(in *bufio.Reader) int {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return n
}

func readInt64(in *bufio.Reader) int64 {
	nStr, _ := in.ReadString('\n')
	nStr = strings.ReplaceAll(nStr, "\r", "")
	nStr = strings.ReplaceAll(nStr, "\n", "")
	n, _ := strconv.Atoi(nStr)
	return int64(n)
}

func readLineNumbs(in *bufio.Reader) []string {
	line, _ := in.ReadString('\n')
	line = strings.ReplaceAll(line, "\r", "")
	line = strings.ReplaceAll(line, "\n", "")
	numbs := strings.Split(line, " ")
	return numbs
}

func readArrInt(in *bufio.Reader) []int {
	numbs := readLineNumbs(in)
	arr := make([]int, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.Atoi(n)
		arr[i] = val
	}
	return arr
}

func readArrInt64(in *bufio.Reader) []int64 {
	numbs := readLineNumbs(in)
	arr := make([]int64, len(numbs))
	for i, n := range numbs {
		val, _ := strconv.ParseInt(n, 10, 64)
		arr[i] = val
	}
	return arr
}


You are given two integers $$$n$$$ and $$$k$$$. You are asked to choose maximum number of distinct integers from $$$1$$$ to $$$n$$$ so that there is no subset of chosen numbers with sum equal to $$$k$$$.A subset of a set is a set that can be obtained from initial one by removing some (possibly all or none) elements of it.

The first line contains the number of test cases $$$T$$$ ($$$1 \le T \le 100$$$). Each of the next $$$T$$$ lines contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 1000$$$) — the description of test cases.

For each test case output two lines. In the first line output a single integer $$$m$$$ — the number of chosen integers. In the second line output $$$m$$$ distinct integers from $$$1$$$ to $$$n$$$ — the chosen numbers. If there are multiple answers, print any. You can print the numbers in any order.

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := ScanInt(); t > 0; t-- {
		n, k := ScanInt(), ScanInt()
		a := []int{}

		for i := (k + 1) / 2; i <= n; i++ {
			if i != k {
				a = append(a, i)
			}
		}

		fmt.Println(len(a))
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	}
}

package main

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

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

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

func main() {
	defer out.Flush()

	var T, n, k int32
	scan(&T)

	for T > 0 {
		T--
		scan(&n, &k)
		var arr []int32

		for i:=k+1; i<=n; i++ {
			arr = append(arr, i)
		}

		for i:=(k>>1)+(k&1); i<k; i++ {
			arr = append(arr, i)
		}

		println(len(arr))
		for k, v := range arr {
			if k > 0 {
				printf(" ")
			}
			printf("%d", v)
		}
		println("")
	}
}

package main

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

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

	var T, n, k int32
	fmt.Fscan(in, &T)

	for T > 0 {
		T--
		fmt.Fscan(in, &n, &k)
		var arr []int32

		for i:=k+1; i<=n; i++ {
			arr = append(arr, i)
		}

		for i:=(k>>1)+(k&1); i<k; i++ {
			arr = append(arr, i)
		}

		fmt.Fprintln(out, len(arr))
		for k, v := range arr {
			if k > 0 {
				fmt.Fprintf(out, " ")
			}
			fmt.Fprintf(out, "%d", v)
		}
		fmt.Fprintln(out, "")

	}
}

package main

import  "fmt"

func main() {
	var T, n, k int32
	fmt.Scan(&T)

	for T > 0 {
		T--
		fmt.Scan(&n, &k)
		var arr []int32

		for i:=k+1; i<=n; i++ {
			arr = append(arr, i)
		}

		for i:=(k>>1)+(k&1); i<k; i++ {
			arr = append(arr, i)
		}

		fmt.Println(len(arr))
		for k, v := range arr {
			if k > 0 {
				fmt.Printf(" ")
			}
			fmt.Printf("%d", v)
		}
		fmt.Println("")

	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1493A
Date: 8/12/21
User: epradere
URL: https://codeforces.com/problemset/problem/1493/A
Problem: CF1493A
**/
func (in *CF1493A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, k := in.NextInt(), in.NextInt()
		var str strings.Builder
		size := 0
		for i := 1; i <= n; i++ {
			if i != k {
				if k-i > 0 && k-i < k && k-i > i {
					continue
				} else {
					size++
					str.WriteString(strconv.Itoa(i)+ " ")
				}
			}
		}
		fmt.Println(size)
		if size > 0 {
			fmt.Println(str.String())
		}
	}
}

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

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

package main

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

type Building struct {
	number     int
	coordinate int
	visit      int
}

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

func solve(n, k int) string {
	r := n - k + k/2
	x := fmt.Sprintln(r)
	for i := n; i > k; i-- {
		x += fmt.Sprint(i) + " "
	}
	for i := k - 1; i >= (k+1)/2; i-- {
		x += fmt.Sprint(i) + " "
	}
	return x
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &k)
		fmt.Println(solve(n, k))
	}
}

package main
import ."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var T, n, k int
	for Scan(&T); T > 0; T-- {
		Scan(&n, &k)
		a := []interface{}{}
		for i := (k + 1) / 2; i < k; i++ {
			a = append(a, i)
		}
		for i := k + 1; i <= n; i++ {
			a = append(a, i)
		}
		Println(len(a))
		Println(a...)
	}
}

package main

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

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

	var T, n, k int
	for Fscan(in, &T); T > 0; T-- {
		Fscan(in, &n, &k)
		ans := []interface{}{}
		for i := (k + 1) / 2; i < k; i++ {
			ans = append(ans, i)
		}
		for i := k + 1; i <= n; i++ {
			ans = append(ans, i)
		}
		Fprintln(out, len(ans))
		Fprintln(out, ans...)
	}
}

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

package main

import (
	"container/list"
	"fmt"
)
func work(){
	var n,k int
	fmt.Scanf("%d %d\n",&n,&k)
	a:=list.New()
	for i:=n;i>k;i--{
		a.PushBack(i)
	}
	for i:=k-1;i>=(k+1)/2;i--{
		a.PushBack(i)
	}
	fmt.Println(a.Len())
	for x:=a.Front();x!=nil;x=x.Next(){
		fmt.Printf("%d ",x.Value)
	}
	fmt.Println("")
}
func main() {
	var T int
	fmt.Scanf("%d\n",&T)
	for cas:=1;cas<=T;cas++{
		work()
	}
	return
}

package main

import . "fmt"
/*
	快速移动当前行 shift + command + ⬆
	删除当前行    command + 删除
	查找+替换	command + R
*/
var (
	T int
	s []byte
	n int
	k int
)

func main() {

	for Scan(&T); T > 0; T-- {
		Scan(&n)
		Scan(&k)
		ans := []int{}
		for i:=k+1;i<=n;i++ {
			ans=append(ans,i)
		}
		lo := k / 2
		if (k & 1) == 1{
			lo ++
		}
		for i:=lo;i<k;i++ {
			ans=append(ans,i)
		}
		Println(len(ans))
		for _,v:=range(ans) {
			Printf("%v ",v)
		}
		Println()

	}
}

package main

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

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

func print(a ...interface{}) { fmt.Fprint(writer, a...) }
func scan(a ...interface{})  { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()
	////////////////////
	var count int
	scan(&count)
	for count != 0 {
		solve()
		count--
	}

}

func solve() {
	n, k := 0, 0
	scan(&n, &k)
	m := make([]int, 0)
	for i := 1; i < (k+1)/2; i++ {
		if k-i == i {
			m = append(m, i)
			continue
		}
		if k-i < 0 {
			m = append(m, i)
		}
	}
	for i := (k + 1) / 2; i <= n; i++ {
		if i != k {
			m = append(m, i)
		}
	}
	print(len(m), "\n")
	for _, v := range m {
		print(v, " ")
	}
	print("\n")
}

package main

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

func solveA() {
	n, k := 0, 0
	scan(&n, &k)

	choosed := make([]int, 0)
	res := 0
	for i := k - 1; i >= (k+1)/2; i-- {
		choosed = append(choosed, i)
		res++
	}
	for i := k + 1; i <= n; i++ {
		choosed = append(choosed, i)
		res++
	}
	printf("%d\n", res)
	for _, i := range choosed {
		printf("%d ", i)
	}
	printf("\n")
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solveA()
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}

package main
// github.com/jamesgrimard/codeforces
import(
    "fmt"
    "bufio"
    "os"
)
func main() {
	in:= bufio.NewReader(os.Stdin)
	out:= bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var t int
	fmt.Fscan(in,&t)
	for i:=0;i<t;i++{
		var n,k int
		fmt.Fscan(in,&n,&k)
		fmt.Fprintln(out, n - (k-1)/2 - 1)
		for j:=(k-1)/2+1;j<=n;j++{
			if j != k {
				fmt.Fprintf(out,"%v ",j)
			}
		}
		fmt.Fprintln(out)
	}
}

package main

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

func solve() {
	f := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	N, n, k := 0, 0, 0
	fmt.Fscan(f, &N)
	for i := 0; i < N; i++ {
		fmt.Fscan(f, &n, &k)
		o := []int{}
		for j := k + 1; j <= n; j++ {
			o = append(o, j)
		}
		for j := k - 1; j >= (k+1)/2; j-- {
			o = append(o, j)
		}
		fmt.Fprintln(w, len(o))
		for _, v := range o {
			fmt.Fprint(w, v, " ")
		}
		fmt.Fprintln(w, "")
	}
	w.Flush()
}

func main() {
	solve()
}

package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	var n int
	n = 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(n, k int) {
	fmt.Println(n - (k+1)/2)
	for z := (k + 1) / 2; z <= n; z++ {
		if z != k {
			fmt.Printf("%d ", z)
		}
	}
	fmt.Println()
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var i, n, k int
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	i = fastGetInt(scanner.Bytes())
	for z := 0; z < i; z++ {
		scanner.Scan()
		n = fastGetInt(scanner.Bytes())
		scanner.Scan()
		k = fastGetInt(scanner.Bytes())
		solution(n, k)
	}
	//======================================================

	//==================== OUTPUT ==========================

}

package main

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

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

It is obivous that any number that is greater than k is a free pick.
so for number 1..k-1, we prove that there is no picker longer than {floor(k/2)..k-1}.
If there is a pick that is longer than that, we divide it into two groups: {1..floor(k-2)-1}
and {floor(k-2)..k-1}. Since it is longer, there must be an a in the first one and a b in the second
one such `a` + `b` = `k`.

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

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

	var T int
	fmt.Fscanln(input, &T)

	for ; T > 0; T-- {
		var n, k int
		fmt.Fscanln(input, &n, &k)
		var m int
		if n > k {
			m = n - k
		}
		m += (k - 1) - (k+1)/2 + 1
		fmt.Fprintln(output, m)
		for i := n; i > k; i-- {
			fmt.Fprintf(output, "%d ", i)
		}
		for i := k - 1; i >= (k+1)/2; i-- {
			fmt.Fprintf(output, "%d ", i)
		}
		fmt.Fprintln(output)
	}
}

package main

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

func main() {

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

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

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

		var n, k int
		fmt.Fscan(in, &n, &k)

		a := make([]int, 0, n)
		for i := n; i >= 1; i-- {
			if i == k || k-i > i {
				continue
			}
			a = append(a, i)
		}

		fmt.Fprintln(out, len(a))
		for i := 0; i < len(a); i++ {
			fmt.Fprint(out, a[i], " ")
		}
		fmt.Fprintln(out)

	}

}

package main

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

// var m []int
// err = json.Unmarshal([]byte(r.FormValue("example")), &m)

// for i := 0; i < len(m); i++ {
// 	fmt.Println(m[i])
// }

func MIN(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func MAX(x, y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

func LCM(x, y int) int {
	if x >= y {
		initial := x
		for i := 1; i < y+2; i++ {
			if initial%y == 0 {
				break
			} else {
				initial = initial + x
			}

		}
		return initial
	} else {
		initial := y
		for i := 1; i < x+2; i++ {
			if initial%x == 0 {
				break
			} else {
				initial = initial + y
			}

		}
		return initial
	}
}

func IsItPrime(x int) bool {
	if x < 10 {
		if x == 2 || x == 3 || x == 5 || x == 7 {
			return true
		} else {
			return false
		}
	} else {
		j := 0
		k := math.Sqrt(float64(x))
		for m := 3; m <= int(k); {
			if x%m == 0 {
				j = 1
				break
			}
			m = m + 2
		}
		if j == 1 {
			return false
		} else {
			return true
		}
	}

}

// sort.Slice(arr, func(i, j int) bool {
// 	return arr[i] > arr[j]
// })

var t int

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &t)
	for o := 0; o < t; o++ {
		var n, k int
		fmt.Fscan(input, &n)
		fmt.Fscan(input, &k)

		if k%2 == 0 {
			m := int(k / 2)
			fmt.Println(n - m)
			for i := m; i < n+1; i++ {
				if i != k {
					fmt.Println(i)
				}
			}
		} else {
			m := int(k / 2)
			fmt.Println(n - m - 1)
			for i := m + 1; i < n+1; i++ {
				if i != k {
					fmt.Println(i)
				}
			}
		}

	}
}

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

package main

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

var (
	println = fmt.Println

	t    int
	n, k int
)

func main() {
	defer stdout.Flush()

	t = readi()
	for tc := 0; tc < t; tc++ {
		n, k = readi2()
		solve()
	}
}

func solve() {
	// ans := n - k
	// ans += Kiriage(k-1, 2)

	A := []int{}
	for i := k + 1; i <= n; i++ {
		A = append(A, i)
	}
	memo := make(map[int]int)
	for i := k - 1; i >= 1; i-- {
		if _, ok := memo[i]; ok {
			break
		}
		A = append(A, i)
		memo[k-i] = 1
	}

	printf("%d\n", len(A))
	printf("%s\n", PrintIntsLine(A...))
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

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

/********** common constants **********/

const (
	MOD = 1000000000 + 7
	// MOD          = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

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

// mod can calculate a right residual whether value is positive or negative.
func mod(val, m int) int {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

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

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

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

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

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

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

	return s
}

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

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

	if e == 0 {
		return 1
	}

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

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

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  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()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

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

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

package main

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

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

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var testcases int
	con.Scan(&testcases)
	for testcase := 0; testcase < testcases; testcase++ {
		var n, k int
		con.Scan(&n, &k)
		m := []int{}
		for i := k + 1; i <= n; i++ {
			m = append(m, i)
		}
		for i := (k + 1) / 2; i < k; i++ {
			m = append(m, i)
		}
		con.Println(len(m))
		for _, x := range m {
			con.Print(x, " ")
		}
		con.Println()
	}
	return nil
}

package main

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

func main() {
	var tcs int
	in := bufio.NewReader(os.Stdin)
	_, _ = fmt.Fscan(in, &tcs)

	for tc := 0; tc < tcs; tc++ {
		var n, k int
		_, _ = fmt.Fscan(in, &n, &k)

		fmt.Println(n - (k+1)/2)
		for i := (k + 1) / 2; i <= n; i++ {
			if i != k {
				fmt.Printf("%d ", i)
			}
		}
		fmt.Println()
	}
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := ScanInt(); t > 0; t-- {
		n, k := ScanInt(), ScanInt()
		a := []int{}

		for i := k / 2; i <= n; i++ {
			if i != k {
				a = append(a, i)
			}
		}

		fmt.Println(len(a))
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	}
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := ScanInt(); t > 0; t-- {
		n, k := ScanInt(), ScanInt()
		a := []int{}

		for i := k / 2; i <= n; i++ {
			a = append(a, i)
		}

		fmt.Println(len(a))
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	}
}

package main

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

var bytes []byte

func nextByte() byte {
	b := bytes[0]
	bytes = bytes[1:]
	return b
}

func ScanInt64() int64 {
	var negative bool
	var result int64

	b := nextByte()

	for ; b < '0' || b > '9'; b = nextByte() {
		if b == '-' {
			negative = true
		}
	}

	for ; '0' <= b && b <= '9'; b = nextByte() {
		result = (result << 3) + (result << 1) + int64(b-'0')
	}

	if negative {
		return -result
	} else {
		return result
	}
}

func ScanInt() int {
	return int(ScanInt64())
}

func ScanString() string {
	builder := strings.Builder{}

	for b := nextByte(); b != '\r'; b = nextByte() {
		if b != '\n' {
			builder.WriteByte(b)
		}
	}

	return builder.String()
}

func init() {
	f, err := os.Open("in.txt")

	if err == nil {
		defer f.Close()
	} else {
		f = os.Stdin
	}

	bytes, _ = ioutil.ReadAll(bufio.NewReader(f))
}

func main() {
	for t := ScanInt(); t > 0; t-- {
		n, k := ScanInt(), ScanInt()
		a := []int{}

		for i, sum := 1, 1; i <= n && sum < k; i, sum = i+1, sum+i+1 {
			a = append(a, i)
		}

		for i := k + 1; i <= n; i++ {
			a = append(a, i)
		}

		fmt.Println(len(a))
		fmt.Println(strings.Trim(fmt.Sprint(a), "[]"))
	}
}

package main

import "fmt"

func main() {
	var T, n, k int32
	fmt.Scanf("%d", &T)

	for T > 0 {
		T--
		fmt.Scanf("%d %d", &n, &k)
		var arr []int32

		for i:=k+1; i<=n; i++ {
			arr = append(arr, i)
		}

		for i:=(k>>1)+(k&1); i<k; i++ {
			arr = append(arr, i)
		}

		fmt.Println(len(arr))
		for k, v := range arr {
			if k > 0 {
				fmt.Printf(" ")
			}
			fmt.Printf("%d", v)
		}
		fmt.Println("")

	}
}

package main

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

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

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

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

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

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

/**
Run solve the problem CF1493A
Date: 8/12/21
User: epradere
URL: https://codeforces.com/problemset/problem/1493/A
Problem: CF1493A
**/
func (in *CF1493A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, k := in.NextInt(), in.NextInt()
		var str strings.Builder
		size := 0
		for i := 1; i <= n; i++ {
			if i != k {
				if k-i > 0 && k-i < k && k-i > i {
					continue
				} else {
					size++
					str.WriteString(string(i+'0') + " ")
				}
			}
		}
		fmt.Println(size)
		if size > 0 {
			fmt.Println(str.String())
		}
	}
}

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

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

package main

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

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

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

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

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

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

/**
Run solve the problem CF1493A
Date: 8/12/21
User: epradere
URL: https://codeforces.com/problemset/problem/1493/A
Problem: CF1493A
**/
func (in *CF1493A) Run() {
	for t := in.NextInt(); t > 0; t-- {
		n, k := in.NextInt(), in.NextInt()
		var str strings.Builder
		size := 0
		for i := 1; i <= n; i++ {
			if i != k {
				if k-i > 0 && k-i < k && k-i < i {
					continue
				} else {
					size++
					str.WriteString(string(i+'0') + " ")
				}
			}
		}
		fmt.Println(size)
		if size > 0 {
			fmt.Println(str.String())
		}

	}
}

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

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

package main

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

type Building struct {
	number     int
	coordinate int
	visit      int
}

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

func solve(n, k int) string {
	r := n - k + k/2
	if k == 1 {
		r = 0
	}
	x := fmt.Sprintln(r)
	for i := n; i > k; i-- {
		x += fmt.Sprint(i) + " "
	}
	for i := k - 1; i >= (k+1)/2; i-- {
		x += fmt.Sprint(i) + " "
	}
	return x
}

func main() {
	fmt.Fscan(reader, &t)
	for ; t > 0; t-- {
		fmt.Fscan(reader, &n, &k)
		fmt.Println(solve(n, k))
	}
}

package main

import (
	"fmt"
	"container/list"
)
func work(){
	var n,k int
	fmt.Scanf("%d%d",&n,&k)
	a:=list.New()
	for i:=n;i>k;i--{
		a.PushBack(i)
	}
	for i:=k-1;i>k/2;i--{
		a.PushBack(i)
	}
	fmt.Println(a.Len())
	for x:=a.Front();x!=nil;x=x.Next(){
		fmt.Printf("%d ",x.Value)
	}
	fmt.Println("")
}
func main() {
	var T int
	fmt.Scan(&T)
	for cas:=1;cas<=T;cas++{
		work()
	}
	return
}

package main

import . "fmt"
/*
	快速移动当前行 shift + command + ⬆
	删除当前行    command + 删除
	查找+替换	command + R
*/
var (
	T int
	s []byte
	n int
	k int
)

func main() {

	for Scan(&T); T > 0; T-- {
		Scan(&n)
		Scan(&k)
		ans := []int{}
		for i:=k+1;i<=n;i++ {
			ans=append(ans,i)
		}
		lo := k / 2
		if (k & 1) == 1{
			lo ++
		}
		for i:=lo;i<k;i++ {
			ans=append(ans,i)
		}
		Println(len(ans))
		Println(ans)

	}
}

package main

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

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

func print(a ...interface{}) { fmt.Fprint(writer, a...) }
func scan(a ...interface{})  { fmt.Fscan(reader, a...) }

func main() {
	defer writer.Flush()
	////////////////////
	var count int
	scan(&count)
	for count != 0 {
		solve()
		count--
	}

}

func solve() {
	n, k := 0, 0
	scan(&n, &k)
	m := make([]int, 0)
	b := make([]bool, n+1)
	for i := 1; i < k; i++ {
		if k-i > 0 && b[i] == false && b[k-i] == false {
			b[i] = true
			m = append(m, i)
		}
	}
	for i := k + 1; i <= n; i++ {
		m = append(m, i)
	}
	print(len(m), "\n")
	for _, v := range m {
		print(v, " ")
	}
	print("\n")
}

package main

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

func solveA() {
	n, k := 0, 0
	scan(&n, &k)

	choosed := make([]int, 0)
	res := 0
	for i := 1; i <= k/2; i++ {
		choosed = append(choosed, i)
		res++
	}
	for i := k + 1; i <= n; i++ {
		choosed = append(choosed, i)
		res++
	}
	printf("%d\n", res)
	for _, i := range choosed {
		printf("%d ", i)
	}
	printf("\n")
}

func main() {
	defer writer.Flush()
	// redirectInputToFile(reader, "input.txt")

	T := 1
	scan(&T)
	for t := 0; t < T; t++ {
		solveA()
	}
}

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

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

func redirectInputToFile(r *bufio.Reader, fp string) {
	f, err := os.Open(fp)
	if err != nil {
		panic(err)
	}
	r.Reset(f)
}