// Arup Guha
// 3/12/2018
// Solution to 2018 UCF HS Contest Problem: Grandmama's Gift Giving

import java.util.*;

public class gifts {

	public static void main(String[] args) {

		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();

		// Process each case.
		for (int loop=0; loop<nC; loop++) {

			// Read in the three values.
			int[] vals = new int[3];
			for (int i=0; i<3; i++)
				vals[i] = stdin.nextInt();
			Arrays.sort(vals);

			// Answer is the smaller of the two consecutive differences.
			System.out.println(Math.min(vals[1]-vals[0], vals[2]-vals[1]));
		}
	}
}