This is probably the simplest problem ever. You just need to count the number of ordered triples of different numbers (X1, X2, X3), where Xi could be any positive integer from 1 to Ni, inclusive (i = 1, 2, 3).
No, wait. I forgot to mention that numbers N1, N2, N3 could be up to 1018. Well, in any case it is still quite simple :)
By the way, because of this the answer could be quite large. Hence you should output it modulo 109 + 7. That is you need to find the remainder of the division of the number of required triples by 109 + 7.

-----Input-----
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows. The only line of each test case contains three space-separated integers N1, N2, N3.

-----Output-----
For each test case, output a single line containing the number of required triples modulo 109 + 7.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 1 ≤ Ni ≤ 1018

-----Example-----
Input:
5
3 3 3
2 4 2
1 2 3
25 12 2012
1 1 2013

Output:
6
4
1
578880
0

-----Explanation-----
Example case 1. We have the following triples composed of different numbers up to 3:
(1, 2, 3)
(1, 3, 2)
(2, 1, 3)
(2, 3, 1)
(3, 1, 2)
(3, 2, 1)
Example case 2. Here the triples are:
(1, 3, 2)
(1, 4, 2)
(2, 3, 1)
(2, 4, 1)
Example case 3. Here the only triple is (1, 2, 3).
Example case 4. Merry Christmas! 
Example case 5. ... and Happy New Year! By the way here the answer is zero since the only choice for X1 and for is X2 is 1, so any such triple will have equal numbers.

Difficulty: interview

Starter code:

Solutions:
d=1000000007
for _ in range(int(input())):
 l=sorted(list(map(int,input().split())))
 ans=(l[0]%d)*((l[1]-1)%d)*((l[2]-2)%d)
 print(ans%d)

# cook your dish here
for _ in range(int(input())):
 a=[int(x) for x in input().split()]
 a.sort()
 m=(10**9+7)
 print((a[0]*(a[1]-1)*(a[2]-2))%m)

for _ in range(int(input())):
 a=[int(x) for x in input().split()]
 p=1
 d=0
 a.sort()
 mod=(10**9)+7
 for v in a:
  p=(p*(v-d))%mod
  d+=1
 print(p%mod)

# cook your dish here
mod=1000000007
for _ in range(int(input())):
 arr=list(map(int,input().split()))
 arr.sort()
 print((arr[0]*(arr[1]-1)*(arr[2]-2))%mod)

T = int(input())
ans = []

m = 10**9 + 7

for _ in range(T):
 N = [int(i) for i in input().split()]

 N.sort()
 ans.append( ((N[0]%m)*((N[1]-1)%m)*((N[2]-2)%m))%m )

for i in ans:
 print(i)


for _ in range(int(input())):
 a,b,c = sorted(map(int,input().split()))
 ans = a*(b-1)*(c-2)
 print(ans%(10**9+7) if ans>0 else 0)

try:
 for i in range(int(input())):
  l=list(map(int,input().split()))
  l.sort()
  m=1
  a=l[0]
  b=l[1]
  c=l[2]
  ans=a*(b-1)*(c-2)
  print(ans% ((10**9)+7))
except:
 pass

m = 10**9 + 7
t=int(input())
for i in range(t):
 ls = list(map(int,input().split()))
 ls.sort()
 print( (ls[0]*(ls[1]-1)*(ls[2]-2 ))%m)

m = 10**9 + 7
for _ in range(int(input())):
 n1,n2,n3 = list(map(int,input().split()))
 ls = [n1,n2,n3]
 ls.sort()
 print( (ls[0]*(ls[1]-1)*(ls[2]-2 ))%m)
 #three different numbers


for _ in range(int(input())):
 N = list(map(int, input().split()))
 N.sort()
 N1, N2, N3 = N[0], N[1], N[2]
 M = 10**9 + 7
 ans = ((((N1 % M) * ((N2-1) % M)) % M) * (N3-2) % M) % M
 print(ans)

# cook your dish here
for _ in range(int(input())):
 l=list(map(int,input().split()))
 l.sort()
 print((l[0]*(l[1]-1)*(l[2]-2))%1000000007)
 


# cook your dish here
for _ in range(int(input())):
 
 l=list(map(int, input().split()))
 l.sort()
 
 print((l[0]*(l[1]-1)*(l[2]-2))%1000000007)


mo=1000000007

for _ in range(int(input())):
 l=list(map(int,input().split()))
 l.sort()
 print((l[0]*((l[1]-1)%mo)*((l[2]-2)%mo))%mo)

# cook your dish here
try:
 t = int(input())
 for jdnkjdew in range(t):
  arr = list(map(int,input().split()))
  arr.sort()
  a = arr[0]*(arr[1]-1)*(arr[2]-2)
  a %= 1000000007
  print(a)
except:
 pass

try:
 t = int(input())
 for jdnkjdew in range(t):
  arr = list(map(int,input().split()))
  arr.sort()
  a = arr[0]*(arr[1]-1)*(arr[2]-2)
  a %= 1000000007
  print(a)
except:
 pass

# cook your dish here
for _ in range(int(input())):
 l=list(map(int,input().split()))
 mod=10**9+7
 l.sort()
 ans=(l[0]%mod)*((l[1]-1)%mod)*((l[2]-2)%mod)
 print(ans%mod)

# cook your dish here
for _ in range(int(input())):

 #n=int(input())
 r=[int(x) for x in input().split()]
 a,b,c=sorted(r)
 print((a*(b-1)*(c-2))%1000000007)


mod = 10**9+7
for _ in range(int(input())):
 l = list(map(int, input().split()))
 l.sort()
 m = l[0]*(l[1]-1)*(l[2]-2)
 print(m % mod)


# cook your dish here
g=10**9+7
for _ in range(int(input())):
 l=list(map(int,input().split()))
 l.sort()
 m=l[0]*(l[1]-1)*(l[2]-2)
 print(m%g)


test = int(input())
for _ in range(test):
 array = list(map(int, input().split()))
 array.sort()
 mod = 1000000007
 answer = (array[0])*((array[1]-1))*((array[2]-2))
 if answer<=0:
  print(0)
 else:
  print(answer%mod)

#
c = 10**9 + 7
for i in range(int(input())):
 arr = list(map(int,input().split()))
 arr.sort()
 ans = arr[0]*(arr[1]-1)*(arr[2]-2)
 
 print(ans%c)
 


# cook your dish here
for i in range(int(input())):
 l=list(map(int,input().split(' ')))
 l.sort()
 print((l[0]*(l[1]-1)*(l[2]-2))%1000000007)