Bring equality

Bring equality

Time Limit: 1.0 s

Memory Limit: 256.0 MB

Description

You are given three non-negative integer \(A,B,C\). You can chose an arbitary number \(K\).

In one operation you can add or subtract \(K\) from one of \(A,B,C\). In other word, in an operation you can do one of the following :-

  • update \(A\) to \(A+K\)
  • update \(A\) to \(A-K\)
  • update \(B\) to \(B+K\)
  • update \(B\) to \(B-K\)
  • update \(C\) to \(C+K\)
  • update \(C\) to \(C-K\)

what is the minimum number of operations needed to make \(A=B=C\) (all of them equal)

Input

first line of input takes an integer \(T\) : number of testcases
each testcase takes 3 integers \(A,B,C\)

\(1 \le T \le 10^4\)
\(0 \le A,B,C \le 10^6\)

Output

Print one integer for each of \(T\) testcases : minimum number of operations needed.

Sample

Input Output
2
2 2 2
3 3 5
0
1

first testcase: all number are equal, so you dont need to do any operation

second testcase: chose k=2, and do the only operation 5-2=3

Information

ID
1061
Difficulty
7
Category
Beginners Click to Show
Tags
# Submissions
181
Accepted
36
Accepted Ratio
20%
Uploaded By

Related

In following contests:

Brain Booster #4