for cas in xrange(input()): a, b, m = map(int, raw_input().strip().split()) print max(a + b - m*(m+1), a - b, b - a)