#include using namespace std; int main() { int t; cin >> t; for (int i = 0; i < t; i++) { int a, b, c, d, e; cin >> a >> b >> c >> d >> e; cout << max({a, b, c, d, e}) - min({a, b, c, d, e}) << endl; } return 0; }