Read problem statements in [Mandarin], [Russian], and [Vietnamese] as well.

Chef is a great mechanic. As the cost of petrol is increasing day by day he decided to build a water car to take his girlfriend Natasha on a date. Water car has great build quality but is able to travel only 1 Km on every 1 liter of water. To show off his water car to Natasha he took her to the formula racing track which is an (N-1) km long road with checkpoints numbered 1 to N from left to right. The distance between two adjacent checkpoints is 1 Km.

Initially, Chef is at checkpoint number 1 and the tank of the water car is empty. At every checkpoint, there is a water station, but the cost of filling 1 liter of water at a checkpoint is equal to the checkpoint number. Chef can not store more than V liters of water in the tank of a car. Chef is interested in both minimum as well as the maximum cost of filling that can happen to reach the checkpoint number N.

You shouldn't have any water left after reaching N^{th} checkpoint. Also, you are not allowed to pour out water.

------ Input Format ------ 

- The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
- The first and only line of each test case contains two space-separated integers N, V.

------ Output Format ------ 

For each test case, output two integers separated by space representing the maximum and minimum cost of filling respectively.

------ Constraints ------ 

$1 ≤T ≤10^{3}$
$1 ≤N, V ≤10^{9}$

------ subtasks ------ 

Subtask 1 (20 points): $V = 1$

Subtask 2 (80 points): Original constraints

----- Sample Input 1 ------ 
3
3 1
4 2
4 3

----- Sample Output 1 ------ 
3 3
6 4
6 3

----- explanation 1 ------ 
Test case $1$: Given $N = 3$ and $V = 1$, Chef will start at checkpoint $1$, fill $1$ liter of water at a cost of $1$ and move $1$ Km right to reach checkpoint $2$. At checkpoint $2$, Chef will fill $1$ liter of water again at a cost of $2$  and move $1$ Km right to reach the destination i.e checkpoint $3$. Hence total cost incurred is $3$. There is no other way to reach the destination with a different expense.

Source: codechef | Difficulty: MEDIUM_HARD
Tags: Mathematics


Solutions:
n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	n = x - 1
	s = n * (n + 1) // 2
	a = n - y
	m = 0
	if a != 0 and a > 0:
		m = m + y
		q = (a + 1) * (a + 2) // 2
		e = q - 1
		m = m + e
	elif a == 0:
		m = y
	else:
		m = x - 1
	print(s, m)


t = int(input())
for i in range(t):
	(n, v) = map(int, input().split())
	l = []
	m = n * (n - 1) // 2
	if v >= n - 1:
		a = n - 1
	else:
		a = v - 1 + (n - v) * (n - v + 1) // 2
	l.append(int(m))
	l.append(int(a))
	print(*l, sep=' ')


t = int(input())
for i in range(t):
	(n, v) = map(int, input().split())
	arr = []
	maxi = n * (n - 1) // 2
	if v >= n - 1:
		lo = n - 1
	else:
		lo = v - 1 + (n - v) * (n - v + 1) // 2
	arr.append(int(maxi))
	arr.append(int(lo))
	print(*arr, sep=' ')


t = int(input())
while t:
	t -= 1
	(n, v) = map(int, input().split())
	if v == 1:
		print((n - 1) * n // 2, (n - 1) * n // 2)
	elif n <= v:
		ans = n - 1
		print((n - 1) * n // 2, ans)
	else:
		ans = v - 1 + (n - v) * (n - v + 1) // 2
		print((n - 1) * n // 2, ans)


t = int(input())
for tc in range(0, t):
	(n, v) = [int(i) for i in input().split()]
	maxi = n * (n - 1) // 2
	mini = (n - v) * (n - v + 1) // 2 + (v - 1)
	if v >= n - 1:
		mini = n - 1
	print(maxi, mini)


for _ in range(int(input())):
	(N, V) = list(map(int, input().split()))
	max = int((N - 1) * N // 2)
	if V >= N - 1:
		min = N - 1
	else:
		min = int(V + (N - V - 1) * (2 + (N - V)) // 2)
	print(max, min)


for i in range(int(input())):
	(n, v) = map(int, input().split())
	maxp = (n - 1) * n // 2
	minp = 0
	if v == 1:
		minp = maxp
	elif v >= n - 1:
		minp = n - 1
	else:
		minp += v + (n - v) * (n - v + 1) // 2 - 1
	print(maxp, minp)


t = int(input())
while t:
	(n, v) = map(int, input().split())
	if v >= n - 1:
		print(n * (n - 1) // 2, end=' ')
		print(n - 1)
	else:
		x = n - 1 - v
		sum = v + x * (3 + x) // 2
		print(n * (n - 1) // 2, end=' ')
		print(sum)
	t = t - 1


from math import ceil
t = int(input())
for _ in range(t):
	(n, v) = map(int, input().split())
	mx = (n - 1) * n // 2
	mn = 0
	if v >= n - 1:
		mn = min(v, n - 1)
	else:
		v1 = n - v
		mn = v + (v1 * (v1 + 1) // 2 - 1)
	print(mx, mn)


import sys
for t in range(int(input())):
	(n, v) = map(int, sys.stdin.readline().strip().split())
	if n > v:
		c = n - v
		minc = v + (c - 1) * (c + 2) // 2
		k = n - 1
		maxc = k * (k + 1) // 2
		print(maxc, minc)
	else:
		minc = n - 1
		k = n - 1
		maxc = k * (k + 1) // 2
		print(maxc, minc)


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	print(n * (n - 1) // 2, n * (n - 1) // 2 if v == 1 else n - 1 if v >= n - 1 else (n - v) * (n - v + 1) // 2 - 1 + v)


def solve():
	(N, V) = map(int, input().split())
	n = N - 1
	maxm = n * (n + 1) // 2
	if N == 1:
		print(0, 0)
	elif V == 1:
		print(maxm, maxm)
	else:
		temp = min(N - 1, V)
		n1 = n - temp
		n2 = n1 + 1
		print(maxm, temp + n2 * (n2 + 1) // 2 - 1)
T = int(input())
while T:
	solve()
	T -= 1


for _ in range(int(input())):
	(n, v) = tuple(map(int, input().split()))
	maxCost = n * (n - 1) // 2
	if v >= n - 1:
		minCost = n - 1
	else:
		k = n - v
		minCost = v - 1 + k * (k + 1) // 2
	print(maxCost, minCost)


for i in range(int(input())):
	(n, k) = map(int, input().split(' '))
	max = 0
	min = 0
	max = n * (n - 1) // 2
	if k == 1:
		min = max
		print(min, min)
	else:
		if k >= n - 1:
			min = n - 1
		else:
			min = (n - k) * (n - k + 1) // 2 - 1 + k
		print(max, min)


def chefCar(n, v):
	maxCost = n * (n - 1) // 2
	if v == 1:
		minCost = maxCost
	elif n < v:
		minCost = n - 1
	else:
		x = n - v
		minCost = v - 1 + x * (x + 1) // 2
	print('{} {}'.format(maxCost, minCost))
t = int(input())
for _ in range(t):
	(n, v) = map(int, input().strip().split(' '))
	chefCar(n, v)


t = int(input())
for _ in range(t):
	args = [int(x) for x in input().split(' ')]
	(n, v) = (args[0], args[1])
	max_value = (n - 1) * n // 2
	if n - 1 >= v:
		min_value = v + (n + 2 - v) * (n - v - 1) // 2
	else:
		min_value = n - 1
	print(max_value, min_value, sep=' ')


t = int(input())
for i in range(t):
	(n, v) = map(int, input().split())
	dis = n - 1
	x = dis // v
	y = dis % v
	maxi = n * (n - 1) // 2
	mini = 0
	if v >= dis:
		mini = dis
	else:
		mini = v + (n - v + 1) * (n - v) // 2 - 1
	print(maxi, mini)


tc = int(input())
for i in range(tc):
	aa = input().split()
	n = int(aa[0])
	v = int(aa[1])
	maxx = n * (n - 1) // 2
	minn = 0
	if n - 1 <= v:
		minn = n - 1
	else:
		cost = v
		gg = n - v
		vk = gg * (gg + 1) // 2
		minn = cost + vk - 1
	print(maxx, end=' ')
	print(minn)


import io, os, sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def outp(n):
	sys.stdout.write(str(n) + '\n')

def outlt(lst):
	sys.stdout.write(' '.join(map(str, lst)) + '\n')

def outplt(lst):
	sys.stdout.write('\n'.join(map(str, lst)))

def A():
	for _ in range(inp()):
		N = inp()
		ans = [1]
		for i in range(1, N):
			ans.append(i)
		else:
			ans.append(2 ** N - N * (N - 1) // 2 - 1)
		print(*ans)

def B():
	ans = []
	for _ in range(inp()):
		(N, V) = invr()
		ans.append((N * (N - 1) // 2, N - 1 if N - 1 <= V else V + (N - V) * (N - V + 1) // 2 - 1))
	for a in ans:
		print(*a)
B()


t = int(input())
result = []
for _ in range(t):
	(n, v) = map(int, input().split(' '))
	minn = 0
	if v > n:
		minn = n - 1
	else:
		minn = v - 1 + (n - v) * (n - v + 1) // 2
	print(n * (n - 1) // 2, minn)


for i in range(int(input())):
	(n, v) = map(int, input().split())
	if v > n:
		minm = n - 1
	else:
		minm = v - 1 + (n - v) * (n - v + 1) // 2
	maxm = n * (n - 1) // 2
	print(maxm, end=' ')
	print(minm)


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	d = n - 1
	maxx = n * (n - 1) // 2
	minn = n - 1
	if v < n - 1:
		minn = v
		d = d - v
		summ = (d + 2) * (d + 1) // 2
		summ = summ - 1
		minn = minn + summ
	print(maxx, minn)


from itertools import permutations as per
from math import factorial as fact
from difflib import SequenceMatcher
t = int(input())
for _ in range(t):
	(n, v) = map(int, input().split())
	print(n * (n - 1) // 2, end=' ')
	if v >= n - 1:
		print(n - 1)
	else:
		print(n * (n - 1) // 2 - ((v - 1) * n - (v - 1) * v // 2) + (v - 1))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if True:
		print(n * (n - 1) // 2, end=' ')
		tobe = max(1, n - k)
		if tobe == 1:
			print(n - 1)
			continue
		ans = k
		ans = ans + tobe * (tobe + 1) // 2 - 1
		print(ans)
		continue


try:
	for t in range(int(input())):
		(N, V) = map(int, input().split())
		maximum = N * (N - 1) // 2
		minimum = N - 1
		maximum = int(maximum)
		if V < N - 1:
			minimum = V - 1 + (N - V) * (N - V + 1) // 2
		minimum = int(minimum)
		print(maximum, minimum)
except:
	pass


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	mx = (n - 1) * n // 2
	if n < v:
		print(mx, n - 1)
		continue
	mn = v - 1 + (n - v) * (n - v + 1) // 2
	print(mx, mn)


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	maxo = n * (n - 1) // 2
	price = 0
	fuel = 0
	k = 1
	if v == 1:
		mino = maxo
		print(mino, maxo)
	else:
		if v >= n:
			price += n - 1
		else:
			price = v + (n - v + 1) * (n - v) // 2 - 1
		print(maxo, price)


t = int(input())
for _ in range(t):
	(n, v) = map(int, input().split())
	if v >= n - 1:
		min_cost = n - 1
	else:
		l = (n - 1 - v) * (4 + (n - 1 - v - 1)) // 2
		min_cost = v + l
	max_cost = (n - 1) * n // 2
	print(max_cost, min_cost)


for _ in range(int(input())):
	(n, v) = [int(i) for i in input().split()]
	maxValue = (n - 1) * n // 2
	if n <= v:
		print(str(maxValue) + ' ' + str(n - 1))
		continue
	minValue = v + (n - v) * (n - v + 1) // 2 - 1
	print(str(maxValue) + ' ' + str(minValue))


for i in range(int(input())):
	(n, v) = map(int, input().split())
	maxi = n * (n - 1) // 2
	mini = 0
	if n - 1 <= v:
		mini += n - 1
	else:
		mini += v + (n - v) * (n - v + 1) // 2 - 1
	if v == 1:
		print(maxi, maxi)
	else:
		print(maxi, mini)


for t in range(int(input())):
	(n, v) = map(int, input().split())
	mi = 0
	ma = n * (n - 1) // 2
	if v == 1:
		print(ma, ma)
	else:
		if v >= n - 1:
			mi = n - 1
		else:
			mi += v + (n - v) * (n - v + 1) // 2 - 1
		print(ma, mi)


import sys
import math
from collections import defaultdict
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, v) = map(int, input().split())
	a = n * (n - 1) >> 1
	b = 0
	if v + 1 >= n:
		b = n - 1
	else:
		t = n - v
		b = t * (t + 1)
		b >>= 1
		b += v - 1
	print(a, b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k >= n:
		mini = n - 1
		n = n - 1
		maxi = n * (n + 1) // 2
	else:
		l = n - k
		n = n - 1
		maxi = n * (n + 1) // 2
		mini = l * (l + 1) // 2 + (k - 1)
	print(maxi, mini)


for t in range(int(input())):
	(n, v) = map(int, input().split())
	x = n - v
	maxi = n * (n - 1) // 2
	if v == 1:
		mini = maxi
	elif v > n - 1:
		mini = n - 1
	else:
		mini = x * (x + 1) // 2 + (v - 1)
	print(maxi, mini)


for i in range(int(input())):
	(distance, capacity) = [int(x) for x in input().split()]
	max_p = 0
	min_p = 0
	max_p = distance * (distance - 1) // 2
	if capacity == 1:
		min_p = max_p
	elif capacity >= distance - 1:
		min_p = distance - 1
	else:
		min_p += capacity + (distance - capacity) * (distance - capacity + 1) // 2 - 1
	print(max_p, min_p)


for i in range(int(input())):
	(n, v) = [int(x) for x in input().split()]
	max_p = 0
	min_p = 0
	max_p = n * (n - 1) // 2
	if v == 1:
		min_p = max_p
	elif v >= n - 1:
		min_p = n - 1
	else:
		min_p += v + (n - v) * (n - v + 1) // 2 - 1
	print(max_p, min_p)


t = int(input())
for _ in range(t):
	(n, v) = list(map(int, input().strip().split()))
	l = n - 1
	excess = l - v
	max = l * (l + 1) // 2
	if l < v:
		min = l
	else:
		min = v + (excess + 1) * (excess + 2) // 2 - 1
	print(max, min)


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	a = n - 1
	mx = a * (a + 1) // 2
	mn = n - 1 if v > n - 1 else v + (n - v) * (n - v + 1) // 2 - 1
	print(mx, mn)


T = int(input())
for i in range(T):
	(N, V) = map(int, input().split())
	maks = (N - 1) * N // 2
	min = 0
	if V == 1:
		min = maks
	elif V >= N - 1:
		min = N - 1
	else:
		min += V + (N - V) * (N - V + 1) // 2 - 1
	print(maks, min)


t = int(input())
for _ in range(0, t):
	(n, v) = map(int, input().split())
	if n == 1:
		print(0, 0)
		continue
	if v >= n - 1:
		ans = n - 1
		maxc = n * (n - 1) // 2
		print(maxc, ans)
		continue
	maxc = n * (n - 1) // 2
	x = n - (v - 1)
	ans = v - 1 + x * (x - 1) // 2
	print(maxc, ans)


t = int(input())
for i in range(t):
	(n, v) = map(int, input().split())
	if n > v:
		min_ = v + (n - v) * (n - v + 1) // 2 - 1
		max_ = (n - 1) * n // 2
	else:
		min_ = n - 1
		max_ = (n - 1) * n // 2
	print(max_, min_)


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	max1 = n * (n - 1) // 2
	min1 = v - 1 + (n - v) * (n - v + 1) // 2
	if v >= n - 1:
		min1 = n - 1
	print(max1, min1)


t = int(input())
for _ in range(t):
	(n, v) = map(int, input().split())
	minn = n - 1
	maxx = n * (n - 1) // 2
	if v < n - 1:
		minn = v + (n - v) * (n - v + 1) // 2 - 1
	print(f'{maxx} {minn}')


def chefcar(n, v):
	if v < n:
		min_cost = (n - v) * (n - v + 1) // 2 - 1 + v
	else:
		min_cost = n - 1
	max_cost = n * (n - 1) // 2
	print(max_cost, min_cost)
t = int(input())
for i in range(t):
	(n, v) = map(int, input().split())
	chefcar(n, v)


for _ in range(int(input())):
	(n, v) = list(map(int, input().split()))
	a = n * (n - 1) // 2
	f = n - v
	b = f * (f + 1) // 2 + v - 1
	if v >= n:
		print(a, n - 1)
	else:
		print(a, b)


for i in range(int(input())):
	(N, V) = map(int, input().split())
	mx = (N - 1) * N // 2
	if V == 1:
		mn = mx
	elif V > N:
		mn = N - 1
	else:
		mn = V + (N - V) * (N - V + 1) // 2 - 1
	print(mx, mn)


for test in range(int(input())):
	[N, V] = map(int, input().split())
	if N <= V:
		min_count = N - 1
	else:
		min_count = (N - V) * (N - V + 1) // 2 + V - 1
	max_count = (N - 1) * N // 2
	print(max_count, min_count)


for _ in range(int(input())):
	(N, V) = map(int, input().strip().split())
	mx = N * (N - 1) // 2
	if V >= N - 1:
		print(mx, N - 1)
		continue
	mn = V - 1 + (N - V) * (N - V + 1) // 2
	print(mx, mn)


from sys import stdin

def solve():
	for _ in range(int(stdin.readline().strip())):
		(N, V) = map(int, stdin.readline().strip().split())
		mx = N * (N - 1) // 2
		if V >= N - 1:
			print(mx, N - 1)
			continue
		mn = V - 1 + (N - V) * (N - V + 1) // 2
		print(mx, mn)
solve()


for _ in range(int(input())):
	(N, V) = map(int, input().split())
	max_cost = N * (N - 1) // 2
	if V == 1:
		print(max_cost, max_cost)
	elif V < N - 1:
		min_cost = (N - V) * (N - V + 1) // 2 + V - 1
		print(max_cost, min_cost)
	else:
		print(max_cost, N - 1)


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	m = n * (n - 1) // 2
	if n == 1:
		print(0, 0, sep=' ')
		continue
	if v >= n - 1:
		ans = n - 1
	else:
		ans = (n - v) * (n - v + 1) // 2
		ans += v - 1
	print(m, ans, sep=' ')


num = int(input())
for i in range(num):
	count = 0
	(n, v) = map(int, input().split())
	maxs = n * (n - 1) // 2
	mins = 0
	if v == 1:
		mins = maxs
	elif v >= n - 1:
		mins = n - 1
	else:
		mins = v + (n - v) * (n - v + 1) // 2 - 1
	print(maxs, mins)


import sys
f = sys.stdin
next(f)
for s in f:
	(n, v) = map(int, s.split())
	d = n - v
	print(n * (n - 1) // 2, v + d * (max(d, 1) + 1) // 2 - 1)


from sys import stdin
import math
getint = lambda : int(stdin.readline().rstrip('\r\n'))
getints = lambda : map(int, stdin.readline().rstrip('\r\n').split())
lgetints = lambda : list(map(int, stdin.readline().rstrip('\r\n').split()))
getstrs = lambda : map(str, stdin.readline().rstrip('\r\n').split())

def prog_name():
	(n, v) = getints()
	mx = n * (n - 1) // 2
	mn = 0
	if v == 1:
		print(mx, mx)
	elif v >= n:
		print(mx, n - 1)
	else:
		mn = v + (n - v) * (n - v + 1) // 2 - 1
		print(mx, mn)
T = getint()
for unique in range(T):
	prog_name()


import sys
f = sys.stdin
next(f)
for s in f:
	(n, v) = map(int, s.split())
	d = n - v
	print(n * (n - 1) // 2, (v + d * (d + 1) // 2 if d > 0 else n) - 1)


from sys import stdin
input = stdin.readline

def answer():
	if v >= n:
		ans = n - 1
	else:
		ans = v - 1 + (n - v) * (n - v + 1) // 2
	return [n * (n - 1) // 2, ans]
for T in range(int(input())):
	(n, v) = map(int, input().split())
	print(*answer())


a = int(input())
for j in range(a):
	(n, v) = [int(x) for x in input().split()]
	max = (n - 1) * n // 2
	if v > n - 1:
		min = n - 1
	else:
		min = v - 1 + (n - v) * (n - v + 1) // 2
	print(max, min)


import math
from collections import OrderedDict
t = int(input())
while t > 0:
	inp = input()
	q = list(map(int, inp.split(' ')))
	n = q[0]
	v = q[1]
	k = (n - 1) // v
	x = (n - 1) % v
	max = n * (n - 1) // 2
	mini = (n - v) * (n - v + 1) // 2 + v - 1
	if v >= n:
		mini = 1 * (n - 1)
	print(max, mini)
	t -= 1


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	cost = 0
	if n - 1 > v:
		cost = v + (n - v) * (n - v + 1) // 2 - 1
	else:
		cost = n - 1
	max_cost = (n - 1) * n // 2
	print(max_cost, cost)


t = int(input())
for i in range(t):
	(n, v) = map(int, input().split())
	maxx = n * (n - 1) // 2
	if v >= n - 1:
		print(maxx, n - 1)
	else:
		minn = v - 1 + (n - v) * (n - v + 1) // 2
		print(maxx, minn)


for i in range(int(input())):
	(n, v) = map(int, input().split())
	ma = n * (n - 1) // 2
	mi = 0
	if v == 1:
		mi = ma
	elif n - 1 > v:
		mi = v
		k = n - v
		mi += k * (k + 1) // 2 - 1
	else:
		mi = n - 1
	print(ma, mi)


def main(t):
	while t > 0:
		(n, v) = map(int, input().split())
		min_cost = 0
		max_cost = (n - 1) * n // 2
		if v == 1:
			min_cost = max_cost
		elif v <= n - 1:
			diff = abs(v - (n - 1)) + 1
			min_cost = diff * (diff + 1) // 2 - 1 + v
		else:
			min_cost = n - 1
		print(max_cost, min_cost)
		t -= 1
main(int(input()))


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	maxval = n * (n - 1) // 2
	if n - 1 <= v:
		minval = n - 1
	else:
		x = n - v + 1
		minval = x * (x - 1) // 2 + v - 1
	print(maxval, minval)


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	maxi = n * (n - 1) // 2
	mini = v
	nt = n - 1 - v
	d = nt - 1
	val = (4 + d) * nt // 2
	mini = v + val
	if n == 1:
		mini = 0
	elif v >= n - 1:
		mini = n - 1
	print(maxi, mini)


import os.path
from math import gcd, floor, ceil
from collections import *
import sys
mod = 1000000007
INF = float('inf')

def st():
	return list(sys.stdin.readline().strip())

def li():
	return list(map(int, sys.stdin.readline().split()))

def mp():
	return map(int, sys.stdin.readline().split())

def inp():
	return int(sys.stdin.readline())

def pr(n):
	return sys.stdout.write(str(n) + '\n')

def prl(n):
	return sys.stdout.write(str(n) + ' ')
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	(n, v) = mp()
	maxi = n * (n - 1) // 2
	mini = min(n, v)
	left = n - mini
	mini += left * (left + 1) // 2
	mini -= 1
	print(maxi, mini)
for _ in range(inp()):
	solve()


import sys
import math
import bisect
from collections import *
import heapq
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from itertools import *
from functools import *
import random
sys.setrecursionlimit(100000000)
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
INF = float('inf')
MOD = 1000000007

def solve():
	(n, v) = mul()
	ma = (n - 1) * n // 2
	if v >= n:
		print(ma, n - 1)
		return
	lo = v - 1 + (n - v + 1) * (n - v) // 2
	print(ma, lo)
t = 1
t = inp()
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, v) = map(int, input().split())
	t = n - v
	mincost = t * (t + 1) // 2 - 1
	mincost = mincost + v
	if n >= v:
		print(n * (n - 1) // 2, mincost)
	else:
		ans = (n - 1) * 1
		print(n * (n - 1) // 2, ans)


a = int(input())
while a > 0:
	(n, v) = input().split()
	maximum = (int(n) - 1) * int(n) // 2
	if int(v) >= int(n) - 1:
		minimum = int(n) - 1
	else:
		minimum = (int(n) - int(v)) * (int(n) - int(v) + 1) // 2 + int(v) - 1
	print(maximum, minimum)
	a -= 1