King Tle4Ever of Time Limit Exceeded is really fascinated about Tic Tac Toe. He organizes a national level contest for Tic Tac Toe every year in Time Limit Exceeded. (Though I agree you need to be really stupid to loose a game of Tic Tac Toe but for the sake of question assume playing Tic Tac Toe for them is same as playing Chess for us :P ). 
Every year the contest has lots of participants. This year there are n participants from all over the country. Seeing this huge participation he asks Moron a simple question.
Suppose participant pi wins wi matches. The king wants to know the sum of wi^2 from 1 to n. Now as you already know Moron is not good with maths, he asks you to help him.
Given the value of n find the minimum and maximum value of sum of wi^2 from 1 to n. As values can be too large output the values mod 10^9+7.
[Input]
First line contains a single integer t denoting number of test cases.
Next t lines contains a single integer n denoting the number of participants.

[Output]
For each test case output the minimum and maximum value mod 10^9+7. Say minimum is minx and maximum is maxx than you should print "minx maxx".
[Constraints]
1 ≤ t ≤ 10^5
3 ≤ n ≤ 10^9
NOTE : n will be an odd integer

SAMPLE INPUT
2
3
5

SAMPLE OUTPUT
3 5
20 30
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
mod = 10**9 +7
test_cases = int(raw_input())
for _ in range(test_cases):
	people = int(raw_input())
	maxx = (((2*(people-1)+1) * (people) * (people-1)) / 6) % mod
	if people % 2 == 1:
		a = ((people-1) / 2) % mod
		minn = ((people % mod) * a**2) % mod
	else:
		a = (people/2) % mod
		a = a**3
		a = a % mod
		b = ((people/2)-1) % mod
		b = ((people/2)% mod) * b**2
		b = b % mod
		minn = a + b
		minn = minn % mod
	print minn, maxx