← Home
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 x, y, k int
		fmt.Fscan(in, &x, &y, &k)

		var ans int
		if y < x {
			ans = x
		} else if y-x <= k {
			ans = y
		} else {
			ans = 2*y - x - k
		}

		fmt.Fprintln(out, ans)
	}
}