```go
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
in := bufio.NewReaderSize(os.Stdin, 1<<20)
out := bufio.NewWriterSize(os.Stdout, 1<<20)
defer out.Flush()
var t int
fmt.Fscan(in, &t)
for ; t > 0; t-- {
var x, y int64
fmt.Fscan(in, &x, &y)
if x == y {
fmt.Fprintln(out, x)
} else {
fmt.Fprintln(out, 2*x)
}
}
}
```