You are given two integers $x$ and $y$. You can perform two types of operations:   Pay $a$ dollars and increase or decrease any of these integers by $1$. For example, if $x = 0$ and $y = 7$ there are four possible outcomes after this operation:   $x = 0$, $y = 6$;  $x = 0$, $y = 8$;  $x = -1$, $y = 7$;  $x = 1$, $y = 7$. 

  Pay $b$ dollars and increase or decrease both integers by $1$. For example, if $x = 0$ and $y = 7$ there are two possible outcomes after this operation:   $x = -1$, $y = 6$;  $x = 1$, $y = 8$.  

Your goal is to make both given integers equal zero simultaneously, i.e. $x = y = 0$. There are no other requirements. In particular, it is possible to move from $x=1$, $y=0$ to $x=y=0$.

Calculate the minimum amount of dollars you have to spend on it.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 100$) — the number of testcases.

The first line of each test case contains two integers $x$ and $y$ ($0 \le x, y \le 10^9$).

The second line of each test case contains two integers $a$ and $b$ ($1 \le a, b \le 10^9$).


-----Output-----

For each test case print one integer — the minimum amount of dollars you have to spend.


-----Example-----
Input
2
1 3
391 555
0 0
9 4

Output
1337
0



-----Note-----

In the first test case you can perform the following sequence of operations: first, second, first. This way you spend $391 + 555 + 391 = 1337$ dollars.

In the second test case both integers are equal to zero initially, so you dont' have to spend money.

Difficulty: EASY

Solutions:
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	count = 0
	if x != 0 or y != 0:
		m = min(x, y)
		x -= m
		y -= m
		count += min(m * b, m * (2 * a))
	if x != 0:
		count += x * a
	else:
		count += y * a
	print(count)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 <= b:
		print((abs(x) + abs(y)) * a)
	else:
		minimum = min(x, y)
		maximum = max(x, y)
		print(minimum * b + (abs(maximum) - abs(minimum)) * a)


for i in range(int(input())):
	(x, y) = input().split()
	(a, b) = input().split()
	(x, y, a, b) = (int(x), int(y), int(a), int(b))
	if b >= 2 * a:
		print((x + y) * a)
	else:
		print(min(x, y) * b + a * (max(x, y) - min(x, y)))


def solve(x, y, a, b):
	if x == 0 and y == 0:
		return 0
	return min(min(x, y) * b + abs(x - y) * a, (x + y) * a)
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(x, y, a, b))


from sys import stdin

def solve(tc):
	(x, y) = map(int, stdin.readline().split())
	(a, b) = map(int, stdin.readline().split())
	diff = abs(x - y)
	mini = min(x, y)
	ans = diff * a
	if mini * 2 * a < mini * b:
		ans += mini * 2 * a
	else:
		ans += mini * b
	print(ans)
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if y != 0 and x / y < 0:
		print((abs(x) + abs(y)) * a)
	elif b <= 2 * a:
		print(min(abs(x), abs(y)) * b + abs(x - y) * a)
	else:
		print(a * abs(x) + a * abs(y))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	val1 = val2 = 0
	val1 = min(x, y) * b + abs(x - y) * a
	val2 = (x + y) * a
	print(min(val1, val2))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	ans = 0
	ans += x * b
	ans += (y - x) * a
	req = (x + y) * a
	ans = min(ans, req)
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	sol = 0
	if b < 2 * a:
		sol += b * min(x, y)
		sol += a * (max(x, y) - min(x, y))
	else:
		sol = a * (x + y)
	print(sol)


t = int(input())
for z in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	sum1 = 0
	sum2 = 0
	sum1 = (x + y) * a
	mini = min(x, y)
	maxi = max(x, y)
	sum2 += (maxi - mini) * a
	sum2 += mini * b
	print(min(sum1, sum2))


import os
import sys
from io import BytesIO, IOBase

def solution(x, y, a, b):
	if x == y:
		write(min(2 * x * a, x * b))
		return
	(xx, yy) = sorted([x, y])
	res1 = (xx + yy) * a
	res2 = xx * b + (yy - xx) * a
	write(min(res1, res2))

def main():
	for _ in range(r_int()):
		(x, y) = r_array()
		(a, b) = r_array()
		solution(x, y, a, b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, sep=' ', end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + sep)
	sys.stdout.write(str(args[-1]) + end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	total = 0
	minimum = min(x, y)
	total += a * abs(y - x)
	if 2 * a < b:
		total += minimum * (2 * a)
	else:
		total += minimum * b
	print(total)


n_tests = input()
n_tests = int(n_tests)

def func(x, y, a, b):
	if x > y:
		res_a = (x - y) * a
		res_b = y * b
		if y * 2 * a < res_b:
			res_b = y * 2 * a
	else:
		res_a = (y - x) * a
		res_b = x * b
		if x * 2 * a < res_b:
			res_b = x * 2 * a
	print(int(res_a + res_b))
for i in range(n_tests):
	(x, y) = input().split()
	(a, b) = input().split()
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	func(x, y, a, b)


R = lambda : map(int, input().split())
(t,) = R()
exec(t * 'x,y=sorted(R());a,b=R();print(min(a,b-a)*x+a*y);')


import collections as cc
I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(x, y) = I()
	(a, b) = I()
	print(min(min(x, y) * b + abs(x - y) * a, (x + y) * a))


import collections
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	elif x >= 0 and y >= 0 or (x <= 0 and y <= 0):
		(x, y) = (abs(x), abs(y))
		if b >= 2 * a:
			print(x * a + y * a)
		else:
			print(abs(x - y) * a + min(x, y) * b)
	elif x >= 0 and y <= 0 or (y >= 0 and x <= 0):
		print((abs(x) + abs(y)) * a)


def NO():
	return print('NO')

def YES():
	return print('YES')

def INT():
	return int(input())

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

def STR():
	return input()

def MAP():
	return map(int, input().split())
for _ in range(INT()):
	(x, y) = MAP()
	(a, b) = MAP()
	ans = 0
	if a * 2 >= b:
		if x == y:
			ans = b * x
		if x < y:
			ans = x * b + a * (y - x)
		if x > y:
			ans = y * b + a * (x - y)
	else:
		ans = a * (x + y)
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = a * abs(x - y)
	if 2 * a < b:
		ans += 2 * a * min(x, y)
	else:
		ans += b * min(x, y)
	print(ans)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	min_v = min(x, y)
	max_v = max(x, y)
	diff = min_v - 0
	diff2 = max_v - min_v
	count = 0
	if b > 2 * a:
		count += 2 * a * diff
		count += diff2 * a
	else:
		count += b * diff
		count += diff2 * a
	print(count)
	t -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	k = c * (a + b)
	w = d * min(a, b) + c * abs(a - b)
	print(min(k, w))


t = int(input())
while t:
	line = input().split()
	x = int(line[0])
	y = int(line[1])
	line = input().split()
	a = int(line[0])
	b = int(line[1])
	amt0 = 0
	amt1 = 0
	if x == y == 0:
		print(amt0)
		t -= 1
		continue
	if x > y:
		amt0 = a * (x - y) + b * y
	else:
		amt0 = a * (y - x) + b * x
	amt1 = a * (x + y)
	if amt1 < amt0:
		print(amt1)
	else:
		print(amt0)
	t -= 1


n = int(input())
for i in range(n):
	(l, m) = input().split()
	l = int(l)
	m = int(m)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if 2 * a >= b:
		s = max(l, m)
		t = min(l, m)
		k = s - min(l, m)
		print(t * b + k * a)
	else:
		print((l + m) * a)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	d = abs(x - y)
	print(min(b * m + d * a, (x + y) * a))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	print(min((x + y) * a, x * b + (y - x) * a))


def ss(p, q):
	return p <= 0 and q <= 0 or (p >= 0 and q >= 0)
for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 > b and ss(x, y):
		m = min(abs(x), abs(y))
		print((abs(x) - m + abs(y) - m) * a + m * b)
		continue
	print((abs(x) + abs(y)) * a)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(abs(x - y) * a + min(x, y) * min(a * 2, b))


for _ in range(int(input())):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	min_x = min(x, y)
	sum = (x + y - 2 * min_x) * a + min(min_x * 2 * a, min_x * b)
	print(sum)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mi = min(x, y)
	mx = max(x, y)
	mx2min = mx - mi
	net_a = mx2min * a
	net_b = mi * b
	both = net_a + net_b
	single = a * x + a * y
	print(single if single < both else both)


t = int(input())
arr = []
for i in range(0, t):
	(x, y) = (int(x) for x in input().split())
	(a, b) = (int(x) for x in input().split())
	if x == 0 and y == 0:
		arr.append(0)
	if x == 0 and y != 0:
		arr.append(y * a)
	if x != 0 and y == 0:
		arr.append(x * a)
	if x != 0 and y != 0:
		if 2 * a <= b:
			arr.append((x + y) * a)
		elif x >= y:
			arr.append((x - y) * a + y * b)
		else:
			arr.append((y - x) * a + x * b)
for i in arr:
	print(i)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	else:
		op = 0
		if b < 2 * a:
			q = min(x, y)
			op += q * b
			x -= q
			y -= q
			op += x * a
			op += y * a
		else:
			op = (x + y) * a
		print(op)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	print(min(x * b + (y - x) * a, (x + y) * a))


t = int(input())
for case in range(1, t + 1):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	cost = 0
	if b < 2 * a:
		diff = min(abs(x), abs(y))
		cost = b * diff
		cost += a * (max(abs(x), abs(y)) - diff)
	else:
		cost = (abs(x) + abs(y)) * a
	print(cost)


t = int(input())
res = []
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mn = min(a, b)
	mx = max(a, b)
	if x > 0 or y > 0:
		if x != y:
			c = abs(x - y)
			r = min(c * a + max(x, y) * b, c * a + min(x, y) * b, (x + y) * a)
			res.append(r)
		else:
			r = min(x * b, (x + y) * a)
			res.append(r)
	else:
		res.append(0)
for r in res:
	print(r)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if x > 0 and y > 0:
		if 2 * a > b:
			m = min(x, y)
			x -= m
			y -= m
			ans += b * m
		if x > 0 or y > 0:
			ans += (x + y) * a
	elif x < 0 and y < 0:
		if 2 * a > b:
			m = max(x, y)
			x -= m
			y -= m
			print(x, y)
			ans += -b * m
		if x < 0 or y < 0:
			ans += (-x - y) * a
			print(x, y)
	else:
		ans += (abs(x) + abs(y)) * a
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cst = 0
	if 2 * a > b:
		cst += b * min(x, y)
		e = min(x, y)
		x -= e
		y -= e
	cst += a * x + a * y
	print(cst)


I = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(x, y) = I()
	(a, b) = I()
	(mi, ma) = (min(x, y), max(x, y))
	an = min([(x + y) * a, mi * b + (ma - mi) * a])
	print(an)


import math
t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	sum1 = a * (x + y)
	sum2 = b * x + a * (y - x)
	sum1 = min(sum1, sum2)
	print(sum1)
	t -= 1


def solve(x, y, a, b):
	_min = min(x, y)
	_max = max(x, y)
	n = abs(x - y)
	if a <= b / 2:
		ans = a * (x + y)
	else:
		ans = b * _min
		ans += a * n
	return ans
t = int(input())
for _n in range(0, t):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	print(solve(x, y, a, b))


t = int(input())
for _ in range(0, t):
	ans = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = min(x, y)
	d = max(x, y)
	u = c * b + (d - c) * a
	w = (x + y) * a
	res = min(u, w)
	print(res)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	if x < y:
		(x, y) = (y, x)
	if b <= 2 * a:
		print((x - y) * a + y * b)
	else:
		print((x + y) * a)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(one, two) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	elif x != 0 and y == 0:
		print(abs(x) * one)
	elif x == 0 and y != 0:
		print(abs(y) * one)
	elif x > 0 and y > 0:
		if one * 2 < two:
			print((abs(x) + abs(y)) * one)
		elif x > y:
			print(two * y + one * (x - y))
		elif y >= x:
			print(two * x + one * (y - x))
	elif x < 0 and y < 0:
		if one * 2 < two:
			print((abs(x) + abs(y)) * one)
		elif x < y:
			print(two * abs(y) + one * (y - x))
		elif y <= x:
			print(two * abs(x) + one * (x - y))
	elif x < 0 and y > 0:
		print((abs(x) + abs(y)) * one)
	elif x > 0 and y < 0:
		print((abs(x) + abs(y)) * one)


I = lambda : [*map(int, input().split())]
for _ in [0] * I()[0]:
	(x, y) = sorted(I())
	(a, b) = I()
	print(min(a * (x + y), b * x + a * (y - x)))


line = input()
t = int(line)
for _ in range(t):
	line = input()
	(x, y) = (int(i) for i in line.split(' '))
	line = input()
	(a, b) = (int(i) for i in line.split(' '))
	res = abs(x) * a + abs(y) * a
	if x * y < 0:
		print(res)
	else:
		print(min(min(x, y) * b + abs(x - y) * a, res))


t = int(input())
AnsList = []
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b < 2 * a:
		cost = abs(x - y) * a + min(x, y) * b
		AnsList.append(cost)
	else:
		cost = (x + y) * a
		AnsList.append(cost)
for cost in AnsList:
	print(cost)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = []
	c.append((x + y) * a)
	v = min(x, y)
	p = max(x, y)
	c.append((p - v) * a + v * b)
	print(min(c))
	t -= 1


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	else:
		mn = min(x, y)
		mx = max(x, y)
		diff = (mx - mn) * a
		both = mn * b
		sol1 = diff + both
		sol2 = diff + mn * 2 * a
		print(min(sol1, sol2))


import sys, math, cmath, time
start_time = time.time()

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

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

def solve():
	(a, b) = invr()
	(c, d) = invr()
	if a >= 0 and b >= 0 or (a <= 0 and b <= 0):
		print(min(d * min(abs(a), abs(b)) + c * abs(b - a), c * (abs(a) + abs(b))))
	else:
		print(c * (abs(a) + abs(b)))

def main():
	ONLINE_JUDGE = __debug__
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed:', time.time() - start_time, 'seconds')

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q
main()
sys.stdout.close()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	(a, b) = map(int, input().split())
	fans = 0
	fans += (y - x) * a
	a *= 2
	fans += x * min(a, b)
	print(fans)


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	moneySpent = 0
	if x > y:
		moneySpent += y * b
	else:
		moneySpent += x * b
	moneySpent += abs(x - y) * a
	if moneySpent > (x + y) * a:
		moneySpent = (x + y) * a
	print(moneySpent)


test = int(input())
count = 0
for i in range(test):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff = abs(x - y)
	count = a * diff
	if x > y:
		h = x
		l = y
	else:
		h = y
		l = x
	count1 = l * b
	count2 = l * 2 * a
	if count1 > count2:
		print(count + count2)
	else:
		print(count + count1)


def solve(x, y, a, b, ans):
	(x, y) = (min(x, y), max(x, y))
	ans.append(min(a * (y - x) + b * x, a * (x + y)))

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		solve(x, y, a, b, ans)
	for i in ans:
		print(i)
main()


test = int(input())
for _ in range(test):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < y:
		(x, y) = (y, x)
	diff = x - y
	print(min(b, 2 * a) * y + diff * a)


t = int(input())
for _ in range(t):
	(x, y) = [int(n) for n in input().split()]
	(a, b) = [int(n) for n in input().split()]
	s = a * abs(x - y)
	s1 = b * min(x, y)
	s2 = a * 2 * min(x, y)
	print(s + min(s1, s2))


no_of_test_cases = int(input())
for case in range(no_of_test_cases):
	(x, y) = [int(i) for i in input().split(' ')]
	(a, b) = [int(i) for i in input().split(' ')]
	if x == y == 0:
		print(0)
		continue
	result = a * abs(x - y)
	if x * y >= 0:
		result += b * min(x, y)
	result2 = a * (x + y)
	if x * y < 0:
		print(result)
		continue
	print(min(result, result2))


import sys
t = int(sys.stdin.readline())
for query in range(t):
	(x, y) = map(int, sys.stdin.readline().strip().split())
	(a, b) = map(int, sys.stdin.readline().strip().split())
	if x < 0 and y < 0:
		x = abs(x)
		y = abs(y)
	ans = (abs(x) + abs(y)) * a
	if x > 0 and y > 0:
		ar = [x, y]
		ar.sort()
		a1 = ar[0]
		a2 = ar[1] - ar[0]
		ans = min(ans, a1 * b + a2 * a)
	print(ans)


t = int(input())
lst = list()
for l in range(t):
	sum1 = 0
	sum2 = 0
	(x, y) = input().split()
	(a, b) = input().split()
	p = max(int(x), int(y))
	q = min(int(x), int(y))
	sum1 = q * int(b) + (p - q) * int(a)
	sum2 = (int(x) + int(y)) * int(a)
	lst.append(min(sum1, sum2))
for i in lst:
	print(int(i))


import os

def number_of_dollars(x, y, a, b):
	m = min(x, y)
	m1 = min(abs(x - y) * a + b * m, x * a + y * a)
	return m1
t = int(input())
for _ in range(t):
	xy = list(map(int, input().rstrip().split()))
	(x, y) = (xy[0], xy[1])
	ab = list(map(int, input().rstrip().split()))
	(a, b) = (ab[0], ab[1])
	print(number_of_dollars(x, y, a, b))


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if 2 * a <= b or x * y < 0:
		print((abs(x) + abs(y)) * a)
	else:
		xa = abs(x)
		ya = abs(y)
		print(min(xa, ya) * b + (max(xa, ya) - min(xa, ya)) * a)


from sys import stdin
input = stdin.readline
INF = 10 ** 9 + 7
MAX = 10 ** 7 + 7
MOD = 10 ** 9 + 7
for Ti in range(int(input().strip())):
	(x, y) = [int(x) for x in input().strip().split()]
	(a, b) = [int(x) for x in input().strip().split()]
	if (x < 0) == (y < 0):
		(x, y) = (abs(x), abs(y))
		if b > 2 * a:
			b = 2 * a
		ans = 0
		mxy = min(x, y)
		ans += mxy * b
		x -= mxy
		y -= mxy
		ans += a * x + a * y
		print(ans)
	else:
		print(abs(x) * a + abs(y) * a)


import math
n = int(input())
for i in range(n):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	sum = 0
	sums = 0
	sum = sum + (x + y) * a
	d = min(x, y)
	if d == x:
		sums = sums + x * b
		y = y - x
		sums = sums + y * a
	elif d == y:
		sums = sums + y * b
		x = x - y
		sums = sums + x * a
	print(min(sum, sums))


t = int(input())
for __ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b <= a:
		print(abs(x - y) * a + min(x, y) * b)
	elif b > a:
		print(min(min(x, y) * b + abs(x - y) * a, x * min(a, b) + y * min(a, b)))


t = int(input())
for tt in range(t):
	xy = input().split()
	x = int(xy[0])
	y = int(xy[1])
	(x, y) = (min(x, y), max(x, y))
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	if a <= b / 2:
		print((x + y) * a)
	else:
		print(x * b + (y - x) * a)


def Sol(a, b, x, y):
	if x * y <= 0:
		print(a * (max(x, y) - min(x, y)))
	elif a * (x + y) > b * min(x, y) + a * (max(x, y) - min(x, y)):
		print(b * min(x, y) + a * (max(x, y) - min(x, y)))
	else:
		print(a * (x + y))
	return
for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	Sol(a, b, x, y)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff = max(x, y) - min(x, y)
	m1 = diff * a + max(x, y) * b
	m2 = diff * a + min(x, y) * b
	m3 = x * a + y * a
	print(min(m1, m2, m3))


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x * y < 0 or 2 * a < b:
		print((abs(x) + abs(y)) * a)
	else:
		print(min(abs(x), abs(y)) * b + abs(y - x) * a)
	t -= 1


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(x, y) = map(int, stdin.readline().split())
	(a, b) = map(int, stdin.readline().split())
	if x == y == 0:
		print(0)
		continue
	if x == 0 and y != 0:
		print(a * y)
		continue
	if x != 0 and y == 0:
		print(a * x)
		continue
	ans1 = x * a + y * a
	ans2 = abs(x - y) * a + min(x, y) * b
	print(min(ans1, ans2))


from math import *

def solve(x, y, a, b):
	if x == 0 or y == 0:
		return x * a + y * a
	diff = abs(x - y)
	ans = min(x, y) * b + diff * a
	ans = min(ans, a * x + a * y)
	return int(ans)
tc = int(input())
for t in range(0, tc):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(x, y, a, b))


t = int(input())
for q in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
		continue
	if x == y:
		if b > a * 2:
			print(a * x + a * y)
		else:
			print(b * x)
		continue
	s = a * (max(x, y) - min(x, y))
	if a * 2 > b:
		s += b * min(x, y)
		print(s)
	else:
		s += a * 2 * min(x, y)
		print(s)


for _ in range(0, int(input())):
	(x, y) = sorted(map(int, input().split()))
	(a, b) = map(int, input().split())
	print(min(a * x + a * y, b * x + a * (y - x)))


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(x, y, a, b):
	n = 0
	while True:
		if x == 0 and y == 0:
			break
		if x == 0:
			n += y * a
			y = 0
		elif y == 0:
			n += x * a
			x = 0
		elif b < a * 2:
			mn = min(x, y)
			n += b * mn
			x -= mn
			y -= mn
		else:
			n += (x + y) * a
			x = 0
			y = 0
	return n
t = read_int()
for case in range(t):
	(x, y) = read_ints()
	(a, b) = read_ints()
	sol = solve(x, y, a, b)
	print(sol)


q = int(input())
for i in range(1, q + 1):
	(x, y) = input().split()
	(a, b) = input().split()
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	t1 = int(min(x, y))
	t2 = int(max(x, y))
	print(min((t1 + t2) * a, t1 * b + (t2 - t1) * a))


def solve(arr, a, b):
	if arr[0] == 0 and arr[1] == 0:
		return 0
	elif arr[0] == 0 and arr[1] != 0:
		return arr[1] * a
	elif arr[0] != 0 and arr[1] == 0:
		return arr[0] * a
	elif arr[0] == arr[1]:
		total_sum = 0
		if b >= 2 * a:
			total_sum = total_sum + 2 * a * min(arr)
		elif b < 2 * a:
			total_sum = total_sum + b * min(arr)
		return total_sum
	else:
		total_sum = abs(arr[0] - arr[1]) * a
		if b >= 2 * a:
			total_sum = total_sum + 2 * a * min(arr)
		elif b < 2 * a:
			total_sum = total_sum + b * min(arr)
		return total_sum
t = int(input())
output = []
for i in range(t):
	arr1 = [int(arr1) for arr1 in input().split()]
	(a, b) = [int(a) for a in input().split()]
	output.append(solve(arr1, a, b))
print(*output, sep='\n')


for test in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(a * abs(x - y) + min(x, y) * min(2 * a, b))


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if x == y == 0:
		print(0)
	else:
		c = 0
		c += abs(x - y) * a
		if min(x, y) * b < min(x, y) * 2 * a:
			c += min(x, y) * b
		else:
			c += min(x, y) * 2 * a
		print(c)


from sys import stdin, stdout
import math

def main():
	t = int(input())
	for _ in range(t):
		(x, y) = [int(i) for i in input().split()]
		(a, b) = [int(i) for i in input().split()]
		s = 0
		if b < 2 * a and x * y > 0:
			mini = min(abs(x), abs(y))
			s += mini * b
			if x > 0:
				x -= mini
				y -= mini
			else:
				x += mini
				y += mini
		slag = (x + y) * a
		s += slag
		print(s)
main()


N = int(input())
for i in range(N):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	t = min(x, y)
	r = abs(x - y)
	print(a * r + min(2 * a, b) * t)


T = int(input())
for _ in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a > b:
		d = abs(x - y)
		v = min(x, y) * b + d * a
	else:
		v = (x + y) * a
	print(v)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	mn = min(x, y)
	mx = max(x, y)
	ans += mn * b
	mx -= mn
	ans += mx * a
	print(min(ans, (x + y) * a))


count = int(input())

def solve():
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	case1 = a * min(x, y) + a * max(x, y)
	case2 = b * min(x, y) + a * (max(x, y) - min(x, y))
	print(min(case1, case2))
for i in range(count):
	solve()


t = int(input())
for x in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(a + a, b)
	if x < y:
		(x, y) = (y, x)
	print(y * b + (x - y) * a)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	r = 0
	if x == 0 and y == 0:
		print(r)
	elif x == y and a == b:
		print(x * b)
	elif x == y and a != b:
		if a * (x + y) < x * b:
			print(a * (x + y))
		else:
			print(x * b)
	elif a * (x + y) < abs(x - y) * a + min(x, y) * b:
		print(a * (x + y))
	elif a * (x + y) > abs(x - y) * a + min(x, y) * b:
		print(abs(x - y) * a + (max(x, y) - abs(x - y)) * b)
	else:
		print(a * (x + y))


def cal(x, y):
	if 2 * a <= b:
		print((x + y) * a)
	else:
		print(y * b + (x - y) * a)
for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	t = 0
	if x >= y:
		cal(x, y)
	else:
		cal(y, x)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().strip().split())
	(a, b) = map(int, input().strip().split())
	c = 0
	if 2 * a < b:
		c += min(x, y) * (2 * a)
		x -= min(a, b)
		y -= min(a, b)
	else:
		c += min(x, y) * b
		x -= min(a, b)
		y -= min(a, b)
	c += abs(x - y) * a
	print(c)


for testcase in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = 0
	if b <= 2 * a:
		d += min(x, y) * b
		d += (max(x, y) - min(x, y)) * a
	else:
		d = a * (x + y)
	print(d)


t = int(input())
(nums, ab, out) = ([], [], [])
for i in range(t):
	line = input().split()
	nums.append([int(line[0]), int(line[1])])
	line = input().split()
	ab.append([int(line[0]), int(line[1])])
	(var1, var2) = (abs(nums[i][0] - nums[i][1]) * ab[i][0] + min(nums[i]) * ab[i][1], ab[i][0] * sum(nums[i]))
	if nums[i][0] == nums[i][1]:
		var3 = nums[i][0] * ab[i][1]
	else:
		var3 = max(var1, var2)
	out.append(min(var1, var2, var3))
for i in out:
	print(i)


n = int(input())
ans = []
for x in range(n):
	suma = 0
	raz = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		ans.append(0)
		continue
	if 2 * a <= b:
		ans.append((x + y) * a)
	else:
		raz = min(x, y)
		suma += raz * b
		x -= raz
		y -= raz
		if x > y:
			suma += a * x
		if y > x:
			suma += a * y
		ans.append(suma)
for x in ans:
	print(x)


t = int(input())
for ti in range(t):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if x == y == 0:
		print(0)
	elif 2 * a < b:
		ans = (abs(x) + abs(y)) * a
		print(ans)
	elif x * y > 0:
		num_b_moves = min(abs(x), abs(y))
		num_a_moves = abs(x) - num_b_moves + abs(y) - num_b_moves
		ans = num_b_moves * b + num_a_moves * a
		print(ans)
	else:
		ans = (abs(x) + abs(y)) * a
		print(ans)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	tot = 0
	if b < 2 * a:
		dim = min(x, y)
		x -= dim
		y -= dim
		tot += dim * b
	tot += a * x + a * y
	print(tot)


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

def op():
	return list(map(int, input().split()))
for i in range(int(input())):
	(x, y) = io()
	(a, b) = io()
	if 2 * a > b:
		if x > y:
			(x, y) = (y, x)
		print(x * b + (y - x) * a)
	else:
		print((x + y) * a)


m = int(input())
for i in range(m):
	[x, y] = sorted(list(map(int, input().split())))
	(a, b) = list(map(int, input().split()))
	if x * y > 0:
		print(min(abs(x) * b + abs(x - y) * a, abs(x + y) * a))
	else:
		print(abs(x) + abs(y) * a)


import math
from sys import *
inp = stdin.readline
zip = zip

def linp(x):
	return list(map(int, x.split()))

def minp(x):
	return map(int, x.split())
t = int(inp())
while t > 0:
	(x, y) = minp(inp())
	(a, b) = minp(inp())
	if x == 0 and y == 0:
		print('0')
	elif b > 2 * a:
		print((x + y) * a)
	else:
		print(min(x, y) * b + (max(x, y) - min(x, y)) * a)
	t -= 1


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	k = min(x, y)
	ans1 = min(k * b, a * 2 * k)
	if x > y:
		ans1 += (x - y) * a
	else:
		ans1 += (y - x) * a
	print(ans1)


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a + a <= b:
		print((x + y) * a)
	elif x < y:
		print(b * x + (y - x) * a)
	else:
		print(b * y + (x - y) * a)


for _ in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	s = 0
	if b < 2 * a:
		if x > y:
			s += y * b
			x -= y
			y = 0
		else:
			s += x * b
			y -= x
			x = 0
	else:
		s += x * a
		s += y * a
		x = 0
		y = 0
	if x != 0:
		s += x * a
	if y != 0:
		s += y * a
	print(s)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dol = 0
	if x > 0 and y < 0 or (x < 0 and y > 0):
		dol += (abs(x) + abs(y)) * a
	elif x > 0 and y > 0 or (x < 0 and y < 0):
		mini = min(abs(x), abs(y))
		tempo1 = mini * b
		tempo2 = (abs(x) + abs(y)) * a
		maxi = max(abs(x), abs(y)) - mini
		tempo3 = maxi * a
		if tempo2 < tempo1 + tempo3:
			dol += tempo2
		else:
			dol += tempo1 + tempo3
	elif x == 0 or y == 0:
		dol += (x + y) * a
	print(dol)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	print((y - x) * a + min(2 * x * a, b * x))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		if 2 * a > b:
			print(x * b)
		else:
			print(x * 2 * a)
	elif 2 * a <= b:
		print((x + y) * a)
	else:
		d = abs(x - y)
		res = a * d + b * min(x, y)
		print(res)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if x > y:
		(x, y) = (y, x)
	if x == 0 and y == 0:
		print(0)
	else:
		k = (y - x) * a
		if 2 * a <= b:
			k = k + x * 2 * a
		else:
			k = k + x * b
		print(k)


n = int(input())
while n > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, 2 * a)
	if x < y:
		(x, y) = (y, x)
	print(b * y + (x - y) * a)
	n -= 1


from sys import stdin
for j in range(int(input())):
	[x, y] = [int(x1) for x1 in stdin.readline().split()]
	[a, b] = [int(x1) for x1 in stdin.readline().split()]
	if 2 * a >= b:
		print(abs(x - y) * a + min(x, y) * b)
	elif 2 * a < b:
		print((min(x, y) * 2 + abs(x - y)) * a)


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	price = b * min(x, y) + a * (max(x, y) - min(x, y))
	price = min(price, a * (x + y))
	print(price)
	t -= 1


import sys
from collections import *
from bisect import *
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	s = 0
	(a, b) = map(int, input().split())
	z = max(x, y) - min(x, y)
	s += z * a
	d1 = min(x, y) * b
	d2 = 2 * min(x, y) * a
	s += min(d1, d2)
	print(s)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	n = min(x, y) * b + a * (max(x, y) - min(x, y))
	m = a * (x + y)
	print(min(n, m))


for jj in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b > 2 * a:
		b = 2 * a
	if x < y:
		al = x
		rem = y - x
	else:
		al = y
		rem = x - y
	ans = al * b + rem * a
	print(ans)


t = int(input())
for j in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print((x + y) * a)
	else:
		a1 = min(x, y) * b
		a2 = (max(x, y) - min(x, y)) * a
		print(a1 + a2)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		print(min(2 * x * a, x * b))
	elif x == 0:
		print(a * y)
	elif y == 0:
		print(a * x)
	else:
		m = max(x, y) - min(x, y)
		c = m * a
		d = max(x, y) - m
		if (d + min(x, y)) * a < min(x, y) * b:
			c += (d + min(x, y)) * a
		else:
			c += min(x, y) * b
		print(c)
	t -= 1


t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if b > 2 * a:
		print(abs(x) * a + abs(y) * a)
	elif abs(x) > abs(y):
		print(abs(y) * b + (abs(x) - abs(y)) * a)
	elif abs(y) > abs(x):
		print(abs(x) * b + (abs(y) - abs(x)) * a)
	else:
		print(abs(x) * b)


import sys
input = sys.stdin.buffer.readline

def main():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	a1 = min(x, y)
	b1 = max(x, y)
	s = 0
	netm = b1 - a1
	s += a * netm
	if a > b:
		s += a1 * b
	elif 2 * a < b:
		s += a1 * 2 * a
	else:
		s += a1 * b
	return s
t = int(input())
while t:
	t -= 1
	print(main())


def solve(x, y, a, b):
	diff_cost = abs(x - y) * a
	X = (x + y) * a
	Y = abs(x - y) * a + min(x, y) * b
	return min(X, Y)
testCases = int(input())
while testCases:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(x, y, a, b))
	testCases -= 1


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	count = 0
	if x > y:
		if 2 * a < b:
			count = (x + y) * a
		else:
			count += b * y
			count += a * (x - y)
	elif 2 * a < b:
		count = (x + y) * a
	else:
		count += b * x
		count += a * (y - x)
	print(count)


import sys
from collections import defaultdict as dd
input = sys.stdin.readline
mod = 1000000007

def power(x, y):
	res = 1
	while y > 0:
		if y & 1 == 1:
			res = res * x % m
		y = y >> 1
		x = x * x % m
	return res % m
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(abs(x - y) * a + min(x, y) * b, (x + y) * a))


for test in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = min(x, y)
	d = max(x, y)
	if 2 * a > b:
		print((d - c) * a + c * b)
	else:
		print((d - c) * a + c * 2 * a)


N = int(input())
for i in range(N):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dol1 = 0
	dol1 = dol1 + (x + y) * a
	dol = 0
	l = min(x, y)
	dol = dol + l * b
	x = x - l
	y = y - l
	dol = dol + max(x, y) * a
	print(min(dol, dol1))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b > 2 * a:
		b = 2 * a
	res = (max(x, y) - min(x, y)) * a
	res += min(x, y) * b
	print(res)


n = int(input())
for i in range(n):
	sum = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (y, x) if x < y else (x, y)
	if 2 * a > b:
		sum = y * b
		sum += a * (x - y)
	else:
		sum = (x + y) * a
	print(sum)


import math
t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ans = 0
	if x * y >= 0:
		if 2 * a <= b:
			ans = a * (abs(x) + abs(y))
		else:
			ans = b * min(abs(x), abs(y))
			ans += a * abs(x - y)
	else:
		ans = a * (abs(x) + abs(y))
	print(ans)


for _ in range(int(input())):
	(N, M) = map(int, input().split())
	(a, b) = map(int, input().split())
	if N == M:
		val = N * b
		var = N * a + M * a
		print(min(val, var))
	else:
		var = N * a + M * a
		print(min(abs(N - M) * a + min(N, M) * b, var))


test = int(input())
while test:
	(p, q) = map(int, input().split())
	(r, s) = map(int, input().split())
	ans = []
	k = min(p, q)
	k1 = max(p, q)
	ans.append((p + q) * r)
	ans.append((k1 - k) * r + k * s)
	print(min(ans))
	test -= 1


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	s1 = 0
	x1 = x
	y1 = y
	if abs(x - y) != 0:
		s = s + int(abs(x - y) * a)
		x = min(x, y)
		y = x
	if x - y == 0:
		s = s + int(x * b)
		x = y = 0
	c = int((x1 + y1) * a)
	s1 = int(s1 + c)
	if s1 < s:
		print(s1)
	else:
		print(s)


import sys
import math
import bisect

def solve(x, y, a, b):
	(x, y) = (min(x, y), max(x, y))
	ans = 0
	if a + a >= b:
		if x > 0 and y > 0:
			ans += x * b
			y -= x
			x = 0
		elif x < 0 and y < 0:
			(x, y) = (-y, -x)
			ans += x * b
			y -= x
			x = 0
	ans += abs(x) * a
	ans += abs(y) * a
	return ans

def main():
	for _ in range(int(input())):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		print(solve(x, y, a, b))
main()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	o = x * a + y * a
	t1 = abs(x - y) * a
	t2 = min(x, y) * b
	t = t1 + t2
	print(min(o, t))


T = int(input())
for test in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x * y == 0:
		if x != 0:
			ans = a * x
		else:
			ans = a * y
	elif x * y > 0:
		(x, y) = (abs(x), abs(y))
		if 2 * a < b:
			ans = a * (x + y)
		else:
			ans = min(x, y) * b + (max(x, y) - min(x, y)) * a
	else:
		(x, y) = (abs(x), abs(y))
		ans = (x + y) * a
	print(ans)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	(a, b) = map(int, input().split())
	(x, y) = (min(l), max(l))
	(x1, y1) = (x, y)
	(total, total1) = (0, 0)
	while x != 0 or y != 0:
		while x != 0:
			total += x * b
			y = y - x
			x = 0
		while y != 0:
			total += a * y
			y = 0
	total1 += (x1 + y1) * a
	print(min(total, total1))


t = int(input())
for asd in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	mi = min(x, y)
	dif = max(x, y) - mi
	if 2 * a <= b:
		print((x + y) * a)
	else:
		print(mi * b + dif * a)


def scanf():
	return list(map(int, input().split()))
for t in range(int(input())):
	(x, y) = scanf()
	(a, b) = scanf()
	if x > y:
		(x, y) = (y, x)
	print(min(a * (x + y), b * x + a * (y - x)))


for nt in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	ans += abs(x - y) * a
	print(ans + min(2 * a * min(x, y), b * min(x, y)))


t = int(input())
for u in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print(a * (x + y))
	else:
		print(abs(x - y) * a + min(x, y) * b)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y != 0:
		print(a * y)
	elif y == 0 and x != 0:
		print(a * x)
	elif x == 0 and y == 0:
		print(0)
	elif x >= y:
		k = y * b + (x - y) * a
		l = (x + y) * a
		print(min(k, l))
	else:
		k = x * b + (y - x) * a
		l = (x + y) * a
		print(min(k, l))


t = int(input())
for i in range(0, t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans1 = x * a + y * a
	ans2 = 0
	if x < y:
		ans2 = b * x
		ans2 += a * (y - x)
	else:
		ans2 = b * y
		ans2 += a * (x - y)
	print(min(ans1, ans2))


for _ in range(int(input())):
	(X, Y) = map(int, input().split())
	(A, B) = map(int, input().split())
	if B < 2 * A:
		K = min(X, Y)
		X -= K
		Y -= K
		M = B * K + A * max(X, Y)
	else:
		M = (X + Y) * A
	print(M)


t = int(input())
for i in range(t):
	str = input()
	(x, y) = str.split()
	x = int(x)
	y = int(y)
	str = input()
	(a, b) = str.split()
	a = int(a)
	b = int(b)
	cost = 0
	if a * 2 < b:
		b = a * 2
	if x > 0 and y > 0:
		if x > y:
			n = x
			x = y
			y = n
		cost += b * x
		y -= x
		x -= x
		cost += a * y
		print(cost)
	elif x < 0 and y < 0:
		if x < y:
			n = x
			x = y
			y = n
		cost -= b * x
		y -= x
		x -= x
		cost -= a * y
		print(cost)
	else:
		ttl = abs(x) + abs(y)
		cost += a * ttl
		print(cost)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, ll, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		if val % ll[mid] == 0:
			ans = ll[mid]
			return binary(l, mid - 1, ll, val, ans)
		else:
			return binary(l, mid - 1, ll, val, ans)

def odd(n, ans, s):
	if n % 2 != 0 or n in s:
		return ans
	else:
		s.add(n)
		return odd(n // 2, ans + 1, s)
n = int(stdin.readline())
for i in range(n):
	(x, y) = map(int, stdin.readline().split(' '))
	(a, b) = map(int, stdin.readline().split(' '))
	print(min(a * x + a * y, min(x, y) * b + a * (max(x, y) - min(x, y))))


import math
from collections import Counter
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()
mod = 10 ** 9 + 7

def s(a):
	print(' '.join(list(map(str, a))))
for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = abs(x - y) * a
	s += min(x, y) * b
	su = (x + y) * a
	print(min(s, su))


from sys import stdin, stdout
for queyr in range(int(stdin.readline())):
	xy = stdin.readline().split()
	ab = stdin.readline().split()
	x = int(xy[0])
	y = int(xy[1])
	a = int(ab[0])
	b = int(ab[1])
	if b > 2 * a or not (x < 0 and y < 0 or (x >= 0 and x >= 0)):
		stdout.write(str(a * (abs(x) + abs(y))) + '\n')
	else:
		x = abs(x)
		y = abs(y)
		z = min(x, y)
		x -= z
		y -= z
		stdout.write(str(b * z + (x + y) * a) + '\n')


test = int(input())
for _ in range(test):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if b > 2 * a:
		ans = (x + y) * a
	else:
		sumb = a * abs(x - y)
		suma = 0
		if x < y:
			suma = b * x
		else:
			suma = b * y
		ans = suma + sumb
	print(ans)


def solve(x, y, a, b):
	res = 0
	if x == 0 and y == 0:
		return 0
	if 2 * a < b:
		res += min(x, y) * 2 * a
	else:
		res += min(x, y) * b
	if x != y:
		res += abs(x - y) * a
	return res
t = int(input())
for i in range(t):
	(x, y) = [int(d) for d in input().split(' ')]
	(a, b) = [int(d) for d in input().split(' ')]
	res = solve(x, y, a, b)
	print(res)


def solve(x, y, a, b):
	min_abs = min(x, y)
	diff = abs(x - y)
	return min(min_abs * b + diff * a, (x + y) * a)

def main():
	T = int(input())
	for t in range(T):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		print(solve(x, y, a, b))
main()


def main():
	for _ in range(int(input())):
		(x, y) = list(map(int, input().split()))
		(a, b) = list(map(int, input().split()))
		if 2 * a <= b:
			print((x + y) * a)
		else:
			print(min(x, y) * b + (max(x, y) - min(x, y)) * a)
main()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	op1 = 0
	op2 = 0
	if x == y:
		op1 += (x + y) * a
		op2 += b * x
		print(min(op1, op2))
	else:
		op1 = a * (x + y)
		op2 += abs(x - y) * a
		x = y = min(x, y)
		op2 += b * y
		print(min(op1, op2))


import sys
import math
for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = (max(x, y) - min(x, y)) * a
	ans += min(x, y) * b
	ans2 = abs(x) * a + abs(y) * a
	print(min(ans, ans2))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min((x + y) * a, abs(x - y) * a + min(x, y) * b))


for q in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if y > x:
		(x, y) = (y, x)
	if b > 2 * a:
		b = 2 * a
	if y < 0 < x:
		print(a * (x + y))
	elif x >= 0 and y >= 0:
		print(b * y + a * (x - y))
	else:
		print(b * x + a * (x - y))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(z, w) = (min(x, y), max(x, y))
	print(z * min(a * 2, b) + (w - z) * a)


try:
	t = int(input())
	for _ in range(t):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		if b < 2 * a:
			sum1 = b * min(x, y)
			print(sum1 + a * (max(x, y) - min(x, y)))
		else:
			print(a * (x + y))
except:
	pass


I = lambda : list(map(int, input().split()))
t = I()[0]
while t:
	t -= 1
	(a, b) = I()
	(x, y) = I()
	c = min(a, b)
	d = max(a, b)
	e = d - c
	ans1 = e * x + c * y
	ans2 = a * x + b * x
	print(min(ans1, ans2))


queries = int(input())
for _ in range(queries):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	result = 0
	if x > 0 and y > 0 and (b < a * 2):
		cof = min(x, y)
		result += b * cof
		x -= cof
		y -= cof
	if x > 0:
		result += a * x
	if y > 0:
		result += a * y
	print(result)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(x, y) = sorted([x, y])
	(a, b) = map(int, input().split())
	cost = 0
	if b <= 2 * a:
		cost += b * x
		cost += (y - x) * a
	else:
		cost = a * (x + y)
	print(cost)


import os, sys
isLocal = os.environ.get('USER', '') == 'xueenpeng'
if isLocal:
	sys.stdin = open('./file/input.txt', 'r')
	pass

def debugPrint(*values: object):
	if isLocal:
		print(values)
t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	debugPrint(x, y)
	result = 0
	dis = min(x, y)
	price = b if a * 2 > b else a * 2
	result += dis * price
	result += abs(x - y) * a
	print(result)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if 2 * a > b:
		ele = min(x, y)
		ans = ele * b
		if x - ele == 0:
			ans += (y - ele) * a
		else:
			ans += (x - ele) * a
	else:
		ans = (x + y) * a
	print(ans)


z = int(input())
lst = []
for i in range(0, z):
	(x, y) = input().split()
	(a, b) = input().split()
	(x, y, a, b) = (int(x), int(y), int(a), int(b))
	c = max(x, y)
	d = min(x, y)
	sum = (c - d) * a
	if a >= 2 * b:
		sum = sum + d * b
	elif b >= 2 * a:
		sum = sum + 2 * d * a
	else:
		sum = sum + d * b
	lst.append(sum)
print(*lst, sep='\n')


def solve():
	(x, y) = input().split(' ')
	x = int(x)
	y = int(y)
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	if 2 * a < b:
		return a * (x + abs(y))
	if x == 0:
		return y * a
	if y == 0:
		return x * a
	if y < 0:
		return (abs(x) + abs(y)) * a
	y = abs(y)
	return min(x, y) * b + a * (max(x, y) - min(x, y))
for _ in range(int(input())):
	print(solve())


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	l = [x, y]
	l[l.index(min(l))] = 0
	l[l.index(max(l))] = max(l) - m
	da = a * max(l)
	if 2 * a <= b:
		db = 2 * a * m
	else:
		db = b * m
	s = da + db
	print(s)


t = int(input())
for i1 in range(t):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	if x == 0 and y == 0:
		print(0)
	else:
		ans = 0
		z = min(x, y)
		if z * b < 2 * z * a:
			ans += z * b
			x -= z
			y -= z
			ans += (x + y) * a
		else:
			ans += (x + y) * a
		print(ans)


import math
inp = int(input())
for i in range(inp):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	print(min(abs(x - y) * a + min(x, y) * b, x * a + y * a))


n = int(input())
list_of_cases = []
for i in range(n):
	(x, y) = input().split(' ')
	(a, b) = input().split(' ')
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	list_of_cases.append([[x, y], [a, b]])
for cases in list_of_cases:
	x = cases[0][0]
	y = cases[0][1]
	a = cases[1][0]
	b = cases[1][1]
	cost = 0
	if x > y:
		if a * (x - y) + b * y < a * (x + y):
			print(a * (x - y) + b * y)
		else:
			print(a * (x + y))
	elif x < y:
		if b * x + a * (y - x) < a * (y + x):
			print(b * x + a * (y - x))
		else:
			print(a * (x + y))
	elif a * (x + y) < b * y:
		print(a * (x + y))
	else:
		print(b * y)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res = 0
	b = 2 * a if b > 2 * a else b
	if x < 0 and y > 0 or (x > 0 and y < 0):
		res = abs(x) * a + abs(y) * a
	else:
		res = (max(x, y) - min(x, y)) * a
		res += min(x, y) * b
	print(res)


from sys import stdin

def main():
	tests_num = int(stdin.readline())
	tests = []
	for t in range(tests_num):
		tests.append([[int(x) for x in stdin.readline().split()], [int(x) for x in stdin.readline().split()]])
	for test in tests:
		count = 0
		x = test[0][0]
		y = test[0][1]
		a = test[1][0]
		b = test[1][1]
		if 2 * a < b:
			print((abs(x) + abs(y)) * a)
			continue
		elif x < 0 and y < 0 or (x > 0 and y > 0):
			minimum = x if x < y else y
			non_minimum = x if minimum == y else y
			print(minimum * b + (non_minimum - minimum) * a)
		else:
			print((abs(x) + abs(y)) * a)
main()


t = int(input())
for j in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dollar = 0
	if x < y:
		(x, y) = (y, x)
	ans1 = x * a + y * a
	ans2 = (x - y) * a + y * b
	print(min(ans1, ans2))


from sys import stdin, stdout
T = int(stdin.readline())
for i in range(T):
	[x, y] = [int(j) for j in stdin.readline().split()]
	[a, b] = [int(j) for j in stdin.readline().split()]
	res = 0
	if b > 2 * a:
		res = (x + y) * a
	else:
		res = min(x, y) * b + (max(x, y) - min(x, y)) * a
	stdout.write(str(res) + '\n')


for tin in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	an = a * abs(x - y) + b * min(x, y)
	at = a * abs(x - y) + b * max(x, y)
	ab = a * x + a * y
	print(min(an, at, ab))


T = int(input())
for _ in range(T):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	cost = 0
	if 2 * a <= b:
		cost = a * (x + y)
	else:
		cost = b * min(x, y)
		if y <= x:
			cost += a * (x - y)
		else:
			cost += a * (y - x)
	print(cost)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c1 = 0
	c2 = 0
	c1 = int(math.fabs(x - y))
	c2 = min(x, y)
	print(min(a * (x + y), c1 * a + c2 * b))


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	temp = 0
	a1 = 0
	a2 = 0
	z = 0
	if y < x:
		temp = x
		x = y
		y = temp
	a1 = x * a + y * a
	z = y - x
	a2 = z * a + x * b
	print(min(a1, a2))


t = int(input())
xlist = []
ylist = []
alist = []
blist = []
for i in range(t):
	(x, y) = input().split()
	xlist.append(x)
	ylist.append(y)
	(a, b) = input().split()
	alist.append(a)
	blist.append(b)
for i in range(t):
	x = int(xlist[i])
	y = int(ylist[i])
	a = int(alist[i])
	b = int(blist[i])
	if x > 0 and y > 0:
		if x - y > 0:
			if b - 2 * a > 0:
				t = (x + y) * a
				print(t)
			else:
				t = y * b + (x - y) * a
				print(t)
		elif b - 2 * a > 0:
			t = (x + y) * a
			print(t)
		else:
			t = x * b + (y - x) * a
			print(t)
	elif x >= 0 and y <= 0:
		t = (x + y) * a
		print(t)
	elif y >= 0 and x <= 0:
		t = (x + y) * a
		print(t)
	elif x - y > 0:
		if b - 2 * a > 0:
			t = abs(x + y) * a
			print(t)
		else:
			t = (x - y) * a + abs(x) * b
			print(t)
	elif b - 2 * a > 0:
		t = abs(x + y) * a
		print(t)
	else:
		t = (y - x) * a + abs(y) * b
		print(t)


import math

def solve():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mn = min(x, y)
	mx = max(x, y)
	diff = mx - mn
	res = 0
	if a <= b / 2:
		res += mn * 2 * a
	else:
		res += mn * b
	res += diff * a
	print(res)
for _ in range(int(input())):
	solve()


def fun(x, y, a, b):
	if x != 0 and y != 0:
		if b <= 2 * a:
			m1 = min(x, y)
			m2 = max(x, y)
			return m1 * b + (m2 - m1) * a
		else:
			m1 = min(x, y)
			m2 = max(x, y)
			return (m1 + m2) * a
	else:
		m1 = max(x, y)
		return m1 * a
t = int(input())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	print(fun(x, y, a, b))


for i in range(int(input())):
	l = []
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	l.append(min(x, y) * b + (max(x, y) - min(x, y)) * a)
	l.append((x + y) * a)
	print(min(l))


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline().rstrip()
res = ['YES', 'NO']
test_case = ii()
while test_case:
	test_case -= 1
	(x, y) = mi()
	if x > y:
		(x, y) = (y, x)
	(a, b) = mi()
	ans = 0
	if b < 2 * a:
		ans += b * x
		ans += (y - x) * a
	else:
		ans += (y + x) * a
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (abs(x), abs(y))
	dif = abs(x - y)
	minv = min(x, y)
	print(min(dif * a + minv * b, (x + y) * a))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res = 0
	if x > y:
		res = min(b * x + a * (x - y), a * (x + y), y * b + (x - y) * a)
	elif x < y:
		res = min(b * y + a * (y - x), a * (x + y), x * b + (y - x) * a)
	else:
		res = min(a * (x + y), b * x)
	print(res)


t = int(input())
while t > 0:
	inp = input().split()
	x = int(inp[0])
	y = int(inp[1])
	inp = input().split()
	a = int(inp[0])
	b = int(inp[1])
	cost = 0
	if x * y > 0:
		x = abs(x)
		y = abs(y)
		val = min(x, y)
		dif = abs(x - y)
		c1 = a * (x + y)
		c2 = b * val + a * dif
		cost = min(c1, c2)
	elif x <= 0:
		y = y + abs(x)
		x = 0
		cost = a * y
	elif y <= 0:
		x = x + abs(y)
		y = 0
		cost = a * x
	print(cost)
	t -= 1


inf = 10 ** 15
mod = 10 ** 9 + 7
t = int(input())
for test in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = inf
	if x > y:
		(x, y) = (y, x)
	if y < 0:
		ans = min((y - x) * a + (0 - y) * b, -(x + y) * a)
	elif x <= 0 <= y:
		ans = (y - x) * a
	else:
		ans = min((y - x) * a + x * b, (x + y) * a)
	print(ans)


from collections import defaultdict
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x1 = min(x, y)
	y1 = max(x, y)
	ans1 = (y1 - x1) * a + x1 * b
	ans2 = (x1 + y1) * a
	print(min(ans1, ans2))


from sys import stdin, exit, setrecursionlimit
from collections import deque
setrecursionlimit(10000000)
input = stdin.readline
lmi = lambda : list(map(int, input().split()))
mi = lambda : map(int, input().split())
si = lambda : input().strip('\n')
ssi = lambda : input().strip('\n').split()
for _ in range(int(input())):
	(x, y) = mi()
	(a, b) = mi()
	print(min(abs(x - y) * a + min(x, y) * b, a * x + y * a))


n = int(input())
for ti in range(0, n):
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	sum_1 = 0
	(a, b) = (abs(a), abs(b))
	while not (a == 0 and b == 0):
		if a == b:
			if y >= 2 * x:
				sum_1 += a * 2 * x
				a = 0
				b = 0
			else:
				sum_1 += a * y
				a = 0
				b = 0
		elif b > a:
			sum_1 += (b - a) * x
			b = a
		else:
			sum_1 += (a - b) * x
			a = b
	print(sum_1)


for i in range(int(input())):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a <= b // 2:
		res = a * (x + y)
	elif x > y:
		res = y * b + a * (x - y)
	elif x < y:
		res = x * b + a * (y - x)
	else:
		res = x * b
	print(res)


def sign(a):
	if a == 0:
		return 1
	return a // abs(a)
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if sign(x) != sign(y):
		print((abs(x - 0) + abs(y - 0)) * a)
	else:
		m = min(abs(x), abs(y))
		sum = 0
		sum += (abs(x - m) + abs(y - m)) * a
		sum += abs(m) * min(b, 2 * a)
		print(sum)


from sys import stdin
tc = int(stdin.readline())
for _ in range(tc):
	(x, y) = list(map(int, stdin.readline().split()))
	(a, b) = list(map(int, stdin.readline().split()))
	temp1 = max(x, y)
	temp2 = min(x, y)
	result = min(b * temp2 + abs(x - y) * a, (x + y) * a)
	print(result)


for _ in range(int(input())):
	summ = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	razn = abs(x - y)
	summ += razn * a
	minn = min(x, y)
	if a * 2 <= b:
		summ += minn * a * 2
	else:
		summ += minn * b
	print(summ)


Q = int(input())
Query = []
for _ in range(Q):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	Query.append((a, b, x, y))
for (a, b, x, y) in Query:
	ans = min([(x + y) * a, abs(x - y) * a + min(x, y) * b])
	print(ans)


t = int(input())
out = ''
while t > 0:
	t -= 1
	(x, y) = [int(i) for i in input().split(' ')]
	(a, b) = [int(i) for i in input().split(' ')]
	both = min(x, y) * b + abs(x - y) * a
	once = (x + y) * a
	out += f'{min(once, both)}\n'
print(out)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b >= 2 * a:
		print((x + y) * a)
	else:
		dif = min(x, y)
		p = dif * b
		p += (max(x, y) - dif) * a
		print(p)


t = int(input())
for q in range(0, t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(min(b * min(x, y) + a * (max(x, y) - min(x, y)), (x + y) * a))


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(x, y) = map(int, sys.stdin.readline().split())
	(a, b) = map(int, sys.stdin.readline().split())
	b = min(b, 2 * a)
	ans = min(x, y) * b + (max(x, y) - min(x, y)) * a
	print(ans)


def rtz(x, y, a, b):
	if x == y:
		if a > int(b / 2):
			p = y * b
		else:
			p = 2 * y * a
		print(p)
		return
	elif x > y:
		c = x - y
		p = c * a
		if a > int(b / 2):
			p = p + y * b
		else:
			p = p + 2 * y * a
		print(p)
		return
	else:
		c = y - x
		p = c * a
		if a > int(b / 2):
			p = p + x * b
		else:
			p = p + 2 * x * a
		print(p)
	return
t = int(input())
for i in range(t):
	T = input()
	p = input()
	l = list(map(int, T.split(' ')))
	d = list(map(int, p.split(' ')))
	rtz(l[0], l[1], d[0], d[1])


def func(x, y, a, b):
	ans1 = abs(x) * b + abs(x - y) * a
	ans2 = abs(y) * b + abs(x - y) * a
	ans3 = (abs(x) + abs(y)) * a
	return min(ans1, ans2, ans3)
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(func(x, y, a, b))


test = int(input())
for i in range(test):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	total = 0
	if 2 * a <= b:
		total = total + (x + y) * a
	elif x != y:
		if x > y:
			k1 = (x - y) * a + y * b
			k2 = (x - y) * a + x * b
			total = total + min(k1, k2)
		else:
			k1 = (y - x) * a + x * b
			k2 = (y - x) * a + y * b
			total = total + min(k1, k2)
	else:
		total = total + x * b
	print(total)


from sys import stdin, stdout
m = 10 ** 9 + 7
t = int(stdin.readline())
while t:
	t -= 1
	(x, y) = map(int, stdin.readline().split())
	(a, b) = map(int, stdin.readline().split())
	if a <= b / 2:
		print(a * (abs(x) + abs(y)))
		continue
	else:
		print(a * abs(abs(x) - abs(y)) + b * abs(min(abs(x), abs(y))))
		continue


for tt in range(int(input())):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	S = 0
	if x != y:
		S = (max(x, y) - min(x, y)) * a
		x = y = min(x, y)
	if 2 * a <= b:
		print(S + 2 * a * x)
	else:
		print(S + x * b)


ans = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y == 0:
		ans += [0]
	elif 2 * a < b:
		ans += [(x + y) * a]
	else:
		ans += [abs(x - y) * a + min(x, y) * b]
print('\n'.join(map(str, ans)))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a < b:
		print((x + y) * a)
	else:
		one = min(x, y)
		two = max(x, y)
		ans = one * b
		ans += (two - one) * a
		print(ans)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	summ = 0
	if x == 0 or y == 0:
		summ += max(x, y) * a
	elif a * 2 < b:
		summ += (x + y) * a
	else:
		summ += abs(x - y) * a
		summ += min(x, y) * b
	print(summ)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	summ = 0
	summ += (max(x, y) - min(x, y)) * a
	summ += min(b * min(x, y), 2 * a * min(x, y))
	print(summ)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ma = max(x, y)
	mi = min(x, y)
	ans = mi * b + (ma - mi) * a
	ans1 = x * a + y * a
	print(min(ans, ans1))


test = int(input())
ans = 0

def set1(a1, x):
	if x[0] == '0':
		ans7 = a1 * int(x[1])
		return ans7
	elif x[1] == '0':
		ans7 = a1 * int(x[0])
		return ans7
	return 0
for i in range(0, test):
	x = input().split()
	ab = input().split()
	a = ab[0]
	b = ab[1]
	alans = int(a) * (int(x[0]) + int(x[1]))
	if x[0] == '0' or x[1] == '0':
		print(alans)
	elif x[0] != '0' and x[1] != '0':
		if int(x[0]) <= int(x[1]):
			ans = int(a) * (int(x[1]) - int(x[0]))
			ans2 = int(b) * int(x[0])
			ans = ans + ans2
		elif int(x[1]) <= int(x[0]):
			ans = int(a) * (int(x[0]) - int(x[1]))
			ans2 = int(b) * int(x[1])
			ans = ans + ans2
		if ans < alans:
			print(ans)
		else:
			print(alans)


import sys
sys.setrecursionlimit(10 ** 6)

def f(x, y, a, b):
	if b >= a + a:
		return (x + y) * a
	(xx, yy) = (min(x, y), max(x, y))
	return xx * b + (yy - xx) * a
nofkase = int(input())
for kase in range(nofkase):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	print(f(x, y, a, b))


numcases = int(input())
for i in range(numcases):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff = abs(x - y)
	if b < a * 2:
		print(diff * a + min(x, y) * b)
	else:
		print((x + y) * a)


for i in range(0, int(input())):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	g = abs(x) - abs(y)
	h = abs(g) * a
	if abs(x) > abs(y):
		j = abs(y) * b
		if j > abs(y) * 2 * a:
			j = abs(y) * 2 * a
	else:
		j = abs(x) * b
		if j > abs(x) * 2 * a:
			j = abs(x) * 2 * a
	print(j + h)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	a2 = 0
	a1 = (x + y) * a
	n = min(x, y)
	a2 += n * b
	x -= n
	y -= n
	if x == 0:
		a2 += y * a
	if y == 0:
		a2 += x * a
	if a1 < a2:
		print(a1)
	else:
		print(a2)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y == 0:
		print(0)
	elif x == y:
		print(min(2 * x * a, x * b))
	else:
		g = max(x, y)
		s = min(x, y)
		d = g - s
		print(min(a * d + s * b, a * (x + y)))
	t = t - 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = abs(x - y) * a + min(x, y) * b
	ans = min(ans, (x + y) * a)
	print(ans)


for _ in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if not a and (not b) or not a:
		print(0)
	else:
		one_n = max(x, y) - min(x, y)
		if b < 2 * a:
			b = b
		else:
			b = a * 2
		if one_n == 0:
			print(x * b)
		else:
			print(one_n * a + (max(x, y) - one_n) * b)


def solution(x, y, a, b):
	(m, cost) = (min(x, y), 0)
	if 2 * a > b:
		cost = b * m
	else:
		cost = m * 2 * a
	return cost + ((x - m) * a + (y - m) * a)

def main():
	for i in range(int(input())):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		print(solution(x, y, a, b))
main()


t = int(input())
for _ in range(t):
	(x, y) = [int(el) for el in input().split()]
	(a, b) = [int(el) for el in input().split()]
	(x, y) = (max(x, y), min(x, y))
	if 2 * a <= b:
		print(a * (x + y))
	else:
		print(a * (x - y) + b * y)


t = int(input())
while t > 0:
	(a, b) = list(map(int, input().split()))
	(c, d) = list(map(int, input().split()))
	if 2 * c < d:
		d = 2 * c
	l = 0
	if a <= b:
		l += d * a
		l += c * (b - a)
	else:
		l += d * b
		l += c * (a - b)
	print(l)
	t -= 1


test = int(input())
for case in range(test):
	(a, b) = [int(i) for i in input().split()]
	(x, y) = [int(i) for i in input().split()]
	print(abs(b - a) * x + min(a, b) * min(x * 2, y))


t = int(input())
for case in range(t):
	(x, y) = [int(s) for s in input().split(' ')]
	(a, b) = [int(s) for s in input().split(' ')]
	if x * y > 0 and 2 * a > b:
		ans = min(abs(x), abs(y)) * b + (max(abs(x), abs(y)) - min(abs(x), abs(y))) * a
	else:
		ans = (abs(x) + abs(y)) * a
	print(ans)


t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().strip().split(' '))
	(a, b) = map(int, input().strip().split(' '))
	print(min(min(x, y) * b + abs(x - y) * a, 2 * min(x, y) * a + abs(x - y) * a))


def solve(a, b, c, d):
	a2 = a
	b2 = b
	a = min(a2, b2)
	b = max(a2, b2)
	move = 0
	if a == b == 0:
		return 0
	if a == b:
		return min(min(a * d, 2 * (a * c)), 2 * (a * c - 1) + d)
	if a == 0:
		return b * c
	move += (b - a) * c + min(a * d, 2 * a * c)
	return move

def main():
	t = int(input())
	for i in range(t):
		d = input()
		d = [int(i) for i in d.split()]
		a = d[0]
		b = d[1]
		e = input()
		e = [int(i) for i in e.split()]
		c = e[0]
		d = e[1]
		ans = solve(a, b, c, d)
		print(ans)
main()


testcases = int(input())
for _ in range(testcases):
	(x, y) = [int(value) for value in input().split(' ')]
	(a, b) = [int(value) for value in input().split(' ')]
	if x == y == 0:
		print(0)
		continue
	val = a * abs(x - y)
	if x * y >= 0:
		val += b * min(x, y)
	val2 = a * (x + y)
	if x * y < 0:
		print(val)
		continue
	print(min(val, val2))


def read_int():
	return int(input().strip())

def read_ints():
	return list(map(int, input().strip().split(' ')))

def solve():
	(x, y) = read_ints()
	(a, b) = read_ints()
	min_x = min(x, y)
	return abs(y - x) * a + min(min_x * b, 2 * min_x * a)
T = read_int()
for _ in range(T):
	print(solve())


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = 0
	if x != y:
		c = c + abs(x - y) * a
	p = min(x, y) * b
	q = min(x, y) * a * 2
	if c + p > c + q:
		print(c + q)
	else:
		print(c + p)


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	if x < y:
		s = x * b + (y - x) * a
	else:
		s = y * b + (x - y) * a
	r = (x + y) * a
	print(min(s, r))
	t -= 1


t = int(input())
for ii in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	ans = (y - x) * a
	print(ans + min(2 * a * x, b * x))


import sys
input = sys.stdin.readline
from math import *
t = int(input())
while t > 0:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(a * x + a * y, min(x, y) * b + abs(x - y) * a))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = 0
	diff = abs(x - y)
	if x > y:
		cost += a * diff
		x = y
	if y > x:
		cost += a * diff
		y = x
	if a * 2 > b:
		cost += b * x
	else:
		cost += 2 * a * x
	print(cost)


n = int(input())
ans = []
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	z1 = min(x, y)
	x = x - z1
	y = y - z1
	if b < a * 2:
		res = z1 * b
	else:
		res = z1 * a * 2
	c = max(x, y)
	res += a * c
	ans.append(res)
for i in range(n):
	print(ans[i])


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(X, Y) = [int(x) for x in input().split()]
		(A, B) = [int(x) for x in input().split()]
		ans1 = abs(X - Y) * A + min(X, Y) * B
		ans2 = abs(X - Y) * A + min(X, Y) * A * 2
		ans5 = (X + Y) * A
		print(min(ans1, ans2, ans5))
main()


t = int(input())
for qq in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x >= 0 and y >= 0 or (x <= 0 and y <= 0):
		if a * 2 < b:
			print(a * (x + y))
		else:
			print(b * min(x, y) + a * (max(x, y) - min(x, y)))
	else:
		print(a * (x + y))


import sys
input = sys.stdin.readline
from collections import Counter

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def print_list_int(l):
	print(''.join(map(str, map(int, l))))
t = inp()
for test in range(t):
	(x, y) = inlt()
	(a, b) = inlt()
	if b < 2 * a:
		if (x < 0) == (y < 0):
			(x, y) = (abs(x), abs(y))
			bs = min(x, y)
			a_s = max(x, y) - min(x, y)
			print(int(a_s * a + bs * b))
		else:
			bs = 0
			a_s = abs(x) + abs(y)
			print(int(a_s * a + bs * b))
	else:
		bs = 0
		a_s = abs(x) + abs(y)
		print(int(a_s * a + bs * b))


def cost(x, y, a, b):
	if a < b:
		(a, b) = (b, a)
	if x * 2 <= y:
		return (a + b) * x
	else:
		return b * y + (a - b) * x
n_test = int(input())
for _ in range(n_test):
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	print(cost(x, y, a, b))


t = int(input())
for xy in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(abs(x - y) * a + min(2 * min(x, y) * a, min(x, y) * b))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	z = min(y, x)
	r = max(y, x)
	s = int((x + y) * a)
	k = int(z * b + (r - z) * a)
	if x != y:
		print(min(k, s))
	else:
		print(min(s, int(b * x)))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > 0 and y > 0 or (x < 0 and y < 0):
		c1 = abs(x - y)
		c2 = min(abs(x), abs(y))
	else:
		c1 = abs(x) + abs(y)
		c2 = 0
	if 2 * a < b:
		(c1, c2) = (c1 + 2 * c2, 0)
	print(c1 * a + c2 * b)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	summ = 0
	if b < 2 * a:
		l = max(x, y)
		k = min(x, y)
		summ += b * k
		l = l - k
		summ += a * l
	else:
		summ += a * (x + y)
	print(summ)


cases = int(input())
for t in range(cases):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a <= b / 2:
		na = abs(x) + abs(y)
		nb = 0
	elif x > 0 > y or y > 0 > x:
		na = abs(x) + abs(y)
		nb = 0
	else:
		na = abs(x - y)
		nb = min(abs(x), abs(y))
	print(a * na + b * nb)


from collections import Counter, defaultdict, deque
from math import *
import sys
input = sys.stdin.readline

def solve():
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	ans = 0
	m = min(x, y)
	ans += abs(x - y) * a
	ans += min(m * b, m * 2 * a)
	print(ans)
tt = int(input())
for test in range(tt):
	solve()


rw = int(input())
for ewqr in range(rw):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0:
		print(abs(y) * a)
		continue
	if y == 0:
		print(abs(x) * a)
		continue
	if a * 2 < b:
		print(abs(x + y) * a)
	else:
		print(min(x, y) * b + abs(x - y) * a)


n = int(input())
cases = []
for i in range(n):
	case = []
	line1 = input().split()
	line2 = input().split()
	case.append(int(line1[0]))
	case.append(int(line1[1]))
	case.append(int(line2[0]))
	case.append(int(line2[1]))
	cases.append(case)
for case in cases:
	x = case[0]
	y = case[1]
	a = case[2]
	b = case[3]
	if b > 2 * a:
		print(a * (x + y))
	else:
		big = max(x, y)
		small = min(x, y)
		a_mult = big - small
		b_mult = small
		print(a * a_mult + b * b_mult)


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mn = min(x, y)
	mx = max(x, y)
	print(min(mn * b + (mx - mn) * a, (x + y) * a))


import math
t = int(input())
for i in range(t):
	s = input().split()
	s1 = input().split()
	x_y = []
	for i in s:
		x_y.append(int(i))
	a_b = []
	for i in s1:
		a_b.append(int(i))
	if 2 * a_b[0] >= a_b[1]:
		if x_y[0] <= x_y[1]:
			res = x_y[0] * a_b[1] + (x_y[1] - x_y[0]) * a_b[0]
		else:
			res = x_y[1] * a_b[1] + (x_y[0] - x_y[1]) * a_b[0]
	else:
		res = (x_y[0] + x_y[1]) * a_b[0]
	print(res)


import math

def s():
	(x, y) = [int(x) for x in input().split(' ')]
	(a, b) = [int(x) for x in input().split(' ')]
	ans = 0
	if a * 2 > b:
		ans += min(x, y) * b
		ans += (max(x, y) - min(x, y)) * a
	else:
		ans += (x + y) * a
	print(ans)
t = int(input())
for i in range(t):
	s()


import math
from collections import defaultdict
ml = lambda : map(int, input().split())
ll = lambda : list(map(int, input().split()))
ii = lambda : int(input())
ip = lambda : input()
t = ii()
for _ in range(t):
	(a, b) = ml()
	(x, y) = ml()
	c = min(a, b)
	ans = 0
	a -= c
	b -= c
	if y * c <= 2 * x * c:
		ans += y * c
	else:
		ans += 2 * x * c
	ans += max(a, b) * x
	print(ans)


import itertools
n = input()

def solve(x, y, a, b):
	if b >= 2 * a:
		return a * (abs(x) + abs(y))
	if x == 0 or y == 0:
		return max(x, y) * a
	if x < 0 and y < 0 or (x > 0 and y > 0):
		return abs(min(x, y)) * b + abs(x - y) * a
	return a * (abs(x) + abs(y))
for i in range(int(n)):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	solution = solve(x, y, a, b)
	print(solution)


from math import *
from bisect import bisect_left, bisect_right
from queue import Queue
from sys import stdin, stdout
from collections import Counter
input = lambda : stdin.readline().strip()
fast_print = stdout.write
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	fast_print(str(min(2 * a, b) * min(x, y) + a * (max(x, y) - min(x, y))) + '\n')


test = int(input())
while test > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(x, y) * min(2 * a, b) + abs(x - y) * a)
	test -= 1


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, a + a)
	if x < y:
		(x, y) = (y, x)
	print(y * b + (x - y) * a)
	t = t - 1


t = int(input())
for xx in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	les = min(x, y)
	mor = max(x, y)
	p1 = les * b + (mor - les) * a
	p2 = (mor + les) * a
	print(min(p1, p2))


def solve(x, y):
	global a
	global b
	if x == 0 or y == 0:
		return x * a + y * a
	else:
		return solve(x - min(x, y), y - min(x, y)) + min(x, y) * min(2 * a, b)
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(x, y))


import math
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b > 2 * a or a * b < 0:
		print((abs(x) + abs(y)) * a)
	else:
		(xymin, xymax) = (min(abs(x), abs(y)), max(abs(x), abs(y)))
		cost = xymin * b + (xymax - xymin) * a
		print(cost)


t = int(input())
for test in range(t):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	diff = abs(x - y)
	tozeroa = min(x, y)
	tozerob = max(x, y)
	ans1 = a * diff + b * tozeroa
	ans2 = a * diff + b * tozerob
	ans3 = a * (x + y)
	ans = min(min(ans1, ans2), ans3)
	print(ans)


t = int(input())
while t > 0:
	(a, b) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	ans1 = 0
	ans1 = x * abs(a - b)
	if a > b:
		(a, b) = (b, a)
	ans1 += y * a
	ans2 = x * (a + b)
	print(min(ans1, ans2))
	t -= 1


tc = int(input())
for i in range(tc):
	(x, y) = [int(j) for j in input().split()]
	(a, b) = [int(j) for j in input().split()]
	[x, y] = sorted([abs(x), abs(y)])
	ans = min((y - x) * a + x * b, x * a + y * a)
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res = 0
	if 2 * a < b:
		tmp = abs(0 - x)
		tmp += abs(0 - y)
		res = a * tmp
		print(res)
	else:
		x = abs(x)
		y = abs(y)
		if x > y:
			tmp = y
			res += tmp * b
			x = x - y
			res += x * a
		else:
			tmp = x
			res += tmp * b
			y = y - x
			res += y * a
		print(res)


import sys, math, itertools, collections, copy
input = sys.stdin.readline

def solve():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
		return
	if a * 2 < b:
		print((x + y) * a)
	else:
		print(min(x, y) * b + (max(x, y) - min(x, y)) * a)
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(m, n) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(m, n) * b + abs(m - n) * a if b < 2 * a else (m + n) * a)


n = int(input())
for i in range(n):
	(c, d) = map(int, input().split())
	(a, b) = map(int, input().split())
	count = 0
	if c == 0 and d == 0:
		print(0)
	elif c >= 0 and d >= 0 or (d < 0 and c < 0):
		(c, d) = (abs(c), abs(d))
		x = min(c, d)
		y = max(c, d)
		if b < 2 * a:
			diff = y - x
			count = count + a * diff
			diff1 = x
			count = count + b * diff1
			print(count)
		else:
			count = count + a * x
			count = count + a * y
			print(count)
	elif c <= 0 and d >= 0 or (d <= 0 and c >= 0):
		x = min(c, d)
		y = max(c, d)
		diff = abs(x)
		count = count + a * diff
		count = count + a * y
		print(count)


for t in range(int(input())):
	(x, y) = tuple(map(int, input().split(' ')))
	(a, b) = tuple(map(int, input().split(' ')))
	if 2 * a > b:
		print(min(x, y) * b + (max(x, y) - min(x, y)) * a)
	else:
		print((x + y) * a)


def solve():
	(x, y) = [int(v) for v in input().split()]
	(a, b) = [int(v) for v in input().split()]
	cost = a * (max(x, y) - min(x, y))
	if b < 2 * a:
		cost += b * min(x, y)
	else:
		cost += 2 * a * min(x, y)
	print(cost)
t = int(input())
for _ in range(t):
	solve()


for t in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if x >= y:
		cost1 = b * y + a * (x - y)
		cost2 = b * x + a * (x - y)
		cost3 = a * x + a * y
		print(min(cost1, cost2, cost3))
	else:
		cost1 = b * x + a * (y - x)
		cost2 = b * y + a * (y - x)
		cost3 = a * x + a * y
		print(min(cost1, cost2, cost3))


tc = int(input())
for i in range(tc):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a < b:
		result = (x + y) * a
		print(result)
	else:
		mx = 0
		mn = 0
		if x > y:
			mx = x
			mn = y
		else:
			mx = y
			mn = x
		result = (mx - mn) * a + mn * b
		print(result)


t = int(input())
for q in range(t):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	cont = 0
	while x != 0 or y != 0:
		if x > 0 and y > 0:
			if b > a * 2:
				menor = min(x, y)
				cont += a * 2 * menor
				x -= 1 * menor
				y -= 1 * menor
			else:
				menor = min(x, y)
				cont += b * menor
				y -= 1 * menor
				x -= 1 * menor
		elif x > 0:
			cont += a * x
			x = 0
		else:
			cont += a * y
			y = 0
	print(cont)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	p = min(x, y)
	q = max(x, y)
	rem = q - p
	cost = rem * a + p * b
	cost1 = (x + y) * a
	print(min(cost, cost1))


def main():
	from bisect import bisect_left as bl, bisect_right as br, insort
	import sys
	import heapq
	from collections import defaultdict as dd, deque

	def data():
		return sys.stdin.readline().strip()

	def mdata():
		return map(int, data().split())
	out = sys.stdout.write
	for i in range(int(data())):
		(x, y) = mdata()
		(a, b) = mdata()
		print(min(abs(x - y) * a + min(x, y) * b, (x + y) * a))
main()


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = 0
	f = 0
	if b > 2 * a:
		f = 1
	if f == 0:
		t = max(x, y)
		u = min(x, y)
		print(b * u + a * (t - u))
	else:
		print(a * (x + y))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	total = 0
	cost = 0
	num = 0
	blabla = a * (x + y)
	if x == y:
		total = y
		num = 0
	elif x < y:
		num = y - x
		total = x
	elif y < x:
		num = x - y
		total = y
	cost = num * a + total * b
	print(min(cost, blabla))


test = int(input())
for i in range(test):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	ans = 0
	if x == 0 and y == 0:
		ans = 0
	elif x >= 0 and y >= 0:
		min_ = min(x, y)
		max_ = max(x, y)
		if x != y:
			ans = min((max_ - min_) * a + min_ * b, (x + y) * a)
		else:
			ans = min(y * b, 2 * a * y)
	print(ans)


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	t = min(x, y)
	t2 = max(x, y) - t
	ans1 = t * b + t2 * a
	ans = x * a + y * a
	print(min(ans, ans1))


def soln(x, y, a, b):
	result = 0
	if b <= 2 * a:
		result += abs(x - y) * a
		m = min(x, y)
		result += m * b
	elif b > 2 * a:
		result = (x + y) * a
	return result

def bruteForce(x, y, a, b):
	result = float('inf')

	def dfs(x, y, currVal):
		if x == 0 and y == 0:
			result = min(result, currVal)
		if x <= 0 or y <= 0:
			return
		dfs(x - 1, y, currVal + a)
		dfs(x, y - 1, currVal + a)
		dfs(x - 1, y - 1, currVal + b)

def main():
	t = int(input())
	for _ in range(t):
		(x, y) = [int(x) for x in input().split(' ')]
		(a, b) = [int(x) for x in input().split(' ')]
		result = soln(x, y, a, b)
		print(result)
main()


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	amt = 0
	if x > y:
		amt += a * (x - y)
		x -= x - y
	elif x == y:
		if x * b >= (x + y) * a:
			amt += a * (x + y)
		else:
			amt += b * x
		x = 0
		y = 0
	else:
		amt += a * (y - x)
		y -= y - x
	if x == y:
		if x != 0 and y != 0:
			if x * b >= (x + y) * a:
				amt += a * (x + y)
			else:
				amt += b * x
	print(amt)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	k = min(x, y)
	cc = b * k
	tt = a * x + a * y
	x -= k
	y -= k
	cc += a * x + a * y
	print(min(cc, tt))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = max(x, y) - min(y, x)
	p1 = x * a + y * a
	p2 = d * a + b * min(x, y)
	print(min(p1, p2))


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(n, m) = list(map(int, input().split()))
	if x > y:
		ss = y * m + (x - y) * n
	else:
		ss = x * m + (y - x) * n
	print(min(ss, (x + y) * n))


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if y < x:
		x = x ^ y
		y = x ^ y
		x = x ^ y
	if a * 2 >= b:
		Cost = abs(x - y) * a + x * b
	else:
		Cost = (x + y) * a
	print(Cost)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	x = l[0]
	y = l[1]
	m = 0
	n = 0
	if x > 0 and y > 0 or (x < 0 and y < 0):
		m = max(abs(x), abs(y)) - min(abs(x), abs(y))
		if b <= 2 * a:
			n = min(abs(x), abs(y))
		else:
			m += 2 * min(abs(x), abs(y))
	else:
		m = abs(x) + abs(y)
	print(m * a + n * b)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def solve(x, y, a, b):
	if x < y:
		(x, y) = (y, x)
	return min(a * (x + y), a * (x - y) + b * y)

def main():
	t = int(input())
	for _ in range(t):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		ans = solve(x, y, a, b)
		sys.stdout.write(str(ans) + '\n')
main()


t = int(input())
while t:
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	val = min(2 * min(x, y) * a, min(x, y) * b)
	val2 = (max(x, y) - min(x, y)) * a
	print(val + val2)
	t -= 1


t = int(input())
for z in range(t):
	(x, y) = map(int, input().rstrip().split())
	(a, b) = map(int, input().rstrip().split())
	if x == 0 and y == 0:
		print('0')
	else:
		if y < x:
			(x, y) = (y, x)
		between = y - x
		print(str(between * a + x * min(2 * a, b)))


ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda : int(input())
ip = lambda : [int(w) for w in input().split()]
mp = lambda : map(int, input().split())
for _ in range(int(input())):
	(x, y) = mp()
	(a, b) = mp()
	t = min(x, y) * b + abs(x - y) * a
	tt = (x + y) * a
	print(min(t, tt))


def count(x, y, a, b):
	if x == y == 0:
		return 0
	elif x == 0:
		return y * a
	elif y == 0:
		return x * a
	else:
		if 2 * a >= b:
			op = b
		else:
			op = a
		price = 0
		if x == y:
			if op == b:
				return x * op
			else:
				return (x + y) * op
		if op == b:
			if x < y:
				return op * x + a * (y - x)
			else:
				return op * y + a * (x - y)
		else:
			return (x + y) * op
for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(count(x, y, a, b))


for _ in range(int(input())):
	k = list(map(int, input().split()))
	k1 = list(map(int, input().split()))
	p = abs(min(k))
	j = min(2 * k1[0], k1[1])
	q = j * p
	k[0] -= p
	k[1] -= p
	q += k[0] * k1[0]
	q += k[1] * k1[0]
	print(q)


def solve(x, y, a, b):
	if x > y:
		(x, y) = (y, x)
	return min(x * b + (y - x) * a, (x + y) * a)
t = int(input())
g = []
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	g.append(solve(x, y, a, b))
	t -= 1
for i in g:
	print(i)


t = int(input())
for hh in range(0, t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	mn = min(x, y)
	mx = max(x, y)
	ans1 = mn * b + (mx - mn) * a
	ans2 = (x + y) * a
	print(min(ans1, ans2))


for _ in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	b = min(b, a + a)
	if x < y:
		(x, y) = (y, x)
	print(y * b + (x - y) * a)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	listt = []
	p = max(x, y)
	q = min(x, y)
	listt.append((p - q) * a + q * b)
	listt.append((x + y) * a)
	print(min(listt))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	sum = 0
	if b <= 2 * a:
		m1 = min(x, y)
		m2 = max(x, y)
		sum += m1 * b
		m2 -= m1
		sum += m2 * a
	else:
		m = x + y
		sum += m * a
	print(sum)


t = int(input())
for _ in range(t):
	(x, y) = [int(a) for a in input().split()]
	(a, b) = [int(x) for x in input().split()]
	turunin = (max(x, y) - min(x, y)) * a
	turunin_sama = min(x, y) * min(2 * a, b)
	print(turunin + turunin_sama)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	cnt = 0
	cnt += min(a, b) * min(x * 2, y)
	cnt += (max(a, b) - min(a, b)) * x
	print(cnt)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	s += min(x, y) * b
	if x == y:
		s2 = 0
		s2 += x * a + y * a
		print(min(s, s2))
	else:
		if x == min(x, y):
			s += (y - x) * a
		else:
			s += (x - y) * a
		s2 = 0
		s2 += x * a + y * a
		print(min(s, s2))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	else:
		diff = abs(x - y)
		m = min(x, y)
		m2 = min(a * 2, b)
		res = diff * a + m2 * m
		print(res)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = 0
	if x == 0 and y == 0:
		print(0)
	elif x == 0:
		steps = abs(y - 0)
		print(a * steps)
	elif y == 0:
		steps = abs(x - 0)
		print(a * steps)
	else:
		f_cost = x * a + y * a
		rem = abs(x - y)
		temp = max(x, y)
		s_cost = b * (temp - rem) + rem * a
		print(min(f_cost, s_cost))


t = int(input())

def cost(x, y, a, b):
	if x > y:
		(x, y) = (y, x)
	return min((y - x) * a + b * x, a * (x + y))
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(cost(x, y, a, b))


t = int(input())
for i in range(t):
	l = list(map(int, input().strip().split()))
	x = l[0]
	y = l[1]
	arr = list(map(int, input().strip().split()))
	a = arr[0]
	b = arr[1]
	m = 10 ** 19
	if x == y and x > 0:
		m = min(m, x * b)
		m = min(m, (x + y) * a)
		print(m)
	elif x == y and x == 0:
		print(0)
	elif x > y or y > x:
		p = x * a + y * a
		q = abs(x - y) * a + min(x, y) * b
		m = min(p, q)
		print(m)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	n = a * abs(x - y)
	c = min(min(x, y) * 2 * a, min(x, y) * b)
	n += c
	print(n)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 10 ** 9
	ans = min(abs(x - y) * a + min(abs(x), abs(y)) * b, abs(x) * a + abs(y) * a)
	print(ans)


def solve():
	(x, y) = [int(el) for el in input().split()]
	(a, b) = [int(el) for el in input().split()]
	res = (abs(x) + abs(y)) * a
	if x <= 0 and y <= 0 or (x > 0 and y > 0):
		res = min([min([abs(x), abs(y)]) * b + abs(x - y) * a, res])
	return res
for t in range(1, int(input()) + 1):
	print(solve())


t = int(input())
for _ in range(t):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if 2 * a <= b or x * y < 0:
		print((abs(x) + abs(y)) * a)
	else:
		x = abs(x)
		y = abs(y)
		(x, y) = (max(x, y), min(x, y))
		print(a * (x - y) + b * y)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print((x + y) * a)
	else:
		s = 0
		c = min(x, y)
		s = s + c * b
		x = x - c
		y = y - c
		if x > 0:
			s = s + x * a
		else:
			s = s + y * a
		print(s)


t = int(input())
for _ in range(t):
	xy = input().split()
	x = int(xy[0])
	y = int(xy[1])
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	if b > 2 * a:
		b = 2 * a
	if x * y < 0:
		print(a * (abs(x) + abs(y)))
	else:
		diff = abs(x - y)
		print(a * diff + b * min(abs(x), abs(y)))


import sys
readline = sys.stdin.readline
writeline = sys.stdout.write
for _ in range(int(readline())):
	(x, y) = map(int, readline().split())
	(a, b) = map(int, readline().split())
	print(min(b * min(x, y) + a * abs(x - y), a * (x + y)))


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b <= 2 * a:
		print((max(x, y) - min(x, y)) * a + min(x, y) * b)
	else:
		print((x + y) * a)
	t -= 1


t = int(input())
for i in range(t):
	(x, y) = [int(j) for j in input().split()]
	(a, b) = [int(j) for j in input().split()]
	res = 0
	if a < b / 2:
		res = (x + y) * a
	else:
		(minim, maxim) = (min(x, y), max(x, y))
		res += minim * b
		res += (maxim - minim) * a
	print(res)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s1 = abs(x) * a + abs(y) * a
	s2 = abs(x) * b + abs(y - x) * a
	s3 = abs(y) * b + abs(x - y) * a
	print(min(s1, s2, s3))


n = int(input())
for i in range(n):
	line = list(map(int, input().split()))
	x = line[0]
	y = line[1]
	maior = max(x, y)
	menor = min(x, y)
	line = list(map(int, input().split()))
	a = line[0]
	b = line[1]
	p = 0
	if a * 2 < b:
		p += a * x + a * y
	else:
		p += b * menor
		p += a * (maior - menor)
	print(p)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < y:
		(x, y) = (y, x)
	if a + a <= b:
		print(a * (x + y))
	elif a + a > b:
		print(b * y + a * (x - y))


T = int(input())

def road_to_zero():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = 0
	if 2 * a <= b:
		cost = (x + y) * a
	elif x > y:
		cost = (x - y) * a + y * b
	else:
		cost = (y - x) * a + x * b
	print(cost)
while T > 0:
	road_to_zero()
	T -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	if x or y:
		(x, y) = (min(x, y), max(x, y))
		if a < b:
			s = (y - x) * a
			s += b * x if b < 2 * a else 2 * a * x
		else:
			s = b * x + a * (y - x)
	print(s)


def main():
	t = int(input())
	for _ in range(t):
		(x, y) = list(map(int, input().strip().split()))
		(a, b) = list(map(int, input().strip().split()))
		ret = min(x, y) * b + (max(x, y) - min(x, y)) * a
		ret = min(ret, (x + y) * a)
		print(ret)
main()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print('0')
		continue
	x = abs(x)
	y = abs(y)
	ans = a * (max(x, y) - min(x, y))
	t = min(x, y)
	ans += min(t * b, t * a * 2)
	print(ans)


for i in range(int(input())):
	(x, y, a, b) = (int(i) for i in input().split() + input().split())
	print(min(min(x, y) * b + (max(x, y) - min(x, y)) * a, a * (x + y)))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	money = 0
	if 2 * a > b:
		if x > 0 and y > 0:
			d = min(x, y)
			x -= d
			y -= d
			money += d * b
		elif x < 0 and y < 0:
			d = abs(max(x, y))
			x += d
			y += d
			money += d * b
	money += abs(x) * a
	money += abs(y) * a
	print(money)


t = int(input())
for test in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	d = abs(x - y)
	c = d * a
	if b < 2 * a:
		c += min(x, y) * b
	else:
		c += min(x, y) * 2 * a
	print(c)


t = int(input())
l = []
c = []
for i in range(t):
	l.append([int(x) for x in input().split()])
	c.append([int(x) for x in input().split()])
for i in range(t):
	if 2 * c[i][0] < c[i][1]:
		print((l[i][0] + l[i][1]) * c[i][0])
	else:
		print(abs(l[i][0] - l[i][1]) * c[i][0] + min(l[i]) * c[i][1])


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		res = b * x
	elif x > y:
		res = a * (x - y) + b * y
	else:
		res = a * (y - x) + b * x
	res2 = (x + y) * a
	print(min(res, res2))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		(x, y) = LI()
		(a, b) = LI()
		if a * 2 <= b:
			r = (x + y) * a
		else:
			if x > y:
				(x, y) = (y, x)
			r = b * x + a * (y - x)
		rr.append(r)
	return JA(rr, '\n')
print(main())


n = int(input())
for i in range(n):
	s = input().split(' ')
	s1 = input().split(' ')
	x = int(s[0])
	y = int(s[1])
	a = int(s1[0])
	b = int(s1[1])
	sum = min(a * 2 * min(x, y), b * min(x, y))
	print(sum + abs(x - y) * a)


t1 = int(input())
while t1:
	(x, y) = input().split(' ')
	(x, y) = (int(x), int(y))
	(a, b) = input().split(' ')
	(a, b) = (int(a), int(b))
	if x >= 0 and y >= 0:
		t = min(x, y)
		ans = t * b + (max(x, y) - t) * a
		ans = min(ans, (x + y) * a)
	if x >= 0 and y < 0:
		ans = min(x * a + (x - y) * b, -y * a + (x - y) * b)
		ans = min(ans, (x - y) * a)
	if x < 0 and y < 0:
		t = min(-x, -y)
		ans = t * b + (min(x, y) + t) * a * -1
		ans = min(ans, (x + y) * a * -1)
	if x < 0 and y >= 0:
		ans = min(y * a + (y - x) * b, -x * a + (y - x) * b)
		ans = min(ans, (y - x) * a)
	print(ans)
	t1 -= 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(m, n) = map(int, input().split())
	s = 0
	if a >= 0 and b >= 0 or (a < 0 and b < 0):
		if a < 0 and b < 0:
			(a, b) = (abs(a), abs(b))
		if n <= 2 * m:
			z = min(a, b)
			(a, b) = (a - z, b - z)
			s += z * n + m * max(a, b)
		else:
			s += m * (a + b)
	else:
		s += m * (abs(a) + abs(b))
	print(s)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, 2 * a)
	ans = b * min(x, y) + a * (max(x, y) - min(x, y))
	print(ans)


def zeros(a, b, x, y):
	if a <= b / 2:
		return (x + y) * a
	else:
		return min(x, y) * b + abs(x - y) * a
m = int(input())
for _ in range(m):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(zeros(a, b, x, y))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dif = abs(x - y)
	ans = dif * a
	x = min(x, y)
	print(min(b * x + ans, 2 * a * x + ans))


t = int(input())
for r in range(t):
	xy = list(map(int, input().split()))
	ab = list(map(int, input().split()))
	x = xy[0]
	y = xy[1]
	a = ab[0]
	b = ab[1]
	d = min(a, b)
	q = min(x, y)
	e = max(x, y)
	z = abs(x - y)
	l = []
	l.append((x + y) * a)
	if b > a:
		l.append(a * z + b * q)
	else:
		l.append(q * b + a * (e - q))
	print(min(l))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x * y >= 0:
		d1 = max(x, y) - min(x, y)
		p1 = d1 * a + min(x, y) * b
		p2 = a * (x + y)
		print(min(p1, p2))
	else:
		print((x + y) * a)


from sys import stdin, stdout
from collections import defaultdict, Counter
from functools import lru_cache
from math import gcd, floor, ceil

def ilist():
	return [int(x) for x in stdin.readline().strip().split(' ')]

def iint():
	return int(stdin.readline().strip())

def istr():
	return stdin.readline().strip()

def solve(x, y, a, b):
	way1 = min(x, y) * b + abs(x - y) * a
	way2 = (x + y) * a
	return min(way1, way2)
t = iint()
for _ in range(t):
	(x, y) = ilist()
	(a, b) = ilist()
	print(solve(x, y, a, b))


from collections import deque
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dif = abs(x - y)
	print(min(dif * a + min(x, y) * b, (x + y) * a))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	spend1 = min(x, y) * b + (max(x, y) - min(x, y)) * a
	spend2 = max(x, y) * b + (max(x, y) - min(x, y)) * a
	spend3 = (x + y) * a
	print(min(spend1, spend2, spend3))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mi = min(x, y)
	result1 = mi * b + (x - mi) * a + (y - mi) * a
	result2 = (x + y) * a
	print(min(result1, result2))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	print(max(a - b, b - a) * c + min(min(a, b) * d, min(a, b) * 2 * c))


t = int(input())
for tt in range(t):
	(x, y) = (int(i) for i in input().split())
	(a, b) = (int(i) for i in input().split())
	if abs(x) > abs(y):
		(x, y) = (y, x)
	useb = False
	if b < 2 * a:
		useb = True
	diffsign = (x < 0) != (y < 0)
	ans = (abs(x) + abs(y)) * a if not useb or diffsign else abs(x) * b + (abs(y) - abs(x)) * a
	print(ans)


from sys import stdin, stdout
import bisect
import math
import itertools
_INPUT = -1
input = []

def I():
	global _INPUT
	_INPUT += 1
	INPUT = list(map(int, input[_INPUT].split()))
	if len(INPUT) == 1:
		return INPUT[0]
	else:
		return INPUT

def IS():
	global _INPUT
	_INPUT += 1
	INPUT = list(map(str, input[_INPUT].split()))
	if len(INPUT) == 1:
		return INPUT[0]
	else:
		return INPUT

def IA():
	global _INPUT
	_INPUT += 1
	INPUT = list(map(int, input[_INPUT].split()))
	return INPUT

def IAS():
	global _INPUT
	_INPUT += 1
	INPUT = list(map(str, input[_INPUT].split()))
	return INPUT
ONLINE_JUDGE = not __debug__
if ONLINE_JUDGE:
	stdin = open('input.txt', 'r')
input = stdin.readlines()
t = I()
for _ in range(t):
	(x, y) = I()
	(a, b) = I()
	print(min((x + y) * a, (max(x, y) - min(x, y)) * a + min(x, y) * b))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (min(abs(x), abs(y)), max(abs(x), abs(y)))
	fir = x * b + (y - x) * a
	sec = (x + y) * a
	print(min(fir, sec))


for T in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	maxi = max(x, y)
	mini = min(x, y)
	diff = maxi - mini
	val = diff * a
	cost = 2 * a
	if 2 * a > b:
		cost = b
	val += mini * cost
	print(val)


def solve():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = abs(x - y)
	a1 = a * (x + y)
	a2 = b * min(x, y) + a * d
	print(min(a1, a2))
for i in range(int(input())):
	solve()


from math import *
t = int(input())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if 2 * a <= b:
		print(a * (int(fabs(x)) + int(fabs(y))))
	elif x * y == 0:
		if x == 0:
			print(a * int(fabs(y)))
		else:
			print(a * int(fabs(x)))
	elif x * y > 0:
		(x, y) = (int(fabs(x)), int(fabs(y)))
		(x, y) = (min(x, y), max(x, y))
		print(b * x + a * (y - x))
	else:
		print(a * (int(fabs(x)) + int(fabs(y))))


from collections import Counter
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b < 2 * a:
		if x * y < 0:
			print(abs(x - y) * a)
		else:
			print(abs(x - y) * a + min(abs(x), abs(y)) * b)
	else:
		print((abs(x) + abs(y)) * a)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(c, d) = (min(x, y), max(x, y))
	print(c * min(a * 2, b) + (d - c) * a)


import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x1 = x
	y1 = y
	a1 = min(x, y) * b
	t = min(x, y)
	x = x - t
	y = y - t
	if x == 0:
		a1 += y * a
	else:
		a1 += x * a
	a2 = (x1 + y1) * a
	print(min(a1, a2))


for _ in range(int(input())):
	(LEN1, LEN2) = map(int, input().split())
	(ALEN, BLEN) = map(int, input().split())
	if BLEN <= 2 * ALEN:
		(LEN1, LEN2) = (min(LEN1, LEN2), max(LEN1, LEN2))
		ANSWER = LEN1 * BLEN + (LEN2 - LEN1) * ALEN
	else:
		ANSWER = (LEN2 + LEN1) * ALEN
	print(ANSWER)


import sys
from collections import defaultdict
from copy import copy
R = lambda t=int: t(input())
RL = lambda t=int: [t(x) for x in input().split()]
RLL = lambda n, t=int: [RL(t) for _ in range(n)]

def solve():
	(x, y) = RL()
	(a, b) = RL()
	print(min((x + y) * a, min(x, y) * b + abs(x - y) * a, max(x, y) * b + abs(x - y) * a))
T = R()
for _ in range(T):
	solve()


t = int(input())
for u in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(min((x + y) * a, min(x, y) * b + (max(x, y) - min(x, y)) * a))


t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if a < b / 2:
		print(x * a + y * a)
	else:
		menor = min(x, y)
		maior = max(x, y)
		print((maior - menor) * a + menor * b)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ans = 0
	if 2 * a <= b:
		ans = (x + y) * a
	else:
		ans = min(x, y) * b
		ans += (max(x, y) - min(x, y)) * a
	print(ans)


def fun(x, y, a, b):
	h = min(x, y)
	g = h * b
	if h == x:
		h = y - h
	else:
		h = x - h
	g += h * a
	m = x + y
	g1 = m * a
	print(min(g, g1))
for T in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	fun(x, y, a, b)


def count():

	def znak(x):
		if x < 0:
			return -1
		elif x > 0:
			return 1
		else:
			return 0
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	if znak(x) == znak(y):
		if 2 * a <= b:
			print(2 * a * min(abs(x), abs(y)) + a * abs(x - y))
		else:
			print(b * min(abs(x), abs(y)) + a * abs(x - y))
	else:
		print(a * (abs(x) + abs(y)))
for i in range(int(input())):
	count()


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass
test = 1
test = int(input().strip())
for t in range(0, test):
	(x, y) = list(map(int, input().strip().split()))
	(a, b) = list(map(int, input().strip().split()))
	a1 = a * abs(x) + a * abs(y)
	m = min(x, y)
	a2 = m * b + a * abs(x - y)
	print(min(a1, a2))
	ans = solve()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	total = 0
	diff = max(x, y) - min(x, y)
	total += diff * a
	mini = min(x, y)
	if mini * b < mini * 2 * a:
		total += mini * b
	else:
		total += mini * 2 * a
	print(total)


for i in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if x > 0 and y > 0:
		if x < y:
			z = y - x
			c = z * a + x * b
			b = (x + y) * a
			print(min(c, b))
		elif x > y:
			z = x - y
			c = z * a + y * b
			b = (x + y) * a
			print(min(c, b))
		else:
			print(min((x + y) * a, x * b))
	elif x > 0 and y >= 0 or (x >= 0 and y > 0):
		if x == 0:
			print(y * a)
		else:
			print(x * a)
	else:
		print(0)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	total = 0
	if x > y:
		total += a * (x - y)
		x -= x - y
	elif y > x:
		total += a * (y - x)
		y -= y - x
	if b > 2 * a:
		total += a * (x + y)
	else:
		total += b * x
	print(total)


for _ in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if x == y:
		num1 = b * x
		num2 = 2 * a * x
		print(min(num1, num2))
		continue
	diff = abs(x - y)
	num = a * diff
	num1 = num + 2 * a * min(x, y)
	num2 = num + b * min(x, y)
	print(min(num1, num2))


T = int(input())
while T > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	case1 = a * (x + y)
	case2 = a * (y - x) + b * x
	if case1 < case2:
		print(case1)
	else:
		print(case2)
	T -= 1


import sys
sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline

def solve():
	(x, y) = map(int, rl().split())
	if x < y:
		(x, y) = (y, x)
	(a, b) = map(int, rl().split())
	if 2 * a <= b:
		ans = a * (x + y)
	else:
		ans = a * (x - y) + b * y
	print(ans)
t = int(rl())
for _ in range(t):
	solve()


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	score = 0
	least_score = 0
	if abs(x) > abs(y):
		smaller = y
	else:
		smaller = x
	if x * y <= 0:
		least_score = (abs(x) + abs(y)) * a + b * abs(smaller)
		score = abs(x) * a + abs(y) * a
		if score < least_score:
			least_score = score
		score = (abs(x) + abs(y)) * a + 2 * a * abs(smaller)
		if score < least_score:
			least_score = score
	else:
		least_score = a * (abs(x) + abs(y))
		score = abs(x - y) * a + abs(smaller) * b
		if score < least_score:
			least_score = score
	print(least_score)
	t -= 1


t = int(input())
p = []
for i in range(t):
	(x, y) = input().split()
	(a, b) = input().split()
	(x, y, a, b) = (int(x), int(y), int(a), int(b))
	money = 0
	if b <= a * 2:
		c = min([x, y])
		x -= c
		y -= c
		money += c * b
		money += x * a + y * a
		print(money)
	else:
		print(sum([x, y]) * a)


t = int(input())
for you in range(t):
	l = input().split()
	x = int(l[0])
	y = int(l[1])
	l = input().split()
	a = int(l[0])
	b = int(l[1])
	if b >= 2 * a:
		ans = a * (abs(x) + abs(y))
	else:
		ans = b * min(abs(x), abs(y)) + a * abs(x - y)
	print(ans)


from sys import stdin, stdout
import heapq as hq
from collections import defaultdict
t = int(input())
for tc in range(t):
	(x, y) = list(map(int, stdin.readline().split()))
	(a, b) = list(map(int, stdin.readline().split()))
	if 2 * a <= b or x <= 0 <= y or y <= 0 <= x:
		res = a * (abs(x) + abs(y))
	else:
		res = b * min(abs(x), abs(y)) + a * (max(abs(x), abs(y)) - min(abs(x), abs(y)))
	stdout.write(str(res) + '\n')


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	if b // 2 < a:
		if x - y > 0:
			s = b * y
			x = x - y
			y = 0
		elif x - y < 0:
			s = b * x
			y = y - x
			x = 0
		else:
			s = b * x
			x = y = 0
		if y == 0 and x != 0:
			s = s + x * a
			x = 0
		elif x == 0 and y != 0:
			s = s + y * a
	else:
		s = (x + y) * a
	print(s)
	t -= 1


from __future__ import division, print_function
from collections import *
from math import *
from itertools import *
from time import time
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	small = min(2 * a, b)
	if x > y:
		smaller = y
		bigger = x
	else:
		smaller = x
		bigger = y
	print(abs(x - y) * a + small * smaller)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	main()
	t -= 1


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(x, y) = map(int, stdin.readline().split())
	(a, b) = map(int, stdin.readline().split())
	if x > y:
		(x, y) = (y, x)
	stdout.write(str(min([b * x + (y - x) * a, b * y + (y - x) * a, a * (x + y)])) + '\n')


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(c, d) = (max(x, y), min(x, y))
	if 2 * a < b:
		b = 2 * a
	print((c - d) * a + d * b)


T = int(input())

def solve():
	[x, y] = list(map(int, input().split()))
	[a, b] = list(map(int, input().split()))
	only_a = a * abs(x) + a * abs(y)
	use_greedy = float('inf')
	if x <= 0 and y <= 0 or (x >= 0 and x >= 0):
		x_abs = abs(x)
		y_abs = abs(y)
		mn = min(x_abs, y_abs)
		use_greedy = b * mn + a * (x_abs - mn) + a * (y_abs - mn)
	print(min(only_a, use_greedy))
for _ in range(T):
	solve()


from math import gcd
from sys import stdin
inp = stdin.readline
t = int(inp().strip())
for _ in range(t):
	(x, y) = [int(x) for x in inp().strip().split()]
	(a, b) = [int(x) for x in inp().strip().split()]
	minimum = min(x, y)
	maximum = max(x, y)
	cost = 0
	flag = False
	if b >= a * 2:
		flag = True
	if flag == False:
		cost += b * minimum
		cost += a * (maximum - minimum)
	else:
		cost += a * minimum * 2
		cost += a * (maximum - minimum)
	print(cost)


from sys import stdin, stdout
t = int(input())
for _ in range(t):
	(x, y) = map(int, stdin.readline().split())
	(a, b) = map(int, stdin.readline().split())
	ans = 0
	if a == 0 and b == 0:
		print(0)
		continue
	if b >= 2 * a:
		ans = (x + y) * a
		print(ans)
	else:
		z = min(x, y)
		k = max(x, y)
		ans += b * z
		ans += a * (k - z)
		print(ans)


t = int(input())
for i in range(0, t, 1):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = min((x + y) * a, min(x, y) * b + (max(x, y) - min(x, y)) * a)
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	z = min(x, y)
	c = abs(x - y)
	s = 0
	s = s + c * a
	s1 = 2 * z * a
	s2 = z * b
	s = s + min(s1, s2)
	print(s)


for rkbaar in range(1):
	for tini in range(int(input())):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		an = a * abs(x - y) + b * min(x, y)
		at = a * abs(x - y) + b * max(x, y)
		ab = a * x + a * y
		print(min(an, at, ab))


T = int(input())
while T:
	(cost1, cost2) = (0, 0)
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost2 = x * a + y * a
	minXY = min(x, y)
	cost1 = minXY * b
	if x == y:
		cost1 = x * b
	elif x < y:
		y -= x
		cost1 += y * a
	else:
		x -= y
		cost1 += x * a
	print(min(cost1, cost2))
	T -= 1


def main():
	t = int(input())
	for _ in range(t):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		b = min(2 * a, b)
		if x >= 0 and y >= 0 or (x <= 0 and y <= 0):
			x = abs(x)
			y = abs(y)
			print(b * min(x, y) + a * abs(x - y))
		else:
			x = abs(x)
			y = abs(y)
			print(a * abs(x + y))
main()


T = int(input())
for t in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c1 = a * (x + y)
	diff = abs(x - y)
	c2 = a * diff + b * (max(x, y) - diff)
	print(min(c1, c2))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	l = []
	if x == 0 and y == 0:
		print(0)
		continue
	else:
		l.append((x + y) * a)
		if x > y:
			l.append(y * b + (x - y) * a)
		elif x < y:
			l.append(x * b + (y - x) * a)
		if x == y:
			l.append(x * 2 * a)
			l.append(x * b)
		print(min(l))


t = int(input())
result = []
for i in range(t):
	e = input()
	es = list(map(int, e.split(' ')))
	d = input()
	ds = list(map(int, d.split(' ')))
	if ds[0] * 2 > ds[1]:
		if es[0] * es[1] > 0:
			es[0] = abs(es[0])
			es[1] = abs(es[1])
			firsttime = min(es[0], es[1])
			es[0] -= firsttime
			es[1] -= firsttime
			secondtime = max(es[0], es[1])
			dollar = ds[0] * secondtime + ds[1] * firsttime
		else:
			dollar = ds[0] * (abs(es[0]) + abs(es[1]))
	else:
		dollar = ds[0] * (abs(es[0]) + abs(es[1]))
	result.append(dollar)
for i in range(t):
	print(result[i])
print()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(x, y) = list(map(int, input().split()))
		(a, b) = list(map(int, input().split()))
		if b >= 2 * a:
			yield ((x + y) * a)
		else:
			yield (min(x, y) * b + (max(x, y) - min(x, y)) * a)
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
for inh in range(0, t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b >= 2 * a:
		ans = (x + y) * a
	else:
		m = min(x, y)
		x -= m
		y -= m
		ans = m * b + a * (x + y)
	print(ans)


test_cases = int(input())
while test_cases > 0:
	(first_num, sec_num) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		operations = first_num + sec_num
		print(operations * a)
	elif first_num == sec_num:
		print(b * abs(sec_num))
	else:
		operations = abs(first_num - sec_num)
		print(min(operations * a + b * first_num, operations * a + b * sec_num))
	test_cases -= 1


t = int(input())
for caso in range(t):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	(n, m) = (0, 0)
	if b <= 2 * a:
		n = min(x, y) * b
		m = (max(x, y) - min(x, y)) * a
	else:
		m = (x + y) * a
	print(m + n)


t = int(input())
for t0 in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 <= b:
		ans = (abs(x) + abs(y)) * a
	elif x * y > 0:
		c = max(x, y)
		d = min(x, y)
		ans = d * b + (c - d) * a
	else:
		ans = (abs(x) + abs(y)) * a
	print(ans)


n = int(input())
while n > 0:
	n = n - 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a < b:
		ans = (x + y) * a
	else:
		ans = min(x, y) * b + a * abs(x - y)
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	a1 = min(x, y)
	b1 = max(x, y)
	op1 = 0
	op2 = 0
	if a * 2 <= b:
		print((x + y) * a)
	else:
		op1 = a1 * b
		op2 = (b1 - a1) * a
		print(op1 + op2)


import sys
import math
from collections import defaultdict

def solve(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res1 = abs(x - y) * a + min(x, y) * b
	res2 = (x + y) * a
	ans = min(res1, res2)
	print(ans)
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


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

def I():
	return int(input())

def S():
	return str(input())

def L():
	return list(R())
from collections import Counter
import math
import sys
from itertools import permutations
import bisect
for _ in range(I()):
	(x, y) = R()
	(a, b) = R()
	if x < y:
		(x, y) = (y, x)
	if 2 * a <= b:
		print((x + y) * a)
	else:
		print((x - y) * a + y * b)


t = int(input())
for i in range(t):
	(e, f) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	x = abs(e)
	y = abs(f)
	sum = 0
	if 2 * a > b:
		while x != 0 and y != 0:
			if x > y:
				x -= y
				sum = sum + y * b
				y = 0
			elif x < y:
				y -= x
				sum = sum + x * b
				x = 0
			else:
				sum = sum + x * b
				(x, y) = (0, 0)
		if x == 0:
			sum = sum + y * a
		else:
			sum = sum + x * a
		print(sum)
	else:
		sum = (x + y) * a
		print(sum)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x >= y:
		ans1 = a * (x - y) + b * y
	else:
		ans1 = a * (y - x) + b * x
	ans2 = a * (x + y)
	if ans1 > ans2:
		print(ans2)
	else:
		print(ans1)
	t -= 1


t = int(input())

def solve(amount, a_b):
	(x1, x2) = amount
	(a, b) = a_b
	if x1 > x2:
		(x1, x2) = (x2, x1)
	(money_1, money_2) = (abs(x1) * b, abs(x2) * b)
	money_3 = (x2 - x1) * a
	return min(money_1 + money_3, money_2 + money_3, abs(x1) * a + abs(x2) * a)
for i in range(t):
	amount = list(map(int, input().split()))
	dollar = list(map(int, input().split()))
	print(solve(amount, dollar))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	if a * 2 < b:
		ans = (x + y) * a
		print(ans)
		continue
	else:
		ans = m * b
	ans = ans + (max(x, y) - m) * a
	print(ans)


t = int(input())
for k in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	val = abs(x - y)
	temp = min(x, y)
	ans1 = a * val + b * temp
	ans2 = a * val + a * temp * 2
	if ans1 < ans2:
		print(ans1)
	else:
		print(ans2)


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	d = y - x
	p = 0
	p = d * a
	p += x * min(2 * a, b)
	stdout.write(str(p) + '\n')


t = int(input())
for j in range(t):
	l = list(map(int, input().split()))
	g = list(map(int, input().split()))
	a = g[0]
	b = g[1]
	c = l[0]
	d = l[1]
	e = abs(c - d)
	s = 0
	s += a * e
	s += b * min(c, d)
	f = 0
	f += a * e
	f += b * max(c, d)
	m = min(f, a * (c + d))
	print(min(s, m))


import math
from collections import deque

def ii():
	return int(input())

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

def matr(n):
	return [list(minp()) for _ in range(n)]
for _ in range(ii()):
	(x, y) = mii()
	(a, b) = mii()
	if x < y:
		(x, y) = (y, x)
	print(y * min(a + a, b) + (x - y) * a)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans1 = abs(x - y) * a + min(x, y) * b
	ans2 = (x + y) * a
	ans3 = max(x, y) * b + abs(x - y) * a
	print(min(ans1, ans2, ans3))


t = int(input())
while t > 0:
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	sum = 0
	if x == 0 and y == 0:
		print(sum)
	else:
		if x > y:
			sum = sum + b * y
			sum += a * (x - y)
		elif y > x:
			sum += b * x
			sum += a * (y - x)
		else:
			sum += b * x
		print(min(sum, (x + y) * a))
	t -= 1


def getCost(x, y, a, b):
	costA = (x + y) * a
	costMix = abs(x - y) * a + b * min(x, y)
	return min(costA, costMix)
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = getCost(x, y, a, b)
	print(cost)


T = int(input())

def main():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b <= 2 * a:
		if x + y == 0:
			return 0
		elif x == 0 and y > 0:
			return y * a
		elif x > 0 and y == 0:
			return x * a
		else:
			return min(x, y) * b + (max(x, y) - min(x, y)) * a
	elif b > 2 * a:
		return (x + y) * a
for _ in range(T):
	print(main())


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		s1 = x * b
		s2 = (x + y) * a
		print(min(s1, s2))
		continue
	else:
		s1 = (x + y) * a
		if x > y:
			n = x
			m = y
		else:
			n = y
			m = x
		z = n - m
		s = z * a
		s2 = s + n * b
		n = n - z
		s3 = s + n * b
		print(min(s1, s2, s3))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cc = min(x, y)
	dd = max(x, y)
	if 2 * a < b:
		print((dd - cc) * a + cc * 2 * a)
	else:
		print((dd - cc) * a + cc * b)


def min(i, j):
	if i > j:
		return j
	else:
		return i

def abs(i):
	if i < 0:
		return -i
	else:
		return i
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(abs(n - m) * a + min(n, m) * min(2 * a, b))


def ans(x, y, a, b):
	if x == 0 and y == 0:
		return 0
	s1 = 0
	s2 = 0
	s1 += abs(x - y) * a
	p = min(x, y)
	s1 += abs(p) * b
	s2 += abs(x) * a + abs(y) * a
	return min(s1, s2)
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(ans(x, y, a, b))


t = int(input().strip())
for _ in range(t):
	(x, y) = [int(x) for x in input().strip().split()]
	(a, b) = [int(x) for x in input().strip().split()]
	print(min(abs(x - y) * a + b * min(x, y), (x + y) * a))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(2 * a, b)
	mi = min(x, y)
	ma = max(x, y)
	ans = mi * b + (ma - mi) * a
	print(ans)


T = int(input())
for t in range(T):
	(x, y) = [int(i) for i in input().split(' ')]
	(a, b) = [int(i) for i in input().split(' ')]
	if a < b * 0.5:
		print(a * (x + y))
	else:
		print(b * min(x, y) + a * (max(x, y) - min(x, y)))


x = []
a = []
num = input()
i = 0
while i < int(num) * 2:
	if i % 2 == 0:
		x.append(input())
	else:
		a.append(input())
	i = i + 1
ans = 0
iterator = 0
while iterator < int(num):
	if int(x[iterator].split(' ')[0]) == int(x[iterator].split(' ')[1]):
		ans = int(a[iterator].split(' ')[1]) * int(x[iterator].split(' ')[0])
	else:
		e = max(int(x[iterator].split(' ')[0]), int(x[iterator].split(' ')[1])) - min(int(x[iterator].split(' ')[0]), int(x[iterator].split(' ')[1]))
		ans = e * int(a[iterator].split(' ')[0])
		ans = ans + min(int(x[iterator].split(' ')[0]), int(x[iterator].split(' ')[1])) * int(a[iterator].split(' ')[1])
	ans1 = (int(x[iterator].split(' ')[0]) + int(x[iterator].split(' ')[1])) * int(a[iterator].split(' ')[0])
	print(min(ans, ans1))
	iterator = iterator + 1


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y and x == 0 and (y == 0):
		print(0)
	elif x == 0 and y != 0:
		print(a * y)
	elif y == 0 and x != 0:
		print(a * x)
	elif x <= y:
		temp = y - x
		an1 = x * b
		an2 = 2 * x * a
		if an1 <= an2:
			print(temp * a + an1)
		else:
			print(temp * a + an2)
	else:
		temp = x - y
		an1 = y * b
		an2 = 2 * y * a
		if an1 <= an2:
			print(temp * a + an1)
		else:
			print(temp * a + an2)


for t in range(int(input().strip())):
	(x, y) = tuple(map(int, input().strip().split()))
	(a, b) = tuple(map(int, input().strip().split()))
	ans = 0
	if 2 * a <= b:
		ans = (x + y) * a
	else:
		ans = min(x, y) * b + abs(x - y) * a
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	sum = 0
	z = min(x, y)
	q = max(x, y)
	if x == 0 and y == 0:
		print(0)
	else:
		if 2 * a > b:
			sum = b * min(x, y) + a * (q - z)
		else:
			sum = a * (x + y)
		print(sum)


def solve():
	t = int(input())
	for i in range(t):
		s = 0
		(x, y) = sorted([int(s) for s in input().split()])
		(a, b) = [int(s) for s in input().split()]
		s += a * (y - x)
		y = x
		if b < a * 2:
			s += x * b
		else:
			s += a * 2 * x
		print(s)
solve()


import sys
t = int(sys.stdin.readline().rstrip())

def main():
	for _ in range(t):
		(x, y) = map(int, sys.stdin.readline().split())
		(a, b) = map(int, sys.stdin.readline().split())
		if x > y:
			(x, y) = (y, x)
		print((x + y) * a if a * 2 <= b else (y - x) * a + x * b)
main()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if 2 * a <= b:
		ans = (x + y) * a
		print(ans)
		continue
	if x < 0 and y < 0:
		x *= -1
		y *= -1
	while x != 0 and y != 0:
		if x > 0 and y > 0:
			if x > y:
				x = x - y
				ans += y * b + x * a
				x = 0
				y = 0
			else:
				y = y - x
				ans += x * b + y * a
				y = 0
				x = 0
	ans += abs(x) * a + abs(y) * a
	print(ans)


test = int(input())
while test > 0:
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if x > y or x < y:
		Max = max(x, y)
		Min = min(x, y)
		cost = (Max - Min) * a + min(Min * 2 * a, Min * b)
	else:
		cost = min(x * 2 * a, x * b)
	print(cost)
	test = test - 1


tes = int(input())
while tes > 0:
	tes -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		z = x
		x = y
		y = z
	if a * 2 < b:
		print((x + y) * a)
	else:
		print(x * b + (y - x) * a)


import sys
from collections import defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
for _ in range(int(data())):
	(x, y) = sp()
	(a, b) = sp()
	if x < y:
		c = x * b + (y - x) * a
		d = (y + x) * a
		print(min(c, d))
	elif y < x:
		c = y * b + (x - y) * a
		d = (x + y) * a
		print(min(c, d))
	else:
		c = x * b
		d = 2 * x * a
		print(min(c, d))


t = int(input())
for _ in range(t):
	(x, y) = input().split(' ')
	x = int(x)
	y = int(y)
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	costo = 0
	if b < 2 * a:
		diferencia = min(x, y)
		x = x - diferencia
		y = y - diferencia
		costo += diferencia * b
	else:
		costo += x * a
		x = 0
	if y > 0:
		costo += y * a
	elif x > 0:
		costo += x * a
	print(costo)


ans = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	if b > a * 2:
		b = a * 2
	ans.append(x * b + (y - x) * a)
print('\n'.join(map(str, ans)))


t = int(input())
for i in range(0, t):
	linea2 = [int(x) for x in input().split()]
	linea1 = [int(x) for x in input().split()]
	a = linea1[0]
	b = linea1[1]
	x = linea2[0]
	y = linea2[1]
	if b < 2 * a:
		if x < y:
			print(a * (y - x) + b * x)
		else:
			print(a * (x - y) + b * y)
	else:
		print(a * (x + y))


class inp:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def ilist():
		return list(map(int, input().split()))

	@staticmethod
	def imap():
		return map(int, input().split())

	@staticmethod
	def list():
		return input().split()

	@staticmethod
	def str():
		return list(input())

def main():
	t = inp.int()
	for _ in range(t):
		(x, y) = inp.imap()
		(a, b) = inp.imap()
		if x * y > 0:
			(x, y) = (abs(x), abs(y))
			if b >= 2 * a:
				ans = (x + y) * a
			else:
				t = min(x, y)
				ans = t * b
				ans += (x + y - 2 * t) * a
		else:
			ans = (abs(x) + abs(y)) * a
		print(ans)
main()


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(x, y) = invr()
	(a, b) = invr()
	temp = max(x, y)
	temp2 = min(x, y)
	x = temp2
	y = temp
	aneg = abs(x - y)
	bfirst = b * y + aneg * a
	bremain = y - x
	afirst = b * x + bremain * a
	c = a * x + a * y
	print(min(min(afirst, bfirst), c))


t = int(input())
i = 0
while i < t:
	s = input().split()
	x = int(s[0])
	y = int(s[1])
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	if x < y:
		(x, y) = (y, x)
	if y >= 0:
		print(a * (x - y) + min(a * 2, b) * y)
	elif x <= 0:
		print(a * (x - y) + min(a * 2, b) * -x)
	elif x > 0 > y:
		print(min((x + y) * a, b * min(x, -y) + a * (max(x, -y) + min(x, -y))))
	i += 1


for t in range(int(input())):
	(x, y) = [int(s) for s in input().split()]
	(a, b) = [int(s) for s in input().split()]
	if x > y:
		(x, y) = (y, x)
	z = y - x
	b = min(b, 2 * a)
	ans = b * x + a * z
	print(ans)


for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	h = abs(x - y) * a + min(x, y) * b
	z = abs(x - y) * a + min(x, y) * 2 * a
	print(min(h, z))


t = int(input())
for _ in range(t):
	(x, y) = [int(y) for y in input().split()]
	(a, b) = [int(__) for __ in input().split()]
	cost = 0
	M = max(x, y)
	m = min(x, y)
	cost += min((M - m) * a + m * b, M * a + m * a)
	print(cost)


t = int(input())
rez = []
for i in range(t):
	A = input().split()
	B = input().split()
	x = int(A[0])
	y = int(A[1])
	a = int(B[0])
	b = int(B[1])
	if b >= 2 * a:
		rez.append(a * (x + y))
	else:
		rez.append(b * min(x, y) + a * (max(x, y) - min(x, y)))
for i in range(t):
	print(rez[i])


t = int(input())
for i in range(t):
	(x, y) = map(int, input().strip().split(' '))
	(a, b) = map(int, input().strip().split(' '))
	x = abs(x)
	y = abs(y)
	res = 0
	if abs(x) > 0 and abs(y) > 0:
		k = min(x, y)
		if 2 * a < b:
			res += 2 * a * k
		else:
			res += b * k
		x = x - k
		y = y - k
	res += x * a
	res += y * a
	print(res)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a >= b:
		if x > y:
			d = x - y
			s = d * a + b * y
		elif y > x:
			d = y - x
			s = d * a + b * x
		else:
			s = b * x
	elif x > y:
		d = x - y
		s = d * a + 2 * a * y
	elif y > x:
		d = y - x
		s = d * a + 2 * a * x
	else:
		s = a * 2 * x
	print(s)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	l = abs(x - y)
	m = l * a
	x = min(x, y)
	f = min(b * x, 2 * x * a)
	g = m + f
	print(g)


t = int(input())
for j in range(t):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	minidir = (x + y) * a
	mini = min(x, y)
	price = mini * b + (max(x, y) - mini) * a
	print(min(minidir, price))


def mindollar(x, y, a, b):
	if x == 0 and y == 0:
		return 0
	elif x != 0 and y == 0:
		return x * a
	elif x == 0 and y != 0:
		return y * a
	elif x != 0 and y != 0:
		if a <= b / 2:
			return (x + y) * a
		elif x > y:
			return (x - y) * a + y * b
		elif x < y:
			return (y - x) * a + x * b
		else:
			return x * b
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	out = mindollar(x, y, a, b)
	print(out)


t = int(input())
x = 0
for i in range(t):
	s = str(input()).split()
	x = int(s[0])
	y = int(s[1])
	s = str(input()).split()
	a = int(s[0])
	b = int(s[1])
	if a <= b / 2:
		print((abs(x) + abs(y)) * a)
	else:
		if abs(x) >= abs(y):
			if y >= 0:
				c = y * b + abs(x - y) * a
			else:
				c = abs(y) * b + abs(x + y) * a
		elif x >= 0:
			c = x * b + abs(y - x) * a
		else:
			c = abs(x) * b + abs(y + x) * a
		print(c)


for _ in range(int(input().strip())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	temp1 = (x + y) * a
	temp2 = (max(x, y) - min(x, y)) * a + b * min(x, y)
	print(min(temp1, temp2))


from sys import stdin, stdout
import bisect
import math
I = lambda : list(map(int, input().split()))
t = I()
for _ in range(t[0]):
	(x, y) = I()
	(a, b) = I()
	print(min((x + y) * a, (max(x, y) - min(x, y)) * a + min(x, y) * b))


import math
t = int(input())
for _ in range(t):
	ans = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print('0')
	else:
		ans += abs(x - y) * a
		if 2 * a < b:
			ans += min(x, y) * a * 2
		else:
			ans += min(x, y) * b
		print(ans)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		if b > 2 * a:
			print(a * (x + y))
		else:
			print(b * min(x, y) + a * abs(x - y))
	q = int(input())
	for _ in range(q):
		solve()
main()


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

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

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(x, y) = int_array()
	(a, b) = int_array()
	if x == 0 and y == 0:
		print(0)
		continue
	if x == y:
		if 2 * a > b:
			print(x * b)
		else:
			print(2 * a * x)
	elif x > y:
		t = x - y
		ans = a * t
		if 2 * a > b:
			ans += y * b
		else:
			ans += 2 * a * y
		print(ans)
	else:
		t = y - x
		ans = a * t
		if 2 * a > b:
			ans += x * b
		else:
			ans += 2 * a * x
		print(ans)


for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if b > 2 * a:
		b = 2 * a
	print(a * abs(x - y) + b * min(x, y))


trials = int(input())
answers = []

def func(x, y, a, b):
	dollars = 0
	c = abs(x - y)
	d = max(x, y) - c
	if 2 * a < b:
		return (x + y) * a
	dollars += d * b
	if x == 0 and y == 0:
		return dollars
	b_odd = (c - 1) / 2 * b + a
	b_even = c * b / 2
	if c % 2 == 1:
		if b_odd > c * a:
			dollars += (c - 1) / 2 * b + a
		else:
			dollars += c * a
	elif b_even > c * a:
		dollars += (c - 1) / 2 * b + a
	else:
		dollars += c * a
	return dollars
while trials != 0:
	trials -= 1
	v = input().split()
	w = input().split()
	x = int(v[0])
	y = int(v[1])
	a = int(w[0])
	b = int(w[1])
	answer = func(x, y, a, b)
	answers.append(answer)
for i in answers:
	print(int(i))


z = []
for i in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	s = 0
	if x == 0 and y == 0:
		z.append(0)
	elif y > 0 and x > 0:
		s = abs(x - y) * a + min(x, y) * b
		s1 = (x + y) * a
		z.append(min(s, s1))
	elif x < 0 and y < 0:
		s = abs(x - y) * a + min(abs(x), abs(y)) * b
		s1 = abs(x + y) * a
		z.append(min(s, s1))
	elif x >= 0 and y <= 0:
		s = abs(x - y) * a
		z.append(s)
	elif x <= 0 and y >= 0:
		s = abs(y - x) * a
		z.append(s)
for i in z:
	print(i)


T = int(input())
for _ in range(T):
	(X, Y) = map(int, input().split())
	(A, B) = map(int, input().split())
	cost = 0
	if X == Y:
		cost += min(B * abs(X), 2 * A * abs(X))
	elif Y >= 0 and X >= 0 or (X <= 0 and Y <= 0):
		cost += A * abs(X - Y) + min(B * min(abs(X), abs(Y)), 2 * A * min(abs(X), abs(Y)))
	elif X >= 0 and Y <= 0 or (X <= 0 and Y >= 0):
		cost += A * (abs(X) + abs(Y))
	print(cost)


import math
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < y:
		(x, y) = (y, x)
	if 2 * a <= b:
		print((abs(x) + abs(y)) * a)
	else:
		print(abs(y) * b + (abs(x) - abs(y)) * a)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = 0
	if x >= 1 and y >= 1 and (2 * a >= b):
		c += min(x, y) * b
		(x, y) = (x - min(x, y), y - min(x, y))
	if x >= 1:
		c += a * x
	if y >= 1:
		c += a * y
	print(c)


n = int(input())
for i in range(n):
	s = 0
	data = list(map(int, input().split()))
	(x, y) = (data[0], data[1])
	data = list(map(int, input().split()))
	(a, b) = (data[0], data[1])
	if a + a > b:
		s += b * min(x, y)
		t = min(x, y)
		(x, y) = (x - t, y - t)
		s += a * max(x, y)
	else:
		s = (x + y) * a
	print(s)


t = int(input())
for q in range(t):
	(x, y) = [int(z) for z in input().split()]
	(a, b) = [int(z) for z in input().split()]
	i = a * (x + y)
	ii = a * (max(x, y) - min(x, y)) + b * min(x, y)
	print(min(i, ii))


for _ in range(int(input())):
	(p, q) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, a + a)
	if p < q:
		(p, q) = (q, p)
	print(q * b + (p - q) * a)


def ri():
	return int(input())

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

def solve():
	(x, y) = rl()
	(a, b) = rl()
	if a * 2 <= b:
		answer = a * (x + y)
	else:
		answer = b * min(x, y) + a * (max(x, y) - min(x, y))
	print(answer)
	return
t = ri()
for i in range(t):
	solve()


for _ in [0] * int(input()):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(min(x, y) * b + abs(x - y) * a, a * (x + y)))


t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	total = 0
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	temp_min = min(abs(x), abs(y))
	temp_max = max(abs(x), abs(y))
	if 2 * a < b:
		total = abs(x) * a + abs(y) * a
	elif x * y > 0:
		total = temp_min * b + (temp_max - temp_min) * a
	else:
		total = abs(x) * a + abs(y) * a
	print(total)


t = int(input())
for l in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	must = abs(x - y) * a
	orb = min(min(x, y) * b, min(x, y) * a * 2)
	print(must + orb)


import sys
for _ in range(int(sys.stdin.readline())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if x * y <= 0:
		ans = abs(x) * a + abs(y) * a
	elif b < 2 * a:
		ans = min(x, y) * b + (max(x, y) - min(x, y)) * a
	else:
		ans = (x + y) * a
	print(ans)


t = int(input())
for tt in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < 0 and y < 0:
		x = -x
		y = -y
	b = min(b, 2 * a)
	(x, y) = (min(x, y), max(x, y))
	if x < 0:
		print(a * (abs(x) + abs(y)))
	else:
		print(b * x + a * (y - x))


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if b > 2 * a:
		b = 2 * a
	mi = min(x, y)
	print(b * mi + (max(x, y) - mi) * a)


from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def powmod(a, b):
	a %= mod
	if a == 0:
		return 0
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % mod
		a = a * a % mod
		b >>= 1
	return res

def main():
	for _ in range(ii()):
		(x, y) = mi()
		(a, b) = mi()
		if x > y:
			(x, y) = (y, x)
		c = y - x
		print(a * c + min(b * x, 2 * a * x))
main()


import sys
from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	t = inin()
	for _ in range(t):
		q1 = ain()
		q2 = ain()
		sum1 = 0
		temp = abs(q1[0] - q1[1])
		sum1 = sum1 + temp * q2[0]
		if q2[1] <= 2 * q2[0]:
			sum1 = sum1 + min(q1[0], q1[1]) * q2[1]
		else:
			sum1 = sum1 + 2 * min(q1[0], q1[1]) * q2[0]
		print(sum1)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	(x, y) = f()
	(a, b) = f()
	c = min(x, y)
	if x == 0 and y == 0:
		print(0)
	elif c == x:
		print(min(x * b + (y - x) * a, (x + y) * a))
	else:
		print(min(y * b + (x - y) * a, (x + y) * a))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	single = (abs(x) + abs(y)) * a
	mix = abs(x - y) * a + min(abs(x), abs(y)) * b
	print(min(single, mix))


for _ in range(int(input())):
	(x, y) = input().split()
	(a, b) = input().split()
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	m = (x + y) * a
	z = abs(x - y) * a + min(x, y) * b
	print((x + y) * a if (x + y) * a < abs(x - y) * a + min(x, y) * b else abs(x - y) * a + min(x, y) * b)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mi = min(x, y)
	ma = max(x, y)
	ans = 0
	if ma == 0:
		print(0)
		continue
	if a * 2 < b:
		ans += ma * a
		ans += mi * a
		print(ans)
	else:
		ans += (mi - 1) * b
		ans += (ma - mi) * a
		ans += b
		print(ans)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	if x < y:
		(x, y) = (y, x)
	a1 = a * (x + y)
	a2 = b * y + a * (x - y)
	ans = min(a1, a2)
	print(ans)


from __future__ import division, print_function
import os, sys
import collections
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(arr):
	return collections.Counter(arr)

def main():
	for _ in range(ii()):
		(x, y) = mi()
		(a, b) = mi()
		j = 0
		f = 1
		z = 0
		if x >= 0 and y >= 0:
			j += min(x, y) * b
			j += (max(x, y) - min(x, y)) * a
			z += (x + y) * a
		elif x < 0 and b < 0:
			j += abs(max(x, y) * b)
			j += abs((min(x, y) - max(x, y)) * a)
			z += abs(x + y) * a
		else:
			j += abs(x) * a + abs(y) * a
			f = 0
		if f:
			print(min(z, j))
		else:
			print(j)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(m, n) = map(int, input().split())
	if a == 0 or b == 0:
		print(max(a, b) * m)
	elif a > 0 and b > 0:
		if a > b:
			(a, b) = (b, a)
		p = a * n + (b - a) * m
		q = (a + b) * m
		print(min(p, q))
	elif a < 0 and b < 0:
		if a > b:
			(a, b) = (b, a)
		p = abs(b) * n + (b - a) * m
		q = abs(a + b) * m
		print(min(p, q))
	else:
		print(abs(a - b) * m)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(a * abs(n - m) + b * min(n, m), a * (n + m)))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < y:
		c = x * b + (y - x) * a
	else:
		c = y * b + (x - y) * a
	print(min(c, a * x + a * y))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	oi = (x + y) * a
	ou = abs(x - y) * a
	op = min(x, y) * b
	ans = min(oi, ou + op)
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mn = min(x, y)
	mx = max(x, y)
	ans = 0
	dif = mx - mn
	ans = dif * a
	if a == 0 and b == 0:
		ans = 0
	elif a * 2 < b:
		ans += 2 * a * mn
	else:
		ans += b * mn
	print(ans)


import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 9)
Input = lambda : sys.stdin.readline().rstrip()
IntRead = lambda : int(Input())
LineRead = lambda : list(map(int, Input().split()))
INF = 10 ** 18

def main():
	N = IntRead()
	for _ in range(N):
		(x, y) = LineRead()
		(a, b) = LineRead()
		if x > y:
			(x, y) = (y, x)
		print(min((x + y) * a, x * b + (y - x) * a, y * b + (y - x) * a))
main()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost1 = a * (abs(x) + abs(y))
	if x == 0 and y == 0:
		cost = 0
	elif x > 0 and y < 0 or (x < 0 and y > 0):
		cost = a * (abs(x) + abs(y))
	elif x == 0 and y != 0 or (x != 0 and y == 0):
		cost = a * (abs(x) + abs(y))
	elif x > 0 and y > 0:
		temp = min(x, y)
		cost = b * temp + abs(x - y) * a
	elif x < 0 and y < 0:
		temp = max(x, y)
		cost = b * abs(temp) + abs(x - y) * a
	print(min(cost, cost1))


t = int(input())
while t > 0:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = 0
	while x != 0 or y != 0:
		if x < 0 and y < 0:
			m = max(x, y)
			if m != 0:
				x += abs(m)
				y += abs(m)
				if cost + abs(m) * b < cost + abs(m) * 2 * a:
					cost += abs(m) * b
				else:
					cost += abs(m) * 2 * a
		elif x > 0 and y > 0:
			m = min(x, y)
			if m != 0:
				x -= abs(m)
				y -= abs(m)
				if cost + abs(m) * b < cost + abs(m) * 2 * a:
					cost += abs(m) * b
				else:
					cost += abs(m) * 2 * a
		elif x >= 0 and y <= 0 or (x <= 0 and y >= 0):
			cost += abs(x) * a + abs(y) * a
			x = 0
			y = 0
	print(cost)


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

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

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg
mm = 1000000007

def solve():
	t = nu()
	for tt in range(t):
		(x, y) = num()
		(a, b) = num()
		if x > y:
			(x, y) = (y, x)
		c1 = (y - x) * a + x * b
		c2 = (y - x) * a + 2 * x * a
		print(min(c1, c2))
solve()


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	t1 = 0
	if x == y:
		if 2 * a < b:
			t1 += x * 2 * a
		else:
			t1 += x * b
	elif x > y:
		t1 += (x - y) * a
		if 2 * a < b:
			t1 += y * 2 * a
		else:
			t1 += y * b
	elif y > x:
		t1 += (y - x) * a
		if 2 * a < b:
			t1 += x * 2 * a
		else:
			t1 += x * b
	print(t1)


def answer(x, y, a, b):
	if 2 * a < b:
		return (x + y) * a
	else:
		return min(x, y) * b + abs(x - y) * a

def main():
	t = int(input())
	x = [0] * t
	y = [0] * t
	a = [0] * t
	b = [0] * t
	for j in range(t):
		(x[j], y[j]) = [int(i) for i in input().split()]
		(a[j], b[j]) = [int(i) for i in input().split()]
	for j in range(t):
		print(answer(x[j], y[j], a[j], b[j]))
main()


t = int(input())
while t > 0:
	sum = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	f = 0
	g = 0
	if x == 0 and y == 0:
		print(0)
	else:
		sum = abs(x - y)
		f = min(x, y)
		g = sum * a
		print(min(f * a * 2, f * b) + g)
	t -= 1


t = int(input())
for ii in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print(a * (abs(x) + abs(y)))
	else:
		ans = 0
		if x > 0 and y > 0 or (x < 0 and y < 0):
			ans += b * min(x, y)
			ans += a * (max(x, y) - min(x, y))
			print(ans)
		else:
			print(a * (abs(x) + abs(y)))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	first_cost = a * (x + y)
	second_cost = abs(x - y) * a + min(x, y) * b
	print(min(first_cost, second_cost))


testcase = int(input())
for test in range(testcase):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	if x > y:
		if a * 2 < b:
			cost = x * a + y * a
		else:
			cost = y * b + (x - y) * a
	elif a * 2 < b:
		cost = x * a + y * a
	else:
		cost = x * b + (y - x) * a
	print(cost)


t = int(input())
for o in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m1 = min(x, y)
	m2 = max(x, y)
	ans = 0
	if a * 2 < b:
		ans += a * m1
		ans += a * m2
	else:
		ans += b * m1
		ans += a * (m2 - m1)
	print(ans)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	(a, b) = li()
	(x, y) = li()
	c = abs(b - a)
	k = min(a, b)
	m = min(2 * k * x, k * y)
	m += c * x
	print(m)
for _ in range(int(input())):
	case()


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff = abs(x - y)
	flag = 0
	cost = 0
	if b > 2 * a:
		cost = x * a + y * a
	else:
		cost = diff * a + min(x, y) * b
	print(cost)
	t -= 1


answer = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	result_one = x * a + y * a
	result_two = min(x, y) * b + (max(x, y) - min(x, y)) * a
	minimum = min(result_one, result_two)
	answer.append(minimum)
for i in answer:
	print(i)


n = int(input())
for u in range(n):
	s = 0
	(x, y) = [int(k) for k in input().split()]
	(a, b) = [int(k) for k in input().split()]
	if 2 * a <= b:
		s += a * abs(x) + a * abs(y)
	elif x * y < 0:
		s += a * abs(x) + a * abs(y)
	elif abs(x) > abs(y):
		s += b * abs(y) + a * (abs(x) - abs(y))
	elif abs(x) < abs(y):
		s += b * abs(x) + a * (abs(y) - abs(x))
	else:
		s += b * abs(x)
	print(s)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = abs(x - y)
	ans = m * a + (x + y - m) // 2 * b
	if ans > (x + y) * a:
		ans = (x + y) * a
	print(int(ans))


import sys
import math

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

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

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(x, y) = get_ints()
	(a, b) = get_ints()
	if 2 * a < b:
		ans = (x + y) * a
	else:
		c = min(x, y)
		d = abs(x - y)
		ans1 = a * d
		ans2 = b * c
		ans = ans1 + ans2
	print(ans)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

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

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

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		(x, y) = In()
		(a, b) = In()
		val1 = (x + y) * a
		val = abs(x - y) * a + b * min(x, y)
		print(min(val1, val))
main()


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x * y > 0:
		if b >= 2 * a:
			print(abs(x + y) * a)
		else:
			(h, k) = (min(abs(x), abs(y)), max(abs(x), abs(y)))
			print(b * h + a * (k - h))
	else:
		print(a * (abs(x) + abs(y)))


t = int(input())
for ck in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == 0 and b == 0:
		print(0)
	elif 2 * a >= b:
		print(a * abs(x - y) + b * min(x, y))
	else:
		print(a * (abs(x) + abs(y)))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if a * 2 <= b or (x < 0 and y > 0 or (x > 0 and y < 0)):
		print(abs(0 - x) * a + abs(0 - y) * a)
		continue
	elif x == y == 0:
		print(0)
		continue
	c = min(abs(x), abs(y))
	ans += c * b
	ans += (max(abs(x), abs(y)) - c) * a
	print(ans)


def dhana(n, m, a, b):
	sum = 0
	if b >= a * 2:
		sum += (n + m) * a
	else:
		sum += abs(n - m) * a
		if n > m:
			sum += m * b
		else:
			sum += n * b
	return sum
n = int(input())
for i in range(n):
	(n, m) = map(int, input().split())
	(a, b) = map(int, input().split())
	x = dhana(n, m, a, b)
	print(x)


for _ in range(int(input())):
	a = input().split(' ')
	x = int(a[0])
	y = int(a[1])
	l = input().split(' ')
	a = int(l[0])
	b = int(l[1])
	if b >= 2 * a:
		print(a * abs(x + y))
	elif x > 0 and y > 0:
		print(a * abs(x - y) + b * min(x, y))
	elif x < 0 and y < 0:
		print(a * abs(x - y) + b * abs(max(x, y)))
	else:
		print(a * (abs(x) + abs(y)))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	ans1 = x * b + (y - x) * a
	ans2 = (y - x) * a + y * b
	ans3 = (x + y) * a
	print(min(ans1, ans2, ans3))


for i in range(0, int(input())):
	(x, y) = [int(f) for f in input().split()]
	(a, b) = [int(f) for f in input().split()]
	s = 0
	if b >= a * 2:
		s += a * x + a * y
	elif x < y:
		y -= x
		s += b * x + a * y
	else:
		x -= y
		s += b * y + a * x
	print(s)


numTests = int(input())

def test():
	(x, y) = sorted(list(map(int, input().split(' '))))
	(a, b) = list(map(int, input().split(' ')))
	first = 0
	second = 0
	first += y - x
	y = x
	if a * 2 < b:
		first += x * 2
	else:
		second += x
	result = a * first + b * second
	print(result)
for _ in range(0, numTests):
	test()


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(x, y) = getVars()
	(a, b) = getVars()
	res = 0
	if 2 * a < b:
		res = a * (x + y)
	else:
		res = min(x, y) * b + (max(x, y) - min(x, y)) * a
	print(res)


test_cases = int(input())
k = test_cases
while k > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b <= 2 * a:
		if x < y:
			z = (y - x) * a + x * b
		else:
			z = (x - y) * a + y * b
	else:
		z = (x + y) * a
	print(z)
	k = k - 1


def solve(x, y, a, b):
	diff = abs(x - y)
	result = diff * a
	remaining = min(x, y)
	result += min(remaining * a * 2, remaining * b)
	return result
for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(x, y, a, b))


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	count = 0
	s1 = min(abs(x), abs(y))
	s2 = max(abs(x), abs(y))
	p1 = (x + y) * a
	p2 = s1 * b + (s2 - s1) * a
	print(min(p1, p2))
	t = t - 1


t = int(input())
c = 1
while c <= t:
	d = 0
	m = 0
	e = 0
	n = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	e += a * (x + y)
	if x > y:
		n = n + (x - y)
		x = x - (x - y)
	elif y > x:
		n = n + (y - x)
		y = y - (y - x)
	elif x == 0 and y == 0:
		n = 0
	c += 1
	d += a * n + b * x
	print(min(e, d))


for i in [0] * int(input()):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > 0 and y > 0 or (x < 0 and y < 0):
		z = min(x, y)
		if 2 * a > b:
			total = z * b
			total += (max(x, y) - min(x, y)) * a
		else:
			total = a * (x + y)
	else:
		total = abs(x) * a + abs(y) * a
	print(total)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().strip().split(' '))
	(a, b) = map(int, input().strip().split(' '))
	s = 0
	if x > y:
		p = x - y
		s += p * a
		if b >= 2 * a:
			s += 2 * y * a
		else:
			s += y * b
	elif y > x:
		p = y - x
		s += p * a
		if b >= 2 * a:
			s += 2 * x * a
		else:
			s += x * b
	elif x == y:
		if b >= 2 * a:
			s += 2 * x * a
		else:
			s += x * b
	print(s)


import sys

def find_cost(case):
	(x, y, a, b) = (case['x'], case['y'], case['a'], case['b'])
	res = 0
	if x == 0 and y == 0:
		return res
	if x == 0:
		res = count_single(y, a)
	elif y == 0:
		res = count_single(x, a)
	elif 2 * a <= b or x * y < 0:
		res = count_single(x, a) + count_single(y, a)
	elif x == y:
		res = count_double(x, b)
	else:
		(max_val, min_val) = (max(x, y), min(x, y))
		diff = max_val - min_val
		res = diff * a + (max_val - diff) * b
	return res

def count_single(x, a):
	res = abs(x) * a
	return res

def count_double(x, b):
	res = abs(x) * b
	return res
inp = sys.stdin.read()
inp = inp.split('\n')[1:]
cases = []
for n in range(len(inp))[:-1:2]:
	(x, y) = inp[n].split()
	(a, b) = inp[n + 1].split()
	cases.append({'x': int(x), 'y': int(y), 'a': int(a), 'b': int(b)})
for case in cases:
	res = find_cost(case)
	print(res)


t = int(input())

def check(x, y, a, b):
	mn = min([x, y])
	mx = max([x, y])
	if max and min:
		if b >= a * 2:
			return a * (x + y)
		else:
			return mn * b + (mx - mn) * a
	else:
		return 0
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(check(x, y, a, b))


t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
		continue
	diff = abs(x - y)
	ans = diff * a
	if x > y:
		ans += min(2 * a * y, b * y)
	else:
		ans += min(2 * a * x, b * x)
	print(ans)


T = int(input())
for _ in range(T):
	(X, Y) = map(int, input().split())
	(A, B) = map(int, input().split())
	a1 = (X + Y) * A
	a2 = min(X, Y) * B + abs(X - Y) * A
	print(min(a1, a2))


def main():
	t = int(input())
	tot = []
	for _ in range(t):
		res = 0
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		if not x and (not y):
			tot.append(0)
			continue
		if x == y:
			tot.append(min(abs(x) * b, abs(x) * a * 2))
			continue
		if x <= 0 and y >= 0 or (x >= 0 and y <= 0):
			tot.append((abs(x) + abs(y)) * a)
			continue
		x = abs(x)
		y = abs(y)
		if max(x, y) == x:
			diff = x - y
			x -= diff
		else:
			diff = y - x
			y -= diff
		res += diff * a
		res += min(x * b, x * a * 2)
		tot.append(res)
	[print(e) for e in tot]
main()


t = int(input())
for i in range(t):
	num1 = list(map(int, input().split()))
	num2 = list(map(int, input().split()))
	x = num1[0]
	y = num1[1]
	a = num2[0]
	b = num2[1]
	z = (x + y) * a
	c = min(x, y)
	x -= c
	y -= c
	m = c * b + x * a + y * a
	print(min(m, z))


for i in range(int(input())):
	a = list(map(int, input().strip().split()))[:2]
	b = list(map(int, input().strip().split()))[:2]
	count = 0
	count1 = 0
	count = (a[0] + a[1]) * b[0]
	count1 = abs(a[0] - a[1]) * b[0] + min(a) * b[1]
	if count1 > count:
		print(count)
	else:
		print(count1)


t = int(input())
for _ in range(t):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if a * 2 < b:
		print((x + y) * a)
	else:
		s = min(x, y)
		print(s * b + (x + y - s - s) * a)


t = int(input())
for T in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if y < x:
		(x, y) = (y, x)
	c1 = x * b
	c1 += (y - x) * a
	c2 = a * (y + x)
	print(min(c1, c2))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	s = abs(x - y)
	if x == 0 and y == 0:
		print(0)
	else:
		print(min(m * b + s * a, (x + y) * a))


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	price = min(2 * a, b)
	tot = 0
	tot += price * min(x, y)
	print(tot + (max(x, y) - min(x, y)) * a)


r = lambda : map(int, input().split())
(t,) = r()
exec(t * 'x , y = sorted(r()) ; a , b  = r() ; print(min(2 * a , b) * x + a * (y - x));')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = x * a + y * a
	ans = min(ans, x * b + abs(x - y) * a)
	ans = min(ans, y * b + abs(x - y) * a)
	print(ans)


t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	a1 = min(x, y)
	b1 = max(x, y)
	s = 0
	netm = b1 - a1
	s += a * netm
	if a > b:
		s += a1 * b
	elif 2 * a < b:
		s += a1 * 2 * a
	else:
		s += a1 * b
	print(s)


n = int(input())
(xy, ab) = ([], [])
for i in range(n):
	xy.append(list(map(int, input().split())))
	ab.append(list(map(int, input().split())))
for j in range(n):
	x = xy[j][0]
	y = xy[j][1]
	a = ab[j][0]
	b = ab[j][1]
	if x < y:
		x = x + y
		y = x - y
		x = x - y
	if x >= 0 and y >= 0:
		if b < 2 * a:
			cost = (x - y) * a + y * b
			print(cost)
		else:
			cost = (x - y) * a + y * 2 * a
			print(cost)
	elif x <= 0 and y <= 0:
		x = x * -1
		y = y * -1
		x = x + y
		y = x - y
		x = x - y
		if b < 2 * a:
			cost = (x - y) * a + y * b
			print(cost)
		else:
			cost = (x - y) * a + y * 2 * a
			print(cost)
	elif x >= 0 and y <= 0:
		cost = (x - y) * a
		print(cost)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0:
		ans = a * y
	elif y == 0:
		ans = a * x
	else:
		ans = min((x + y) * a, min(x, y) * b + (max(x, y) - min(x, y)) * a)
	print(ans)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	if 2 * c <= d:
		print((a + b) * c)
	else:
		z = min(a, b)
		print(d * z + (a + b - 2 * z) * c)


t = int(input())
for i in range(0, t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if x == 0 and y == 0:
		print(0)
	else:
		print(min((x + y) * a, min(x, y) * b + (max(x, y) - min(x, y)) * a, (max(x, y) - min(x, y)) * a + max(x, y) * b))


from math import *
from collections import *
from itertools import *
from bisect import *
from heapq import *
from operator import *
from sys import *
setrecursionlimit(1000000)
d = defaultdict(lambda : 0, {})

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

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

def o():
	return int(input())

def l(x):
	return len(x)

def r(x):
	if type(x) == int:
		return range(x)
	else:
		return range(len(x))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MOD = 1000000007
MAX = float('inf')
MIN = -float('inf')
p = input
for _ in range(o()):
	(x, y) = io()
	if x > y:
		(x, y) = (y, x)
	(a, b) = io()
	s = 0
	s = +x * min(2 * a, b)
	s += (y - x) * a
	print(s)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	pr1 = (x + y) * a
	pr2 = (y - x) * a + y * b
	pr3 = x * b + (y - x) * a
	print(min(pr1, pr2, pr3))


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = 0
	if (x > 0 and y > 0 or (x < 0 and y < 0)) and 2 * a >= b:
		z = abs(x - y)
		c += min(abs(x), abs(y)) * b
		c += z * a
	else:
		c += (abs(x) + abs(y)) * a
	print(c)


t = int(input())
for _ in range(0, t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if x == 0 and y == 0:
		print(0)
	elif b < a * 2:
		diff = abs(x - y)
		ans = ans + diff * a
		if x < y:
			y = x
		else:
			x = y
		ans = ans + x * b
		print(ans)
	else:
		ans = a * (x + y)
		print(ans)


def solve():
	case = int(input())
	for _t in range(case):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		ans = abs(x - y)
		print(min(min(x, y) * b + ans * a, min(x, y) * 2 * a + ans * a))
solve()


for _ in ' ' * int(input()):
	x = sorted(map(int, input().split()), key=lambda x: abs(x))
	y = [abs(x) for x in x]
	(a, b) = map(int, input().split())
	s = 0
	if b < a * 2:
		if all((x > 0 for x in x)) or all((x < 0 for x in x)):
			s += b * abs(min(y))
			s += a * abs(y[1 - y.index(min(y))] - y[y.index(min(y))])
			print(s)
			continue
	s = 0
	for x in y:
		s += a * abs(x)
	print(s)


ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
for _ in range(ii()):
	(x, y) = f()
	(a, b) = f()
	c = min(x, y)
	if x == 0 and y == 0:
		print(0)
	elif c == x:
		print(min(x * b + (y - x) * a, (x + y) * a))
	else:
		print(min(y * b + (x - y) * a, (x + y) * a))


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = min(x, y)
	d = max(x, y) - c
	s1 = d * a + c * b
	s2 = a * (x + y)
	e = max(x, y)
	s3 = b * c + a * d
	print(min(s1, s2, s3))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if x >= 0 and y >= 0:
		if 2 * a > b:
			ans += b * min(x, y)
		else:
			ans += 2 * a * min(x, y)
		temp = max(x, y)
		temp -= min(x, y)
		ans += temp * a
		print(ans)
		continue
	if x <= 0 and y <= 0:
		x = -x
		y = -y
		if 2 * a > b:
			ans += b * min(x, y)
		else:
			ans += 2 * a * min(x, y)
		temp = max(x, y)
		temp -= min(x, y)
		ans += temp * a
		print(ans)
		continue
	if x >= 0 and y <= 0:
		ans += a * -y
		ans += a * x
		print(ans)
		continue
	print(ans)


def read():
	return list(map(int, input().strip().split()))
for t in range(int(input())):
	(x, y) = read()
	(a, b) = read()
	print(min(x, y) * min(b, 2 * a) + abs(y - x) * a)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	temp = min(x, y)
	t = temp
	temp = max(0, temp - 1) * b
	extra = max(x, y) - t
	extra = max(0, extra) * a
	ans2 = x * a + y * a
	ans = temp + extra + b
	print(min(ans, ans2))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	x = abs(a - b)
	y = min(a, b)
	z = a + b
	print(min(c * x + d * y, z * c))


n = int(input())
for i in range(0, n):
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	mi = min(l)
	ma = max(l)
	if 2 * p[0] < p[1]:
		print(p[0] * (mi + ma))
	else:
		print(mi * p[1] + (ma - mi) * p[0])


def main():
	t = int(input())
	for c in range(t):
		(x, y) = [int(s) for s in input().split(' ')]
		(a, b) = [int(s) for s in input().split(' ')]
		print(solve(x, y, a, b))

def sign(x):
	return x >= 0

def solve(x, y, a, b):
	cost = 0
	z = min(abs(x), abs(y))
	if sign(x) == sign(y):
		if 2 * a < b:
			return abs(x - y) * a + 2 * z * a
		else:
			return abs(x - y) * a + z * b
	else:
		return a * (abs(x) + abs(y))
	return cost
main()


try:
	import sys
	for _ in range(int(sys.stdin.readline())):
		(x, y) = map(int, sys.stdin.readline().split())
		(a, b) = map(int, sys.stdin.readline().split())
		r = abs(x - y)
		ans = min(r * a + b * min(x, y), r * a + 2 * min(x, y) * a)
		print(ans)
except:
	pass


import sys
readline = sys.stdin.readline
flush = sys.stdout.flush
T = int(readline())
for t in range(1, T + 1):
	line = readline().split()
	(x, y) = (int(line[0]), int(line[1]))
	line = readline().split()
	(a, b) = (int(line[0]), int(line[1]))
	if a * 2 > b:
		ans = abs(x - y) * a + min(abs(x), abs(y)) * b
	else:
		ans = (abs(x) + abs(y)) * a
	print(ans)


for i in range(0, int(input())):
	(a, b) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	ek = a * x + b * x
	if a > b:
		c = a - b
		co = c * x
		co = co + b * y
	else:
		c = b - a
		co = c * x
		co = co + a * y
	print(min(co, ek))


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	(x, y) = mapi()
	(a, b) = mapi()
	res = 0
	if x > y:
		(x, y) = (y, x)
	res = (y - x) * a + min(2 * x * a, x * b)
	print(res)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		p = x * b
		q = 2 * x * a
		print(min(p, q))
	else:
		c = abs(x - y)
		if x != 0 and y != 0:
			c = c * a
			p = min(x, y)
			p *= b
			p += c
			q = min(x, y)
			q *= 2
			q *= a
			q += c
			print(min(p, q))
		else:
			print(c * a)


for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	(c, d, e) = (0, 0, 0)
	if x > 0 and y > 0:
		d = x * a + y * a
		if x > y:
			c += y * b
			c += (x - y) * a
			e = min(c, d)
			print(e)
		else:
			c += x * b
			c += (y - x) * a
			e = min(c, d)
			print(e)
	elif x == 0 and y != 0:
		print(y * a)
	elif y == 0 and x != 0:
		print(x * a)
	else:
		print(0)


mod = 998244353
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x1 = abs(x - y) * a + b * min(abs(x), abs(y))
	x2 = (x + y) * a
	print(min(x1, x2))


t = int(input())
while t:
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	s = 0
	p = abs(x - y)
	s += a * p
	s += min(b, 2 * a) * min(x, y)
	print(s)
	t -= 1


for _ in range(int(input())):
	(i, j) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min((i + j) * a, (max(i, j) - min(i, j)) * a + min(i, j) * b))


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline

def I():
	return list(map(int, inp().split()))
for _ in range(I()[0]):
	(x, y) = I()
	(a, b) = I()
	print(min(min(x, y) * b + (max(x, y) - min(x, y)) * a, (x + y) * a))


def func(a, b, x, y):
	(m1, m2) = (min(x, y), max(x, y))
	return min(m1 * b + (m2 - m1) * a, a * (m1 + m2))
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(func(a, b, x, y))


t = int(input())
for w in range(t):
	(x, y) = (int(i) for i in input().split())
	(a, b) = (int(i) for i in input().split())
	print(abs(x - y) * a + min(x, y) * min(2 * a, b))


T = int(input())
for _ in range(0, T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	X = max(x, y)
	Y = min(x, y)
	if 2 * a < b:
		b = 2 * a
	ans = Y * b + (X - Y) * a
	print(ans)


import math

def getLeastCost(x, y, a, b):
	useOne = True if a * 2 < b else False
	singleMoves = int(math.fabs(x - y))
	doubleMoves = x if x < y else y
	totalCost = 0
	if useOne == True:
		totalCost = a * (singleMoves + 2 * doubleMoves)
	else:
		totalCost = a * singleMoves + b * doubleMoves
	return totalCost
n = int(input())
leastCosts = []
for i in range(0, n):
	xy = list(input().split(' '))
	ab = list(input().split(' '))
	x = int(xy[0])
	y = int(xy[1])
	a = int(ab[0])
	b = int(ab[1])
	leastCosts.append(getLeastCost(x, y, a, b))
for cost in leastCosts:
	print(int(cost))


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ans1 = (x + y) * a
	if x < y:
		temp = x
		t = y - x
	else:
		temp = y
		t = x - y
	ans2 = temp * b + t * a
	if ans1 < ans2:
		print(ans1)
	else:
		print(ans2)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(x, y) = read_ints()
	(a, b) = read_ints()
	smart = 0
	x_1 = x
	y_1 = y
	if x > 0 and y > 0:
		diff = min(x_1, y_1)
		smart += diff * b
		x_1 -= diff
		y_1 -= diff
	smart += x_1 * a
	smart += y_1 * a
	dumb = x * a + y * a
	print(min(smart, dumb))


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	val = (x + y) // 2
	res = a * abs(val - x) + a * abs(val - y)
	res += b * val
	vall = min(x, y)
	print(min(res, x * a + y * a, vall * b + (x + y - 2 * vall) * a))


import sys
I = sys.stdin.readline
ans = ''
for _ in range(int(I())):
	(x, y) = map(int, I().split())
	(a, b) = map(int, I().split())
	if x == y:
		only_a = (x + y) * a
		only_b = x * b
		ans += str(min(only_a, only_b)) + '\n'
	else:
		total = min(x, y) * b
		total += (max(x, y) - min(x, y)) * a
		only_a = (x + y) * a
		ans += str(min(only_a, total)) + '\n'
print(ans)


t = int(input())
for test in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	elif 2 * a <= b:
		print((x + y) * a)
	else:
		print(b * min(x, y) + (max(x, y) - min(x, y)) * a)


def mincost(x, y, a, b):
	if 2 * a <= b:
		return a * (x + y)
	else:
		return b * min(x, y) + a * (max(x, y) - min(x, y))
n = int(input())
for _ in range(n):
	arr1 = list(map(int, input().rstrip().split()))
	arr2 = list(map(int, input().rstrip().split()))
	x = arr1[0]
	y = arr1[1]
	a = arr2[0]
	b = arr2[1]
	print(mincost(x, y, a, b))


import sys
t = int(input())
for _ in range(t):
	arr = input().split(' ')
	x = int(arr[0])
	y = int(arr[1])
	if x > y:
		(x, y) = (y, x)
	arr = input().split(' ')
	a = int(arr[0])
	b = int(arr[1])
	print(min(a * (y - x) + b * x, a * (y + x)))


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	ntest = int(stdin.readline())
	for testcase in range(ntest):
		(x, y) = [int(z) for z in stdin.readline().split()]
		(a, b) = [int(z) for z in stdin.readline().split()]
		res = 0
		dist = abs(x - y)
		res = min(x, y) * min(a * 2, b) + dist * a
		stdout.write('%d\n' % res)
	return 0
main()


from collections import Counter
import itertools
from functools import lru_cache
import sys
import math

def helper():
	pass

def solve():
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	if x == y == 0:
		print(0)
		return
	op1 = abs(x) * a + abs(y) * a
	op2 = abs(x - y) * a + abs(y) * b
	op3 = abs(y - x) * a + abs(x) * b
	print(min(op1, op2, op3))
	return
t = int(input())
for _ in range(t):
	solve()


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = []
	if x > y:
		ans.append((x - y) * a + x * b)
		ans.append((x - y) * a + y * b)
		ans.append(x * a + y * a)
		print(min(ans))
	else:
		(x, y) = (y, x)
		ans.append((x - y) * a + x * b)
		ans.append((x - y) * a + y * b)
		ans.append(x * a + y * a)
		print(min(ans))


def smaller(a, b):
	if a < b:
		return a
	else:
		return b

def difference(a, b):
	return abs(a - b)
t = int(input())
list = []
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if 2 * a > b:
		s = smaller(x, y)
		d = difference(x, y)
		m = s * b + d * a
	else:
		s = x + y
		m = s * a
	list.append(m)
for x in list:
	print(x)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < y:
		res = b * x + a * (y - x)
	elif y < x:
		res = b * y + a * (x - y)
	else:
		res = b * x
	res1 = (x + y) * a
	if res <= res1:
		print(res)
	else:
		print(res1)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	elif x == 0 or y == 0:
		m = max(x, y)
		print(a * m)
	else:
		if x > y:
			(x, y) = (y, x)
		c = (y - x) * a
		c += x * b
		k = (x + y) * a
		print(min(c, k))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	l = abs(x - y)
	c = 0
	c = c + l * a
	d = min(x, y)
	c += d * min(2 * a, b)
	print(c)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	r1 = b * min(x, y) + a * abs(x - y)
	r2 = a * (x + y)
	print(min(r1, r2))


p = int(input())
for z in range(p):
	(x, y) = [int(i) for i in input().split()]
	if x > y:
		(x, y) = (y, x)
	(a, b) = [int(i) for i in input().split()]
	res = 0
	if x < 0 and y > 0:
		res = abs(x) * a + y * b
	else:
		x = abs(x)
		y = abs(y)
		if 2 * a < b:
			res += 2 * a * x
		else:
			res += b * x
		y -= x
		res += a * y
	print(res)


from sys import stdin

def r():
	return stdin.readline()

def r_t():
	return map(int, r().strip().split())

def r_a():
	return list(r_t())

def main():
	cases = int(r())
	for case in range(cases):
		(x, y) = r_t()
		(a, b) = r_t()
		ans1 = abs(x - y) * a
		ans1 += min(x, y) * b
		ans2 = x * a + y * a
		print(min(ans1, ans2))
main()


for q in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 < b:
		Y = min(x, y)
		res = a * Y * 2
		Y = max(x, y) - Y
		res += Y * a
		print(res)
	else:
		Y = min(x, y)
		res = b * Y
		Y = max(x, y) - Y
		res += Y * a
		print(res)


import math
for ttt in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b <= 2 * a:
		m = min(x, y)
		print(m * b + (x - m + (y - m)) * a)
	else:
		print((x + y) * a)


def main():
	no_of_test_cases = int(input())
	test_cases_list = []
	for i in range(no_of_test_cases):
		int_str = input()
		dollars_str = input()
		test_cases_list.append([int_str.split(), dollars_str.split()])
	for case in test_cases_list:
		x = int(case[0][0])
		y = int(case[0][1])
		a = int(case[1][0])
		b = int(case[1][1])
		if a * 2 < b:
			print(a * (x + y))
		elif x > y:
			print(y * b + (x - y) * a)
		else:
			print(x * b + (y - x) * a)
main()


case = int(input())
for i in range(0, case):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(x, y) * min(b, 2 * a) + a * abs(x - y))


t = int(input())
for i in range(t):
	(x, y) = [int(xx) for xx in input().split()]
	(a, b) = [int(xx) for xx in input().split()]
	ans1 = b * min(x, y) + a * (max(x, y) - min(x, y))
	ans2 = a * (x + y)
	print(min(ans1, ans2))


import math
tests = int(input())
for i in range(0, tests):
	first = input().split()
	second = input().split()
	x = int(first[0])
	y = int(first[1])
	a = int(second[0])
	b = int(second[1])
	if (abs(x) + abs(y)) * a < abs(x - y) * a + min(abs(x), abs(y)) * b:
		print((abs(x) + abs(y)) * a)
	else:
		print(abs(x - y) * a + min(abs(x), abs(y)) * b)


t = int(input())
for _ in range(t):
	num_arr = []
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	max_num = max(x, y)
	a_multiplier = abs(x - y)
	b_multiplier = max_num - a_multiplier
	mix_a_b = a_multiplier * a + b_multiplier * b
	num_arr.append(mix_a_b)
	a_answer = (x + y) * a
	num_arr.append(a_answer)
	print(min(num_arr))


t = int(input())
for _ in range(t):
	ansA = 0
	ansB = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a <= b:
		if 2 * a <= b:
			print(a * (x + y))
			continue
		else:
			mn = min(x, y)
			mx = max(x, y)
			ansB += mn
			mx -= mn
			ansA += mx
			print(a * ansA + b * ansB)
			continue
	else:
		mn = min(x, y)
		mx = max(x, y)
		ansB += mn
		mx -= mn
		ansA += mx
		print(a * ansA + b * ansB)
		continue


import math
import atexit
import io
import sys
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())

def array_to_string(a):
	s = ''
	for i in a:
		s += str(i) + ' '
	return s[0:len(s) - 1]
t = int(input())
while t > 0:
	t = t - 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
		continue
	x1 = x
	y1 = y
	if b <= 2 * a:
		if x1 > y1:
			print(b * y1 + (x1 - y1) * a)
		elif x1 < y1:
			print(b * x1 + (y1 - x1) * a)
		else:
			print(b * x1)
	else:
		print((x1 + y1) * a)


t = int(input())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	c = min(b, 2 * a)
	ans = 0
	ans += abs(x - y) * a + min(abs(x), abs(y)) * c
	print(ans)


def solve(x, y, a, b):
	return min(abs(x) * a + abs(y) * a, abs(x - y) * a + min(abs(x), abs(y)) * b)
n = int(input())
for i in range(n):
	(x, y) = [int(p) for p in input().split()]
	(a, b) = [int(p) for p in input().split()]
	print(solve(x, y, a, b))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = map(int, input().split())
	m1 = min(n, m)
	m2 = max(n, m)
	a2 = b * m1 + a * (m2 - m1)
	a3 = a * (m1 + m2)
	print(min(a2, a3))


testcases = int(input())
while testcases > 0:
	testcases = testcases - 1
	(x, y) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	(num1, num2) = (min(x, y), max(x, y))
	(a, b) = map(int, input().split())
	mincost = num1
	maxcost = num2 - num1
	cost = 0
	if a + a < b:
		cost += (a + a) * mincost + maxcost * a
	else:
		cost += b * mincost + maxcost * a
	print(cost)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 >= b:
		if y >= x:
			rem = y - x
			print(x * b + rem * a)
		else:
			rem = x - y
			print(y * b + rem * a)
	else:
		print((x + y) * a)


for i in range(int(input())):
	(x, y) = list(map(int, input().strip().split()))
	(a, b) = list(map(int, input().strip().split()))
	mx = max(x, y)
	mn = min(x, y)
	cost = (mx - mn) * a
	mx = mn
	cost += min(mx * b, mx * 2 * a)
	print(cost)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = 0
	if x > y:
		(x, y) = (y, x)
	if 2 * a > b:
		c += (x - 1) * b
		c += (y - (x - 1) - 1) * a + b
	else:
		c = a * (abs(x) + abs(y))
	print(c)


for t in range(int(input())):
	args = [int(x) for x in input().split(' ')]
	x = args[0]
	y = args[1]
	args = [int(x) for x in input().split(' ')]
	a = args[0]
	b = args[1]
	if b >= 2 * a or x == 0 or y == 0:
		print((abs(x) + abs(y)) * a)
	elif x / y < 0:
		print((abs(x) + abs(y)) * a)
	else:
		print(min(abs(x), abs(y)) * b + (max(abs(x), abs(y)) - min(abs(x), abs(y))) * a)


import sys

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def solver(firstA, firstB, oneChangeCost, twoChangeCost):
	if firstA < firstB:
		tmp = firstB
		firstB = firstA
		firstA = tmp
	allOne = (firstA + firstB) * oneChangeCost
	diffAandB = firstA - firstB
	partCost = firstB * twoChangeCost + diffAandB * oneChangeCost
	if allOne < partCost:
		return allOne
	else:
		return partCost
T = II()
for _ in range(T):
	(A, B) = MI()
	(X, Y) = MI()
	print('{}'.format(solver(A, B, X, Y)))


n = int(input()) * 2
for i in range(int(n)):
	if i % 2 == 0:
		(a, b) = input().split()
		(a, b) = (int(a), int(b))
		m = min(a, b)
	if i % 2 == 1:
		(x, y) = input().split()
		(x, y) = (int(x), int(y))
		price = 0
		if y < 2 * x:
			price = m * y + (max(a, b) - m) * x
		else:
			price = (a + b) * x
		print(price)


def solve(X, Y, A, B):
	min_el = min(X, Y)
	diff = abs(Y - X)
	cost = diff * A + min_el * min(2 * A, B)
	print(cost)
t = int(input())
while t != 0:
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	solve(x, y, a, b)
	t -= 1


for _ in range(int(input())):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	_max = max(x, y)
	_min = min(x, y)
	c = _max - _min
	cost2 = (_max + _min) * a
	cost1 = c * a + _min * b
	print(min(cost1, cost2))


T = int(input())
for _ in range(T):
	in1 = list(map(int, input().split()))
	in2 = list(map(int, input().split()))
	if 2 * in2[0] >= in2[1]:
		(in1[0], in1[1]) = (min(in1[0], in1[1]), max(in1[0], in1[1]))
		ans = in1[0] * in2[1] + (in1[1] - in1[0]) * in2[0]
		print(ans)
	else:
		ans = (in1[0] + in1[1]) * in2[0]
		print(ans)


test = int(input())
for yy in range(test):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	ctb = min(x, y)
	cta = max(x, y) - min(x, y)
	print(min(cta * a + ctb * b, (x + y) * a))


from math import inf
t = int(input())
for q in range(t):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	print(min(a * (x + y), a * abs(x - y) + b * min(x, y)))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x >= y:
		(x, y) = (y, x)
	eqc = abs(x - y) * a
	minc = min(x * b, 2 * a * x)
	print(eqc + minc)


n = int(input())
x = []
y = []
a = []
b = []
ret = []
for i in range(n):
	temp = input()
	temp_spl = temp.split()
	x.append(int(temp_spl[0]))
	y.append(int(temp_spl[1]))
	temp = input()
	temp_spl = temp.split()
	a.append(int(temp_spl[0]))
	b.append(int(temp_spl[1]))
for i in range(n):
	r = 0
	c = x[i]
	d = y[i]
	c1 = a[i]
	c2 = b[i]
	if c == 0 and d == 0:
		ret.append(r)
		continue
	if c > d:
		(c, d) = (d, c)
	if 2 * c1 > c2:
		r += c2 * c
	else:
		r += c1 * c * 2
	d -= c
	c = 0
	r += d * c1
	ret.append(r)
for line in ret:
	print(line)


t = input()
for i in range(int(t)):
	(x, y) = tuple(map(int, input().split()))
	(a, b) = tuple(map(int, input().split()))
	(s, s1) = (0, 0)
	if x > y:
		s += (x - y) * a
		s += y * b
		s1 += x * b
		s1 += (x - y) * a
	else:
		s += (y - x) * a
		s += x * b
		s1 += y * b
		s1 += (y - x) * a
	if (x + y) * a < s:
		s = (x + y) * a
	if s1 < s:
		s = s1
	print(s)


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	aux = 0
	maxi = max(x, y)
	mini = min(x, y)
	if a < b / 2:
		aux += a * x + a * y
	else:
		aux += b * mini
		aux += a * (maxi - mini)
	print(aux)


t = int(input())
while t:
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	print(min(a * x + a * y, b * min(x, y) + a * abs(y - x)))
	t -= 1


t = int(input())
for x in range(1, t + 1):
	(x, y) = [int(x) for x in input().split(' ')]
	(a, b) = [int(x) for x in input().split(' ')]
	spent = 0
	while x != 0 and y != 0:
		if x > 0 and y > 0 and (b < 2 * a):
			m = min(x, y)
			spent += m * b
			x -= m
			y -= m
		elif x > y:
			spent += y * a
			y = 0
		else:
			spent += x * a
			x = 0
	if x == 0:
		spent += y * a
	elif y == 0:
		spent += x * a
	print(spent)


T = int(input())
for _ in range(T):
	(x, y) = map(int, input().split())
	if x < y:
		(x, y) = (y, x)
	(a, b) = map(int, input().split())
	c = a * (x - y)
	c = c + min(2 * a * y, b * y)
	print(c)


from sys import stdin, stdout
t = int(stdin.readline().strip())
for caso in range(t):
	(x, y) = map(int, stdin.readline().strip().split())
	(a, b) = map(int, stdin.readline().strip().split())
	ans = 0
	if x > y:
		ans += abs(x - y) * a
		x = y
	else:
		ans += abs(x - y) * a
		y = x
	ans = min(ans + x * 2 * a, ans + x * b)
	print(ans)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(x, y) = read_ints()
	if x > y:
		tmp = x
		x = y
		y = tmp
	(a, b) = read_ints()
	p = (x + y) * a
	q = (y - x) * a + x * b
	print(min(p, q))


import math

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

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

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
t = inp()
while t:
	(x, y) = invr()
	(a, b) = invr()
	x1 = min(x, y)
	y1 = max(x, y)
	x = x1
	y = y1
	cost1 = y * b + (y - x) * a
	cost2 = x * a + y * a
	cost3 = x * b + (y - x) * a
	print(min(cost1, cost2, cost3))
	t -= 1


def calc_min(x, y, a, b):
	if b < 2 * a:
		minimum = min(x, y)
		rest = max(x, y) - minimum
		amount = minimum * b + rest * a
	else:
		amount = (x + y) * a
	return amount
t = int(input())
for i in range(t):
	(x, y) = (int(s) for s in input().split())
	(a, b) = (int(s) for s in input().split())
	print(calc_min(x, y, a, b))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a < b:
		print((x + y) * a)
	else:
		ans = 0
		mi = min(x, y)
		ans += mi * b
		x -= mi
		y -= mi
		ans += (x + y) * a
		print(ans)


from math import factorial as fac
from collections import defaultdict
from copy import deepcopy
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
sys.setrecursionlimit(10 ** 6)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m
from collections import deque, defaultdict
import heapq

def bfs(V, E):
	s = set()
	print('\n'.join(map(str, E.items())))
	cnt = 0
	for v in V:
		if v in s:
			continue
		q = deque([])
		s.add(v)
		q.append(v)
		while len(q) > 0:
			x = q.popleft()
			for e in E[x]:
				if e not in s:
					s.add(e)
					q.append(e)
			print(q)
		cnt += 1
	return cnt
from typing import List, Tuple

def regular_bs(L, x, l=None, r=None):
	l = 0 if l == None else l
	r = len(L) if r == None else r
	while r - l > 1:
		m = (r + l) // 2
		l = m if L[m] <= x else l
		r = m if L[m] > x else r
	cnt = 0
	return l

def binary_count_smaller(L, x):
	l = 0
	if x < L[0]:
		return 0
	r = len(L)
	while r - l > 1:
		mid = (l + r) // 2
		if L[mid] < x:
			l = mid
		else:
			r = mid
	return l + 1

def binary_count_larger(L, x):
	l = 0
	if x > L[-1]:
		return 0
	r = len(L)
	while r - l > 1:
		mid = (l + r) // 2
		if L[mid] <= x:
			l = mid
		else:
			r = mid
	return len(L) - (r - 1)
from itertools import product

def solution(x, y, a, b):
	if x * y < 0:
		return a * (abs(x) + abs(y))
	x = abs(x)
	y = abs(y)
	res = a * (max(x, y) - min(x, y))
	if b > 2 * a:
		return res + min(x, y) * 2 * a
	return res + min(x, y) * b

def main():
	T = read_int()
	for i in range(T):
		(x, y) = read_int_array()
		(a, b) = read_int_array()
		print(solution(x, y, a, b))
main()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	z = abs(x - y)
	s = s + a * z + min(x, y) * b
	w = (x + y) * a
	print(min(s, w))


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if x == 0 and y == 0:
		print(0)
		continue
	elif x == 0 or y == 0:
		ans = (y + x) * a
	else:
		val = min(y, x)
		ans = min(val * b + (y + x - 2 * val) * a, (y + x) * a)
	print(ans)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(x, y) = sp()
	(a, b) = sp()
	(x, y) = (min(x, y), max(x, y))
	if a * 2 > b:
		out(x * b + (y - x) * a)
	else:
		out((x + y) * a)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
from io import BytesIO
for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x != 0 and y != 0:
		optimal = min(b, 2 * a)
		need = abs(x - y)
		answer = need * a
		answer += min(x, y) * optimal
		print(answer)
	elif x == 0 and y == 0:
		print(0)
	else:
		answer = max(y, x) * a
		print(answer)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (abs(x), abs(y))
	p = (x + y) * a
	r = min(x, y) * b + (max(x, y) - min(x, y)) * a
	print(min(p, r))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	count = 0
	if 2 * a > b:
		op = b
	else:
		op = 2 * a
	if op == 2 * a:
		count = (x + y) * a
	else:
		count += abs(x - y) * a
		count += min(x, y) * b
	print(count)


import datetime
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y == 0:
		print(0)
	elif 2 * a < b:
		count = 0
		temp = min(x, y)
		x -= temp
		y -= temp
		count += temp * 2 * a
		count += x * a + y * a
		print(count)
	else:
		count = 0
		temp = min(x, y)
		x -= temp
		y -= temp
		count += temp * b
		count += a * x + y * a
		print(count)


from math import *
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	if x <= 0 and y >= 0:
		k = abs(x)
		print((k + y) * a)
	else:
		if x < 0 and y < 0:
			c = abs(y - x) * a + abs(y) * b
			d = (abs(x) + abs(y)) * a
			s = min(c, d)
		else:
			c = abs(y - x) * a + abs(x) * b
			d = (abs(x) + abs(y)) * a
			s = min(c, d)
		print(s)


def RoadToZero(a, b, x, y):
	bcount = 0
	acount = 0
	if x == 0:
		acount = y
	elif y == 0:
		acount = x
	elif a * 2 < b:
		b = a
		acount = x
		bcount = y
	else:
		bcount = x if x < y else y
		acount = abs(x - y)
	print(b * bcount + a * acount)
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	RoadToZero(x, y, a, b)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = min(x, y) * b + (max(x, y) - min(x, y)) * a
	ss = x * a + y * a
	if s > ss:
		print(ss)
	else:
		print(s)


for ii in range(int(input())):
	l = [int(i) for i in input().split()]
	m = [int(i) for i in input().split()]
	x = l[0]
	y = l[1]
	a = m[0]
	b = m[1]
	if x * y > 0:
		print(min(b * min(abs(x), abs(y)) + a * (max(abs(x), abs(y)) - min(abs(x), abs(y))), a * (abs(x) + abs(y))))
	else:
		print(a * (abs(x) + abs(y)))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b >= 2 * a:
		ans = x * a + y * a
	else:
		bfact = min(x, y)
		afact = max(x, y) - min(x, y)
		ans = afact * a + bfact * b
	print(ans)


t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if b > 2 * a:
		ans = (m + n) * a
	else:
		ans = min(m, n) * b + (max(m, n) - min(m, n)) * a
	print(ans)


n = int(input())
XY = []
AB = []
for _ in range(n):
	XY.append(tuple(map(int, input().split())))
	AB.append(tuple(map(int, input().split())))
for i in range(n):
	(x, y) = XY[i]
	(a, b) = AB[i]
	price1 = a * (x + y)
	price2 = min(x, y) * b + abs(x - y) * a
	print(min(price1, price2))


for __ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	(mini, maxi) = (min(x, y), max(x, y))
	c1 = mini * a + maxi * a
	c2 = mini * b + (maxi - mini) * a
	print(min(c1, c2))


import sys
readline = sys.stdin.readline
T = int(readline())
Ans = [None] * T
for qu in range(T):
	(x, y) = map(int, readline().split())
	(a, b) = map(int, readline().split())
	if x * y <= 0:
		ans = a * (abs(x) + abs(y))
	else:
		(x, y) = (abs(x), abs(y))
		if x > y:
			(x, y) = (y, x)
		ans = min(b * x + a * (y - x), a * (x + y))
	Ans[qu] = ans
print('\n'.join(map(str, Ans)))


t = int(input())
for i in range(t):
	contador = 0
	linea = input().split(' ')
	x = int(linea[0])
	y = int(linea[1])
	linea = input().split(' ')
	a = int(linea[0])
	b = int(linea[1])
	if 2 * a < b or (x > 0 and y < 0) or (a < 0 and y > 0):
		if x > 0:
			contador += x * a
			x = 0
		elif x < 0:
			x *= -1
			contador += x * a
			x = 0
		if y > 0:
			contador += y * a
			y = 0
		elif y < 0:
			y *= -1
			contador += y * a
			y = 0
	else:
		if x > 0 and y > 0:
			if x > y:
				contador += b * y
				x = x - y
				y = 0
			else:
				contador += b * x
				y = y - x
				x = 0
		elif x < 0 and y < 0:
			x *= -1
			y *= -1
			if x > y:
				contador += b * y
				x = x - y
				y = 0
			else:
				contador += b * x
				y = y - x
				x = 0
		if x > 0:
			contador += x * a
			x = 0
		elif x < 0:
			x *= -1
			contador += x * a
			x = 0
		if y > 0:
			contador += y * a
			y = 0
		elif y < 0:
			y *= -1
			contador += y * a
			y = 0
	print(contador)


q = int(input())
for _ in range(q):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	if x * y <= 0:
		s = a * abs(x) + a * abs(y)
		print(s)
	else:
		x = abs(x)
		y = abs(y)
		MIN = min(x, y)
		MAX = max(x, y)
		if x > 0 and y > 0:
			s1 = MIN * b + (MAX - MIN) * a
			s2 = a * abs(x) + a * abs(y)
			print(min(s1, s2))


for test_i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 < b:
		print(a * (x + y))
	else:
		print(a * abs(x - y) + b * (max(x, y) - abs(x - y)))


import sys

def main():
	t = int(input())
	for _ in range(t):
		(x, y) = map(int, sys.stdin.readline().split())
		(a, b) = map(int, sys.stdin.readline().split())
		diff = abs(x - y)
		if a * 2 < b:
			ans = (x + y) * a
		else:
			ans = min(x, y) * b + diff * a
		print(ans)
	return
main()


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	Cost = min(x, y) * b + (max(x, y) - min(x, y)) * a
	if (x + y) * a < Cost:
		print((x + y) * a)
	else:
		print(Cost)


t = int(input())
for k in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		b = 2 * a
	if y > x:
		temp = x
		x = y
		y = temp
	print(a * (x - y) + y * b)


n = int(input())
t = list()
for i in range(n):
	xy = input()
	x = int(xy.split()[0])
	y = int(xy.split()[1])
	ab = input()
	a = int(ab.split()[0])
	b = int(ab.split()[1])
	tot1 = 0
	tot2 = 0
	if a > b:
		if x >= 0 & y >= 0:
			if x > y:
				tot1 = (x - y) * a + y * b
			else:
				tot1 = (y - x) * a + x * b
		elif x <= 0 & y <= 0:
			if x > y:
				tot1 = (x - y) * a - x * b
			else:
				tot1 = (y - x) * a - y * b
		elif x >= 0 & y <= 0:
			if x > -y:
				tot1 = (x + y) * a + y * b
			else:
				tot1 = (-y - x) * a + x * b
		elif -x > y:
			tot1 = (-x - y) * a + y * b
		else:
			tot1 = (y + x) * a - x * b
	elif x >= 0 & y >= 0:
		if x > y:
			tot1 = (x - y) * a + y * b
		else:
			tot1 = (y - x) * a + x * b
	elif x <= 0 & y <= 0:
		if x > y:
			tot1 = (x - y) * a - x * b
		else:
			tot1 = (y - x) * a - y * b
	elif x >= 0 & y <= 0:
		if x > -y:
			tot1 = (x + y) * a + y * b
		else:
			tot1 = (-y - x) * a + x * b
	elif -x > y:
		tot1 = (-x - y) * a + y * b
	else:
		tot1 = (y + x) * a - x * b
	tot2 = (x + y) * a
	if tot1 > tot2:
		tot = tot2
	else:
		tot = tot1
	t.append(tot)
for i in t:
	print(i)


def zz(x, y, a, b):
	if x == y == 0:
		return 0
	p = min(x, y)
	return min(b * p + abs(x - y) * a, a * (x + y))
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(zz(x, y, a, b))


t = int(input())
for l in range(t):
	(a, b) = map(int, input().split())
	(s1, s2) = map(int, input().split())
	if s1 * 2 < s2:
		print((a + b) * s1)
	else:
		print((max(a, b) - min(a, b)) * s1 + min(a, b) * s2)


s = []
for iii in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	aa = min(x, y) * b + (x - min(x, y)) * a + (y - min(x, y)) * a
	bb = (x + y) * a
	s.append(min(aa, bb))
for i in s:
	print(i)


def road_zero():
	cases = int(input())
	numbers = []
	prices = []
	for i in range(cases):
		numbers.append(list(map(int, input().split())))
		prices.append(list(map(int, input().split())))
	for i in range(len(numbers)):
		if prices[i][0] == 0:
			print(0)
			continue
		output = 0
		minimum = min(abs(numbers[i][0]), abs(numbers[i][1]))
		best = min(minimum * prices[i][0] * 2, minimum * prices[i][1])
		if abs(numbers[i][0]) == minimum:
			numbers[i][0] = 0
		else:
			numbers[i][0] -= minimum
		if abs(numbers[i][1]) == minimum:
			numbers[i][1] = 0
		else:
			numbers[i][1] -= minimum
		output += best
		if numbers[i][0] == 0 and numbers[i][1] == 0:
			print(output)
			continue
		maximum = max(numbers[i][0], numbers[i][1])
		output += maximum * prices[i][0]
		print(output)
road_zero()


from sys import stdin

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		(x, y) = map(int, inp().split())
		(a, b) = map(int, inp().split())
		h = abs(x - y) * a
		if b > 2 * a:
			h += min(x, y) * 2 * a
		else:
			h += min(x, y) * b
		print(h)
main()


def Hello(x, y, a, b):
	if x == 0 and y == 0:
		return 0
	else:
		k = min(b * min(x, y) + a * abs(x - y), a * (x + y))
		return k
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(Hello(x, y, a, b))


cases = int(input())
for j in range(cases):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(k) for k in input().split()]
	mini = min(x, y)
	if a <= b // 2:
		print((x + y) * a)
	else:
		print(mini * b + (max(x, y) - mini) * a)


for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if 2 * a >= b:
		min1 = min([x, y])
		max1 = max([x, y])
		print(abs(min1) * b + abs(min1 - max1) * a)
	else:
		print((x + y) * a)


t = int(input())
while t > 0:
	(k1, k2) = input().split()
	k1 = int(k1)
	k2 = int(k2)
	(m1, m2) = input().split()
	m1 = int(m1)
	m2 = int(m2)
	sum1 = 0
	sum2 = 0
	if (k1 > 0) & (k2 > 0):
		u1 = k1 - k2
		if u1 >= 0:
			q1 = u1
		else:
			q1 = -u1
		sum1 = q1 * m1
		if 2 * m1 > m2:
			if k1 < k2:
				sum2 = m2 * k1
			else:
				sum2 = m2 * k2
		elif k1 < k2:
			sum2 = 2 * m1 * k1
		else:
			sum2 = 2 * m1 * k2
	elif (k1 < 0) & (k2 < 0):
		k1 = -k1
		k2 = -k2
		u1 = k1 - k2
		if u1 >= 0:
			q1 = u1
		else:
			q1 = -u1
		sum1 = q1 * m1
		if 2 * m1 > m2:
			if k1 < k2:
				sum2 = m2 * k1
			else:
				sum2 = m2 * k2
		elif k1 < k2:
			sum2 = 2 * m1 * k1
		else:
			sum2 = 2 * m1 * k2
	elif (k1 == 0) & (k2 > 0):
		sum1 = 0
		sum2 = k2 * m1
	elif (k2 == 0) & (k1 > 0):
		sum1 = k1 * m1
		sum2 = 0
	elif (k1 == 0) & (k2 < 0):
		k2 = -k2
		sum1 = 0
		sum2 = k2 * m1
	elif (k2 == 0) & (k1 < 0):
		k1 = -k1
		sum1 = k1 * m1
		sum2 = 0
	else:
		if k1 >= 0:
			k1 = k1
		else:
			k1 = -k1
		if k2 >= 0:
			k2 = k2
		else:
			k2 = -K2
		sum1 = k1 * m1
		sum2 = k2 * m2

	def add(s1, s2):
		totBestSum = s1 + s2
		return totBestSum
	bbb = add(sum1, sum2)
	print(bbb)
	t = t - 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff1 = abs(x)
	diff2 = abs(y)
	t = abs(diff1 - diff2) * a
	if b <= 2 * a:
		t += min(diff1, diff2) * b
	else:
		t += min(diff1, diff2) * 2 * a
	print(t)


try:
	t = int(input())
	for asdf in range(t):
		(x, y) = map(int, input().split(' '))
		(a, b) = map(int, input().split(' '))
		b_counter = min(x, y)
		a_counter = max(x, y) - b_counter
		amount1 = b_counter * b + a_counter * a
		amount_a = (x + y) * a
		print(min(amount1, amount_a))
except:
	pass


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b // 2 > a:
		print((abs(x) + abs(y)) * a)
		continue
	cost = 0
	x = abs(x)
	y = abs(y)
	cost = min(abs(y - x) * a + b * max(x, y), b * min(x, y) + a * abs(y - x), a * (x + y))
	print(cost)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		s1 = 2 * a * x
		s2 = b * x
		print(min(s1, s2))
	else:
		s = abs(x - y) * a
		s += b * min(x, y)
		s2 = a * (x + y)
		print(min(s, s2))
	t -= 1


n = int(input())
for i in range(n):
	ans = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	minxy = min(x, y)
	maxxy = max(x, y)
	maxxy -= minxy
	if minxy * b < minxy * 2 * a:
		ans += minxy * b
	else:
		ans += minxy * 2 * a
	ans += maxxy * a
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	if x >= 0 and y <= 0:
		s = a * (abs(x) + abs(y))
	elif x >= 0 and y >= 0:
		z = abs(x - y)
		s += a * z
		if 2 * a * min(x, y) > b * min(x, y):
			s += b * min(x, y)
		else:
			s += a * 2 * min(x, y)
	elif x <= 0 and y <= 0:
		z = abs(x - y)
		s += a * z
		if 2 * a * max(x, y) > b * max(x, y):
			s += b * max(x, y)
		else:
			s += a * 2 * max(x, y)
	print(s)


from sys import stdin, stdout
import bisect
import math
import itertools
inp = -1
input = []

def I():
	input = I2()
	if len(input) == 1:
		return input[0]
	else:
		return input

def I2():
	global inp
	inp += 1
	return list(map(int, input[inp].split()))
ONLINE_JUDGE = not __debug__
if ONLINE_JUDGE:
	stdin = open('input.txt', 'r')
input = stdin.readlines()
t = I()
for _ in range(t):
	(x, y) = I()
	(a, b) = I()
	print(min((x + y) * a, (max(x, y) - min(x, y)) * a + min(x, y) * b))


def main():
	t = int(input())
	for _ in range(t):
		total = 0
		(x, y) = list(map(int, input().split()))
		(a, b) = list(map(int, input().split()))
		diff = abs(x - y)
		total += a * diff
		if b > 2 * a:
			total += 2 * a * min(x, y)
		else:
			total += b * min(x, y)
		print(total)
main()


test_case = int(input())
road_list = []
dollars = []
cost1 = 0
cost2 = 0
for i in range(test_case):
	(x, y) = input().split()
	road_list.append(int(x))
	road_list.append(int(y))
	(a, b) = input().split()
	dollars.append(int(a))
	dollars.append(int(b))
index = 0
while index < len(road_list):
	x = road_list[index]
	y = road_list[index + 1]
	a = dollars[index]
	b = dollars[index + 1]
	if x == y and x == 0:
		print(0)
	elif x == y and x != 0:
		cost1 = x * b
		cost2 = x * a + y * a
		if cost1 > cost2:
			print(cost2)
		else:
			print(cost1)
	elif x != y and x > y:
		cost2 = x * a + y * a
		cost1 = y * b
		x = x - y
		cost1 += x * a
		if cost1 > cost2:
			print(cost2)
		else:
			print(cost1)
	elif x != y and y > x:
		cost2 = x * a + y * a
		cost1 = x * b
		y = y - x
		cost1 += y * a
		if cost1 > cost2:
			print(cost2)
		else:
			print(cost1)
	cost1 = 0
	cost2 = 0
	index += 2


import sys
from itertools import islice
stdin = sys.stdin
t = int(stdin.readline())
for line in stdin:
	if not line:
		break
	(x, y) = line.split()
	(x, y) = (int(x), int(y))
	(a, b) = stdin.readline().split()
	(a, b) = (int(a), int(b))
	if b > 2 * a or x * y < 0:
		result = abs(x) + abs(y)
		result *= a
		print(result)
	else:
		b_uses = min(abs(x), abs(y))
		ax_uses = abs(x) - b_uses
		ay_uses = abs(y) - b_uses
		result = b_uses * b + (ax_uses + ay_uses) * a
		print(result)


n = int(input())
while n:
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	if 2 * x < y:
		print((a + b) * x)
	else:
		c = int(min(a, b) * y)
		d = int((max(a, b) - min(a, b)) * x)
		print(c + d)
	n -= 1


def que_42():
	for t in range(int(input())):
		(x, y) = map(int, input().split())
		(c1, c2) = map(int, input().split())
		diff = abs(y - x)
		ans = c1 * diff
		x = y = min(x, y)
		if 2 * c1 < c2:
			ans += 2 * x * c1
		else:
			ans += x * c2
		print(ans)
que_42()


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(II()):
		(x, y) = MI()
		(a, b) = MI()
		v1 = (abs(x) + abs(y)) * a
		v2 = abs(x - y) * a + min(abs(x), abs(y)) * b
		print(min(v1, v2))
main()


t = int(input())
for p in range(0, t):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	cost = 0
	if a + a < b:
		cost = cost + (x + y) * a
	elif x > y:
		cost = cost + (x - y) * a + y * b
	else:
		cost = cost + (y - x) * a + x * b
	print(cost)


t = int(input())
for test in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	maxnum = max(x, y)
	minnum = min(x, y)
	numb = (maxnum - minnum) * a
	numb = numb + minnum * b
	numa = x * a + y * a
	if numa < numb:
		print(numa)
	else:
		print(numb)


t = int(input())
ans = []
for i in range(t):
	flag = False
	cost = 0
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if 2 * a <= b:
		flag = True
	if flag == False:
		sub = min(x, y)
		cost = sub * b
		x = x - sub
		y = y - sub
	cost += y * a + x * a
	ans.append(cost)
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (min(x, y), max(x, y))
	one = (y - x) * a + x * b
	two = (x + y) * a
	print(min(one, two))


t = int(input())
while t > 0:
	(x, y) = [int(q) for q in input().split()]
	(a, b) = [int(q) for q in input().split()]
	if 2 * a <= b:
		print((abs(x) + abs(y)) * a)
	else:
		tot = 0
		if x >= 0 and y >= 0 or (x <= 0 and y <= 0):
			tot += min(abs(x), abs(y)) * b
			tot += (abs(x) - min(abs(x), abs(y))) * a
			tot += (abs(y) - min(abs(x), abs(y))) * a
		else:
			tot += abs(x) * a
			tot += abs(y) * a
		print(tot)
	t -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(y, x) = (x, y)
	z = (y - x) * a
	z += min(x * b, 2 * x * a)
	print(z)


from math import *

def solve():
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	mn = min(abs(x), abs(y))
	ans = 0
	if b < 2 * a:
		ans += b * mn
		if x == mn:
			x = 0
			if y > 0:
				y -= mn
			else:
				y += mn
			ans += a * abs(y)
			print(ans)
		else:
			y = 0
			if x > 0:
				x -= mn
			else:
				x += mn
			ans += a * abs(x)
			print(ans)
	else:
		print(a * (abs(x) + abs(y)))
for _ in range(int(input())):
	solve()


n = int(input())
res = []
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	diff = abs(x - y)
	minb = min(x, y)
	print(min(diff * a + minb * b, (x + y) * a))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	pos1 = (x + y) * a
	pos2 = min(x, y) * b + abs(x - y) * a
	print(min(pos1, pos2))


t = int(input())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	c = min(x, y)
	d = max(x, y)
	if c * b + (d - c) * a <= (c + d) * a:
		print(c * b + (d - c) * a)
	else:
		print((c + d) * a)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	k = min(x, y)
	cnt = b * k
	cnt2 = a * x + a * y
	y -= k
	x -= k
	cnt += a * x + a * y
	print(min(cnt, cnt2))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dollars = 0
	if x == 0 and y == 0:
		dollars = 0
	elif a >= b:
		z = min(x, y)
		x = x - z
		y = y - z
		dollars += b * z
		if x == 0:
			dollars = dollars + a * y
		else:
			dollars = dollars + a * x
	else:
		diff = abs(x - y)
		dollars += a * diff
		if x >= y:
			x = x - diff
		else:
			y = y - diff
		temp1 = 0
		temp2 = 0
		temp1 = a * x + a * y
		temp2 = b * x
		dollars += min(temp1, temp2)
	print(dollars)


for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	x1 = min(x, y)
	q = x1 * b + abs(x + y - 2 * x1) * a
	q1 = (x + y) * a
	print(min(q, q1))


t = int(input())
while t > 0:
	(x, y) = input().split(' ')
	(a, b) = input().split(' ')
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	d = 0
	if x > y:
		d += a * (x - y)
		x = y
	if x < y:
		d += a * (y - x)
		y = x
	if x == y and 2 * a >= b and (x > 0):
		d += b * y
		x = 0
		y = 0
	if x == y and 2 * a < b and (x > 0):
		d += 2 * a * y
		x = 0
		y = 0
	print(d)
	t -= 1


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if b >= a * 2:
		print(a * (x + y))
	else:
		total = b * min(x, y) + a * (max(x, y) - min(x, y))
		print(total)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	nums = [list(map(int, input().split())) for x in range(2 * t)]
	for i in range(t):
		(x, y) = (nums[2 * i][0], nums[2 * i][1])
		(a, b) = (nums[2 * i + 1][0], nums[2 * i + 1][1])
		m = (max(x, y) - min(x, y)) * a + min(x, y) * b
		n = (x + y) * a
		print(min(m, n))
main()


t = int(input())
while t:
	(x, y) = input().split()
	(a, b) = input().split()
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	cost = 0
	if x > y:
		diff = x - y
		temp = x - diff
	else:
		diff = y - x
		temp = y - diff
	cost = diff * a + temp * b
	cost2 = (x + y) * a
	if cost > cost2:
		print(cost2)
	else:
		print(cost)
	t = t - 1


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 5)

def i():
	return sys.stdin.readline().strip()

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

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

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

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

def solve():
	(a, b) = mii()
	(c, d) = mii()
	(x, y) = (min(abs(a), abs(b)), max(abs(a), abs(b)))
	if a >= 0 and b <= 0 or (a <= 0 and b >= 0):
		print(min((x + y) * c, max(x, y) * d + (x + y) * c))
	else:
		print(min((x + y) * c, d * y + abs(x - y) * c, d * x + (y - x) * c))
for _ in range(ii()):
	solve()


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def from_file(f):
	return f.readline

def solve(x, y, a, b):
	if y >= x:
		(x, y) = (y, x)
	return min(y * b + (x - y) * a, (x + y) * a)
t = inp()
for _ in range(t):
	(x, y) = invr()
	(a, b) = invr()
	res = solve(x, y, a, b)
	print(res)


import sys
read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 < b:
		print((x + y) * a)
	else:
		print(min(x, y) * b + abs(y - x) * a)


def ans(x, y, a, b):
	ans = 0
	minimum = min(x, y)
	if x > 0 and y > 0:
		ans += minimum * min(a * 2, b)
	x -= minimum
	y -= minimum
	ans += max(x, y) * a
	return ans
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(ans(x, y, a, b))


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())

def solve():
	(x, y) = mpint()
	(a, b) = mpint()
	if a * 2 <= b:
		return a * (x + y)
	if x > y:
		(x, y) = (y, x)
	return b * x + a * (y - x)
for case in range(itg()):
	print(solve())


import math
import os
import random
import re
import sys

def cost(x, y, a, b):
	sum = 0
	d = x - y
	if d > 0:
		sum = y * min(b, 2 * a) + d * a
	else:
		sum = x * min(b, 2 * a) + abs(d) * a
	return sum
t = int(input())
for i in range(t):
	(x, y) = input().split()
	(a, b) = input().split()
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	print(cost(x, y, a, b))


t = int(input())
for v in range(t):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	total = 0
	total += abs(x - y) * a
	total += min(x, y) * b
	total1 = (x + y) * a
	print(min(total, total1))


def solve():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dollar1 = (x + y) * a
	dollar2 = min(x, y) * b + (max(x, y) - min(x, y)) * a
	print(min(dollar1, dollar2))
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(l1, l2) = (0, 0)
	diff = abs(x - y)
	l1 += diff * a
	l1 += (max(x, y) - diff) * b
	l2 = (x + y) * a
	print(min(l1, l2))


from sys import stdin
rInt = lambda : int(stdin.readline().strip('\n'))
rIntArray = lambda : [int(x) for x in stdin.readline().split()]
rString = lambda : stdin.readline().strip('\n')
rStrArray = lambda : [x for x in stdin.readline().split()]
for _ in range(rInt()):
	(x, y) = sorted(rIntArray())
	(a, b) = rIntArray()
	ans = min(2 * a * x, b * x, b * y) + a * (y - x)
	print(ans)


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m1 = abs(y - x) * a + min(x, y) * b
	m2 = (x + y) * a
	print(min(m1, m2))


for _ in range(int(input())):
	(X, Y) = map(int, input().split())
	(A, B) = map(int, input().split())
	if X == 0 and Y == 0:
		print(0)
	else:
		x = abs(X)
		y = abs(Y)
		if x < y:
			k = y - x
			if 2 * A < B:
				print(k * A + x * 2 * A)
			else:
				print(k * A + x * B)
		else:
			k = x - y
			if 2 * A >= B:
				print(k * A + y * B)
			else:
				print(k * A + y * 2 * A)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print('0')
	else:
		sum = 0
		X = max(x, y)
		Y = min(x, y)
		sum = sum + (X - Y) * a + Y * b
		r = (x + y) * a
		print(min(sum, r))


t = int(input())
for test in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if x == 0 and y == 0:
		print(0)
	if x == 0 and y != 0:
		y = abs(y)
		print(a * y)
	if x != 0 and y == 0:
		x = abs(x)
		print(a * x)
	if x > 0 and y > 0 or (x < 0 and y < 0):
		x = abs(x)
		y = abs(y)
		greater = max(x, y)
		lower = min(x, y)
		if b < 2 * a:
			cost = lower * b + (greater - lower) * a
			print(cost)
		else:
			cost = (greater + lower) * a
			print(cost)
	if x > 0 and y < 0 or (x < 0 and y > 0):
		cost = (abs(x) + abs(y)) * a
		print(cost)


import sys

def func():
	(x, y) = map(int, sys.stdin.readline().split())
	(a, b) = map(int, sys.stdin.readline().split())
	count = 0
	if x > y:
		count += (x - y) * a + b * y
	elif y > x:
		count += (y - x) * a + b * x
	elif x == y:
		count += b * x
	count2 = (x + y) * a
	return min(count, count2)
t = int(sys.stdin.readline())
while t:
	print(func())
	t -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	t1 = 0
	t2 = 0
	if x > y:
		t1 = a * (x - y)
		if 2 * y * a > b * y:
			print(b * y + t1)
		else:
			print(t1 + 2 * a * y)
	else:
		t1 = a * (y - x)
		if 2 * x * a > b * x:
			print(b * x + t1)
		else:
			print(t1 + 2 * a * x)


for xyz in range(0, int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	p1 = a * (abs(x) + abs(y))
	(x, y) = (min(x, y), max(x, y))
	p2 = abs(x) * b
	p2 += abs(y - x) * a
	print(min(p1, p2))


inp = lambda : map(int, input().split())
for _ in range(int(input())):
	(x, y) = inp()
	(a, b) = inp()
	minn = min(x, y)
	maxx = max(x, y)
	v1 = minn * b + (maxx - minn) * a
	v2 = (x + y) * a
	print(min(v1, v2))


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ans = 0
	ans += abs(x) + abs(y)
	ans *= a
	ans1 = 0
	p = abs(x)
	q = abs(y)
	if p > q:
		(p, q) = (q, p)
	ans1 += p * b
	ans1 += (q - p) * a
	print(min(ans, ans1))


t = int(input())
for rep in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	maxi = max(x, y)
	mini = min(x, y)
	print(min(a * (maxi - mini) + b * mini, a * (maxi - mini) + 2 * a * mini))


def R():
	return map(int, input().split())
(t,) = R()
for _ in range(t):
	(x, y) = sorted(R())
	(a, b) = R()
	print(min(2 * a, b) * x + a * (y - x))


inp = int(input())
cost = []
for _ in range(inp):
	l1 = input().split(' ')
	l2 = input().split(' ')
	x = int(l1[0])
	y = int(l1[1])
	a = int(l2[0])
	b = int(l2[1])
	ac = abs(x - y)
	if b < 2 * a:
		if x > y:
			bc = abs(x - ac)
		else:
			bc = abs(y - ac)
		cost.append(ac * a + bc * b)
	else:
		if x > y:
			bc = abs(x - ac)
		else:
			bc = abs(y - ac)
		cost.append(ac * a + bc * 2 * a)
for i in cost:
	print(i)


for ii in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mymax = max(x, y)
	mymin = min(x, y)
	z = abs(mymax - mymin) * a + mymin * b
	y = (mymax + mymin) * a
	print(min(z, y))


n = int(input())
for k in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print(a * (x + y))
	else:
		print(b * min(x, y) + a * abs(x - y))


arr = [[], []]

def out1(x, n, m):
	if x <= 0:
		return True
	if n <= 0:
		if x - 10 * m > 0:
			return False
		else:
			return True
	if m <= 0:
		return False
	return out1(x // 2 + 10, n - 1, m) or out1(x - 10, n, m - 1)

def out():
	(n, a, b, c, d) = map(int, input().split())
	if c - d > n * (a + b) or n * (a - b) > c + d:
		return 'No'
	return 'Yes'
ans = 0
for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(b * min(x, y) + a * (max(x, y) - min(x, y)), a * (x + y)))


test_case = int(input())
for test in range(test_case):
	(x, y) = (int(item) for item in input().split())
	(a, b) = (int(item) for item in input().split())
	if 2 * a < b:
		print((x + y) * a)
	else:
		print(min(x, y) * b + a * (max(x, y) - min(x, y)))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	else:
		sums = 0
		sums2 = 0
		diff = abs(y - x)
		sums = sums + diff * a
		sums = sums + min(x, y) * b
		sums2 = (x + y) * a
		if sums2 <= sums:
			print(sums2)
		else:
			print(sums)


from collections import defaultdict as dc
from heapq import *
import math
import bisect
import sys
from collections import deque as dq
from heapq import heapify, heappush, heappop
mod = 10 ** 9 + 7

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

def line():
	p = list(map(int, input().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def digit(n):
	s = str(n)
	p = 0
	for i in s:
		p += int(i) ** 2
	return p

def solve(a, t):
	pass
for _ in range(inp()):
	(x, y) = line()
	(a, b) = line()
	ans2 = a * (x + y)
	z = min(x, y)
	ans = z * b
	l = max(x, y)
	ans += (l - z) * a
	print(min(ans, ans2))


import math

def inp_n():
	return int(input())

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

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

def is_odd(n):
	if n & 1:
		return True
	return False
for _ in range(inp_n()):
	(x, y) = inp_mul_num()
	(a, b) = inp_mul_num()
	v = abs(x - y)
	m = min(x, y)
	print(min(v * a + m * b, (x + y) * a))


tests = int(input())

def absolute(n):
	if n < 0:
		return -n
	return n

def sign(n):
	if n < 0:
		return 1
	return -1
for t in range(tests):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	minim = a * absolute(x) + a * absolute(y)
	minim = min(minim, b * absolute(x) + a * absolute(y - x))
	minim = min(minim, b * absolute(y) + a * absolute(x - y))
	print(minim)


t = int(input())
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	ans = 0
	d = min(x, y)
	if 2 * a < b:
		ans = 2 * d * a
	else:
		ans = b * d
	ans += a * abs(x - y)
	print(ans)


def solve():
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if b < a:
		(w, z) = (min(x, y), max(x, y))
		cost = w * b + (z - w) * a
	elif b > 2 * a:
		cost = (x + y) * a
	else:
		(w, z) = (min(x, y), max(x, y))
		cost = w * b + (z - w) * a
	print(cost)
t = int(input())
for i in range(t):
	solve()


import bisect, math

def foo(a, b, x, y):
	if a + a <= b:
		return (x + y) * a
	return abs(x - y) * a + min(x, y) * b
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(foo(a, b, x, y))


import sys
input = sys.stdin.buffer.readline
INF = 2 ** 62 - 1

def read_int():
	return int(input())

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

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

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

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

def slv(X, Y, A, B):
	ans = (abs(X) + abs(Y)) * A
	if X * Y > 0:
		X = abs(X)
		Y = abs(Y)
		if X > Y:
			(X, Y) = (Y, X)
		ans = min(ans, X * B + (Y - X) * A)
	return ans

def main():
	T = read_int()
	for _ in range(T):
		(X, Y) = read_int_n()
		(A, B) = read_int_n()
		print(slv(X, Y, A, B))
main()


import sys
import math
t = int(input())
for _ in range(t):
	(x, y) = [int(c) for c in input().split()]
	(a, b) = [int(c) for c in input().split()]
	(x, y) = (min(x, y), max(x, y))
	res1 = (y - x) * a + x * b
	res2 = (x + y) * a
	res = min(res1, res2)
	print(res)


import sys
import math
input = sys.stdin.buffer.readline
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	distX = abs(x)
	distY = abs(y)
	if 2 * a < b:
		print(distY * a + distX * a)
	else:
		tmp = a * (max(distX, distY) - min(distX, distY)) + min(distY, distX) * b
		print(tmp)


t = 0
try:
	t = int(input())
except:
	pass
for _ in range(t):
	l = list(map(int, input().split()))
	(a, b) = map(int, input().split())
	if a > b / 2:
		print(min(l) * b + (max(l) - min(l)) * a)
	else:
		print(min(l) * a * 2 + (max(l) - min(l)) * a)


n = int(input())
mine = []
for k in range(n):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a * 2 < b:
		mine.append((y + x) * a)
	else:
		mine.append(b * min(x, y) + a * abs(x - y))
for v in mine:
	print(v)


T = int(input())
while T:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = min(abs(x - y) * a + min(x, y) * b, (x + y) * a)
	T -= 1
	print(ans)


for _ in range(int(input())):
	[x, y] = list(map(int, input().split()))
	[a, b] = list(map(int, input().split()))
	count = 0
	if 2 * a <= b or a * b < 0:
		print((abs(x) + abs(y)) * a)
	else:
		small = min(abs(x), abs(y))
		large = max(abs(x), abs(y))
		print(small * b + (large - small) * a)


n = int(input())
x = []
y = []
a = []
b = []
mon_b = [0] * n
mon_a = [0] * n
for i in range(n):
	x_y = list(map(int, input().split()))
	x.append(x_y[0])
	y.append(x_y[1])
	ab = list(map(int, input().split()))
	a.append(ab[0])
	b.append(ab[1])
for i in range(n):
	if x[i] > y[i]:
		k = x[i] - y[i]
		mon_a[i] = k * a[i]
		x[i] = y[i]
	elif y[i] > x[i]:
		k = y[i] - x[i]
		mon_a[i] = k * a[i]
		y[i] = x[i]
	if x[i] * a[i] + y[i] * a[i] > b[i] * x[i]:
		mon_b[i] = b[i] * x[i]
	else:
		mon_b[i] = x[i] * a[i] + y[i] * a[i]
for i in range(n):
	print(mon_a[i] + mon_b[i])


t = int(input())
for _ in range(t):
	(x, y) = [int(x) for x in input().strip().split()]
	(a, b) = [int(x) for x in input().strip().split()]
	if 2 * a < b:
		res = (abs(x) + abs(y)) * a
	elif x < 0 and y < 0:
		res = abs(abs(x) - abs(y)) * a + abs(b * max(x, y))
	elif x > 0 and y > 0:
		res = abs(y - x) * a + min(x, y) * b
	else:
		res = (abs(x) + abs(y)) * a
	print(res)


t = int(input())
for i in range(t):
	xy = input().split()
	x = int(xy[0])
	y = int(xy[1])
	ab = input().split()
	a = int(ab[0])
	b = int(ab[1])
	mn = min(x, y)
	mx = max(x, y)
	print(min(a * (mx + mn), a * (mx - mn) + b * mn))


mas_res = []
for i in range(int(input())):
	result = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s1 = x * a + y * a
	s2 = (max(x, y) - min(x, y)) * a + min(x, y) * b
	mas_res.append(min(s1, s2))
for d in mas_res:
	print(d)


import sys
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().split()))

def a():
	ans = ''
	for _ in range(int(inp())):
		(x, y) = sorted(read())
		(a, b) = read()
		d = min((y - x) * a + b * x, (y + x) * a)
		ans += str(d) + '\n'
	print(ans)
a()


from pprint import pprint
import sys
input = sys.stdin.readline
q = int(input())
for _ in range(q):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res = 999999999999999999999999999
	both = x
	kata = abs(y - x)
	v = both * b + kata * a
	res = min(res, v)
	both = y
	kata = abs(x - y)
	v = both * b + kata * a
	res = min(res, v)
	both = 0
	kata = abs(x) + abs(y)
	v = both * b + kata * a
	res = min(res, v)
	kata = abs(x - y)
	both = min(x, y)
	v = both * b + kata * a
	res = min(res, v)
	print(res)


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(x, y) = [int(x) for x in input().split()]
		(a, b) = [int(x) for x in input().split()]
		c1 = 0
		c1 += b * min(x, y)
		c1 += a * abs(x - y)
		c2 = 0
		c2 += b * max(x, y)
		c2 += a * abs(x - y)
		c3 = 0
		c3 += a * abs(x - y)
		c3 += b * max(x, y)
		c4 = 0
		c4 += a * abs(x - y)
		c4 += b * min(x, y)
		c5 = x * a + y * a
		print(min(c1, c2, c3, c4, c5))
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin
for _ in range(int(stdin.readline())):
	(x, y) = map(int, stdin.readline().split())
	(a, b) = map(int, stdin.readline().split())
	print(min(a * abs(x - y) + min(x, y) * b, a * (x + y)))


t = int(input())
while t:
	t = t - 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	out1 = (x + y) * a
	out2 = abs(x - y) * a + min(x, y) * b
	print(min(out1, out2))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	(a, b) = map(int, input().split())
	cost = 0
	totalOperation = x + y
	minimum = min(x, y)
	if x == 0 and y == 0:
		print(0)
	elif minimum * b < 2 * minimum * a:
		cost = minimum * b + (totalOperation - minimum - minimum) * a
		print(cost)
	else:
		cost = totalOperation * a
		print(cost)


t = int(input())
for case in range(t):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if x == 0 and y == 0:
		print(0)
	else:
		indi_cost = (x + y) * a
		split_cost = min(x, y) * b + (max(x, y) - min(x, y)) * a
		print(min(indi_cost, split_cost))


t = int(input())
for _ in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	c1 = abs(0 - x)
	c2 = abs(0 - y)
	ans1 = c1 * a + c2 * a
	m = min(c1, c2)
	ans2 = m * b + (c1 - m) * a + (c2 - m) * a
	print(min(ans1, ans2))


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return s[:len(s) - 1]

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

def solve(dim, t):
	(x, y) = dim
	(a, b) = t
	effort = abs(x) + abs(y)
	if 2 * a <= b:
		cost = effort * a
		print(cost)
	else:
		cost = 0
		if x < 0 and y < 0 or (x > 0 and y > 0):
			cost += min(abs(x), abs(y)) * b
			effort -= 2 * min(abs(x), abs(y))
		cost += effort * a
		print(cost)
T = inp()
dims = []
tests = []
for _ in range(T):
	dims.append(inlt())
	tests.append(inlt())
for i in range(T):
	solve(dims[i], tests[i])


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	s = 0
	if x == 0 and y == 0:
		print(0)
		continue
	if 2 * a > b:
		s += (min(x, y) - 1) * b
		s += (max(x, y) - (min(x, y) - 1) - 1) * a
		s += b
	else:
		s += (x + y) * a
	print(s)


test = int(input())
while test > 0:
	test -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y == 0:
		print(0)
	elif x == y:
		if b > a * 2:
			b = 2 * a
		print(b * y)
	else:
		sum = a * abs(x - y)
		if b > a * 2:
			b = 2 * a
		if x > y:
			sum += b * y
		else:
			sum += b * x
		print(sum)


def solve(x, y, a, b):
	b = min(b, 2 * a)
	ans = 0
	if x <= 0 and y <= 0:
		x *= -1
		y *= -1
	if x > 0 and y > 0:
		delta = min(x, y)
		x -= delta
		y -= delta
		ans += b * delta
	ans += a * abs(x)
	ans += a * abs(y)
	return ans

def main():
	n = int(input())
	for _ in range(n):
		(x, y) = list(map(int, input().split()))
		(a, b) = list(map(int, input().split()))
		ans = solve(x, y, a, b)
		print(ans)
main()


from collections import Counter
from _collections import defaultdict
import math
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rls = lambda : list(map(str, input().split()))
t = int(input())
for _ in range(0, t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	mn = min(x, y)
	s = 0
	if 2 * a < b:
		s = s + mn * (2 * a)
	else:
		s = s + mn * b
	s = s + (max(x, y) - mn) * a
	print(s)


for t in range(int(input())):
	(x, y) = sorted(map(int, input().split()))
	(a, b) = map(int, input().split())
	if x:
		if 2 * a < b:
			ans = a * (x + y)
		else:
			ans = x * b + a * (y - x)
	else:
		ans = y * a
	print(ans)


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if abs(x) >= abs(y):
		m = abs(y)
	else:
		m = abs(x)
	n = abs(x - y)
	if x <= 0 <= y or y <= 0 <= x:
		print(n * a)
	else:
		print(n * a + m * min(2 * a, b))


t = int(input())
for k in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print((x + y) * a)
	else:
		Min = min(x, y)
		res = b * Min + a * (max(x, y) - Min)
		print(res)


import sys
from os import path
if path.exists('C:/Users/prana/Desktop/sublime/input.txt'):
	sys.stdin = open('C:/Users/prana/Desktop/sublime/input.txt', 'r')
	sys.stdout = open('C:/Users/prana/Desktop/sublime/output.txt', 'w')

def solve():
	xy = list(map(int, input().split()))
	x = xy[0]
	y = xy[1]
	ab = list(map(int, input().split()))
	a = ab[0]
	b = ab[1]
	if 2 * a < b:
		print(a * (x + y))
	else:
		print('hy', file=sys.stderr)
		mi = min(x, y)
		ma = max(x, y)
		temp = ma - mi
		ans = mi * b
		ans += temp * a
		print(ans)
T = 1
T = int(input())
for _ in range(1, T + 1):
	print('Case #', _, file=sys.stderr)
	solve()


def linput():
	return [int(i) for i in input().split()]
q = int(input())
for ______ in range(q):
	(a, b) = linput()
	(n, m) = linput()
	a1 = a
	b1 = b
	if b1 > a1:
		(b1, a1) = (a1, b1)
	s = (a1 - b1) * n
	if n * 2 < m:
		s += b1 * 2 * n
	else:
		s += b1 * m
	print(s)


t = int(input())
Ans = []
for o in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	Ans.append((max(x, y) - min(x, y)) * a + min(2 * a, b) * min(x, y))
for k in Ans:
	print(k)


t = int(input())
while t:
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	if x >= 0 and y >= 0 or (x <= 0 and y <= 0):
		m = max(x, y)
		n = min(x, y)
		result = abs(m - n) * a + abs(n) * (b if b <= 2 * a else 2 * a)
		print(result)
	else:
		result = a * (abs(x) + abs(y))
		print(result)
	t -= 1


n = int(input())
xy = [[] for i in range(n)]
ab = [[] for i in range(n)]
for i in range(n):
	xy[i] = list(map(int, input().split()))
	ab[i] = list(map(int, input().split()))
for i in range(n):
	if 2 * ab[i][0] <= ab[i][1]:
		cost = sum(xy[i]) * ab[i][0]
	else:
		cost = min(xy[i]) * ab[i][1] + abs(xy[i][0] - xy[i][1]) * ab[i][0]
	print(cost)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 > b:
		if x == y:
			print(x * b)
		else:
			big = x if x > y else y
			small = x if x < y else y
			print(small * b + (big - small) * a)
	else:
		print((x + y) * a)


numTests = int(input())
ops = 0
for i in range(numTests):
	ops = 0
	(x, y) = tuple((int(i) for i in input().split(' ')))
	(a, b) = tuple((int(i) for i in input().split(' ')))
	if b >= 2 * a:
		ops = (x + y) * a
	elif x < 0 and y < 0:
		ops += max(x, y) * b + abs(x - y) * a
	elif x > 0 and y > 0:
		ops += min(x, y) * b + abs(x - y) * a
	else:
		ops = (x + y) * a
	print(ops)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	val1 = val2 = 0
	val1 = min(x, y) * b + abs(x - y) * a
	val2 = (x + y) * a
	j = 0
	for i in range(10):
		j += 1
	print(min(val1, val2))


for q in range(int(input())):
	sum1 = 0
	sum2 = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff = abs(x - y)
	sum = diff * a
	if x <= y:
		sum1 += x * b
		sum2 += 2 * x * a
	else:
		sum1 += y * b
		sum2 += 2 * y * a
	z = [sum1, sum2]
	z.sort()
	print(int(z[0] + sum))


total = int(input())
result = []
for i in range(total):
	nm = input().split(' ')
	ab = input().split(' ')
	n = int(nm[0])
	m = int(nm[1])
	a = int(ab[0])
	b = int(ab[1])
	candid = min(n, m)
	candid2 = max(n, m) - candid
	if candid * b + candid2 * a < (n + m) * a:
		result.append(candid * b + candid2 * a)
	else:
		result.append((n + m) * a)
for t in range(total):
	print(result[t])


t = int(input())
for g in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ans = abs(x - y) * a
	if b >= 2 * a:
		ans += 2 * a * min(x, y)
	else:
		ans += b * min(x, y)
	print(ans)


import math
t = int(input(''))
for i in range(t):
	(x, y) = sorted(list(map(int, input().split())))
	(a, b) = list(map(int, input().split()))
	result = min(abs(x - y) * a + x * b, (x + y) * a)
	print(result)


T = int(input())
for _ in range(T):
	(x, y) = [int(ele) for ele in input().split(' ')]
	(a, b) = [int(ele) for ele in input().split(' ')]
	if b > 2 * a:
		b = 2 * a
	ans = min(abs(x), abs(y)) * b + abs(y - x) * a
	print(int(ans))


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x >= y:
		dist1 = x - y
		cost1 = a * dist1 + b * abs(y)
	else:
		dist1 = y - x
		cost1 = a * dist1 + b * abs(x)
	cost2 = a * (abs(x) + abs(y))
	if cost1 < cost2:
		print(cost1)
	else:
		print(cost2)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	print(min(m * b + (x + y - 2 * m) * a, (x + y) * a))


n = int(input())
for i in range(n):
	(x, y) = [int(x1) for x1 in input().split()]
	(a, b) = [int(x2) for x2 in input().split()]
	if x * y < 0:
		print(abs(x - y) * a)
	else:
		money1 = min(x, y) * b + abs(x - y) * a
		money2 = (x + y) * a
		if money1 < money2:
			print(money1)
		else:
			print(money2)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	elif x == 0 and y != 0:
		print(y * a)
	elif x != 0 and y == 0:
		print(a * x)
	else:
		sum = 0
		sum2 = x * a + y * a
		m = min(x, y)
		sum += m * b
		x = x - m
		y = y - m
		if x == 0 and y == 0:
			sum += 0
		elif x == 0 and y != 0:
			sum += y * a
		elif x != 0 and y == 0:
			sum += a * x
		print(min(sum, sum2))


j = int(input())
while j > 0:
	xy = input().split(' ')
	modifiers = input().split(' ')
	x = min(int(xy[0]), int(xy[1]))
	y = max(int(xy[0]), int(xy[1]))
	a = int(modifiers[0])
	b = int(modifiers[1])
	c = min(y * a + x * (b - a), y * a + x * a)
	print(c)
	j -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(s, ts) = (0, 0)
	s = s + min(x, y) * b
	s = s + (max(x, y) - min(x, y)) * a
	ts = ts + x * a + y * a
	print(min(s, ts))


t = int(input())

def fn():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	if 2 * a > b:
		print(b * x + (y - x) * a)
	else:
		print(a * x + a * y)
while t:
	t -= 1
	fn()


cases = int(input())
for _ in range(cases):
	(x, y) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	(a, b) = map(int, input().split())
	if x == y:
		print(min((x + y) * a, x * b))
	else:
		tot = 0
		tot1 = 0
		tot += abs(x - y) * a
		tot += min(x, y) * b
		tot1 += a * (x + y)
		print(min(tot1, tot))


t = int(input())
x_values = []
y_values = []
a_values = []
b_values = []
for i in range(t):
	(x, y) = input().split(' ')
	(a, b) = input().split(' ')
	x_values.append(int(x))
	y_values.append(int(y))
	a_values.append(int(a))
	b_values.append(int(b))
for i in range(t):
	x = x_values[i]
	y = y_values[i]
	a = a_values[i]
	b = b_values[i]
	if 2 * a < b:
		b = 2 * a
	print(abs(y - x) * a + min(x, y) * b)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	big = max(x, y)
	small = min(x, y)
	equ1 = (big - small) * a
	equ2 = small * b
	total1 = equ1 + equ2
	equA = (x + y) * a
	print(min(equA, total1))


t = int(input())

def solve(x, y, a, b):
	if a * 2 <= b:
		return (x + y) * a
	ans = min(x, y) * b + (max(x, y) - min(x, y)) * a
	return ans
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(x, y, a, b))


for _ in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	b = min(b, 2 * a)
	d = (max(x, y) - min(x, y)) * a
	d += (min(x, y) - 0) * b
	print(d)


t = int(input())
while t > 0:
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if x == y and y == 0:
		print(0)
		t -= 1
		continue
	if x > y:
		(x, y) = (y, x)
	cost = (y - x) * a
	if b > 2 * a:
		cost += 2 * a * x
	else:
		cost += b * x
	print(cost)
	t -= 1


def go():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = abs(x - y)
	result = min([a * d + b * min(x, y), a * (x + y)])
	return result
t = int(input())
ans = []
for _ in range(t):
	ans.append(str(go()))
print('\n'.join(ans))


n = int(input())
for i in range(n):
	q = str(input()).split()
	v = str(input()).split()
	x = int(q[0])
	y = int(q[1])
	a = int(v[0])
	b = int(v[1])
	if a == b:
		per = b * max(x, y)
	elif a * (y + x) < b or a <= b // 2:
		per = a * (x + y)
	else:
		per = a * (max(x, y) - min(x, y)) + b * min(x, y)
	print(per)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	m = min(x, y)
	mx = max(x, y)
	if 2 * a > b:
		print(b * m + a * (mx - m))
	else:
		print(a * (x + y))


t = int(input())
while t:
	t = t - 1
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	sum1 = b[0] * (a[0] + a[1])
	ans = b[1] * a[0]
	a[1] = a[1] - a[0]
	ans = ans + b[0] * a[1]
	print(min(ans, sum1))


def runFunc():
	(x, y) = [int(val) for val in input().strip().split()]
	(a, b) = [int(val) for val in input().strip().split()]
	if x < y:
		(x, y) = (y, x)
	if 2 * a <= b:
		print((x + y) * a)
	else:
		print(y * b + (x - y) * a)
t = int(input())
for i in range(t):
	runFunc()


def solution(x, y, a, b):
	total = 0
	d = abs(x - y)
	total += d * a
	f = 0
	c = 2 * (min(x, y) * a)
	d = b * min(x, y)
	total += min(c, d)
	return total
t = int(input())
for i in range(t):
	(X, Y) = list(map(int, input().strip().split()))
	(A, B) = list(map(int, input().strip().split()))
	print(solution(X, Y, A, B))


for i in range(int(input())):
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	diff_x = x - 0
	diff_y = y - 0
	sum1 = (diff_x + diff_y) * a
	if diff_x > diff_y:
		sum2 = (diff_x - diff_y) * a + diff_y * b
	else:
		sum2 = (diff_y - diff_x) * a + diff_x * b
	if sum1 < sum2:
		print(sum1)
	else:
		print(sum2)


from sys import stdin, stdout
from collections import defaultdict, deque

def main():
	for _ in range(int(stdin.readline())):
		(x, y) = map(int, input().split())
		res = 0
		(a, b) = map(int, input().split())
		if x == 0 and y == 0:
			print(0)
		else:
			if x > y:
				diff = x - y
				res = diff * a
				if a * 2 < b:
					res = res + a * 2 * y
				else:
					res += y * b
			else:
				diff = y - x
				res = diff * a
				if a * 2 < b:
					res += a * 2 * x
				else:
					res += b * x
			print(res)
main()


def rtz(x, y, a, b):
	money = 0
	if b < 2 * a and x * y > 0:
		absxy = min(abs(x), abs(y))
		money += b * absxy
		x = abs(x) - absxy
		y = abs(y) - absxy
	money += a * (abs(x) + abs(y))
	return money
t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(rtz(x, y, a, b))


LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
yes = lambda : print('Yes')
no = lambda : print('No')
I = lambda : list(input())
J = lambda x: ''.join(x)
II = lambda : int(input())
SI = lambda : input()
t = II()
for i in range(t):
	(x, y) = MI()
	(a, b) = MI()
	if b > 2 * a:
		print((x + y) * a)
	else:
		c = abs(x - y) * a + min(x, y) * b
		print(c)


for i in range(int(input())):
	(x, y) = map(int, input().split(' '))
	(x, y) = (abs(x), abs(y))
	(a, b) = map(int, input().split(' '))
	if x > y:
		if (x + y) * a > (x - y) * a + y * b:
			ans = (x - y) * a + y * b
		else:
			ans = (x + y) * a
	elif y >= x:
		if (x + y) * a > (y - x) * a + x * b:
			ans = (y - x) * a + x * b
		else:
			ans = (x + y) * a
	print(ans)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	c = min(x, y)
	d = min(b, a * 2)
	dif = abs(x - y)
	print(d * c + dif * a)


import math

def rn():
	a = int(input())
	return a

def rl():
	a = list(map(int, input().split()))
	return a
for _ in range(int(input())):
	[x, y] = list(map(int, input().split()))
	[a, b] = list(map(int, input().split()))
	ans = 0
	if 2 * a > b:
		ans = min(x, y) * b + a * (max(x, y) - min(x, y))
	else:
		ans = a * (x + y)
	print(ans)


import sys
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a * 2 < b:
		print((x + y) * a)
	else:
		print(min(x, y) * b + (max(x, y) - min(x, y)) * a)


def func(x, y, a, b):
	if 2 * a < b:
		v = (x + y) * a
	else:
		d = abs(x - y)
		v = min(x, y) * b + d * a
	return v
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(func(x, y, a, b))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	min_n = min(x, y)
	max_n = max(x, y)
	if b > 2 * a:
		print(a * (x + y))
	else:
		print(b * min_n + a * (max_n - min_n))


import sys
t = int(input())
while t != 0:
	(x, y) = map(int, sys.stdin.readline().strip().split())
	(a, b) = map(int, sys.stdin.readline().strip().split())
	total = 0
	if x > y:
		temp = x
		x = y
		y = temp
	total += a * (y - x)
	if 2 * a < b:
		total += x * (2 * a)
	else:
		total += x * b
	print(total)
	t -= 1


tc = int(input())
cases = []
for i in range(tc):
	cases.append(list(map(int, input().split())))
	cases[i] += list(map(int, input().split()))
for case in cases:
	(x, y) = (case[0], case[1])
	(a, b) = (case[2], case[3])
	if b * min(x, y) < a * 2 * min(x, y):
		print(b * min(x, y) + a * abs(x - y))
	else:
		print(a * (x + y))


t = int(input())
buf = []
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	buf.append(min(a * abs(x - y) + b * min(x, y), a * (x + y)))
print('\n'.join(map(str, buf)))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	sumb = 0
	c = abs(x - y)
	sumb = c * a + b * min(x, y)
	suma = (x + y) * a
	print(min(sumb, suma))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	tmp_count_1 = abs(x - y)
	tmp_count_2 = min(x, y)
	tmp_1 = tmp_count_1 * a + tmp_count_2 * b
	tmp_2 = (x + y) * a
	ans = min(tmp_1, tmp_2)
	print(ans)


t = int(input())
for i in range(t):
	l1 = list(map(int, input().split()))
	x = l1[0]
	y = l1[1]
	l2 = list(map(int, input().split()))
	a = l2[0]
	b = l2[1]
	max1 = max(x, y)
	min1 = min(x, y)
	d = max1 - min1
	if d == 0:
		if x == 0 and y == 0:
			print(0)
		elif b > a * 2:
			print(a * 2 * x)
		else:
			print(b * x)
	elif b > a:
		sum1 = d * a
		if b > 2 * a:
			sum1 = sum1 + 2 * a * min1
		else:
			sum1 = sum1 + b * min1
		print(sum1)
	else:
		sum1 = 0
		sum1 = min1 * b
		sum1 += d * a
		print(sum1)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = 0
	cost += a * abs(x - y)
	z = min(x, y)
	x = y = z
	cost += min(x * b, a * 2 * x)
	print(cost)


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	k = min(x, y)
	s = abs(x - y)
	print(min(k * b + s * a, a * (x + y)))


import io, os
import sys
from atexit import register
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())
t = nextInt()
for _ in range(t):
	x = nextInt()
	y = nextInt()
	a = nextInt()
	b = nextInt()
	if x > y:
		(x, y) = (y, x)
	res = x * b + (y - x) * a
	res = min(res, (y - x) * a + y * b)
	res = min(res, a * (x + y))
	print(res)


n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = 0
	if a >= b / 2:
		min_num = min(x, y)
		cost += min_num * b
		x -= min_num
		y -= min_num
		max_num = max(x, y)
		cost += max_num * a
	else:
		cost = (x + y) * a
	print(cost)


def sign(x):
	return x // (abs(x) + (x == 0))

def main():
	for _ in range(int(input())):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		if a * 2 < b or sign(x) != sign(y):
			print(a * (abs(x) + abs(y)))
		else:
			print(abs(x - y) * a + min(abs(x), abs(y)) * b)
main()


def roadToZero(x, y, a, b):
	if x == 0 and y == 0:
		print(0)
		return
	elif x == y:
		sum1 = (x + y) * a
		sum2 = x * b
		print(min(sum1, sum2))
		return
	else:
		diff = abs(x - y)
		ans = []
		sum1 = (x + y) * a
		sum3 = diff * a + min(x, y) * b
		ans.extend([sum1, sum3])
		print(min(ans))

def main():
	t = int(input())
	for i in range(t):
		(x, y) = tuple(map(int, input().split()))
		(a, b) = tuple(map(int, input().split()))
		roadToZero(x, y, a, b)
main()


_IS_DEBUG_MODE = False

def Problem():
	if _IS_DEBUG_MODE == True:
		testcaseList = []
		testcaseList.append([1, 3, 391, 555])
		testcaseList.append([0, 0, 9, 4])
		testcaseList.append([30, 10, 2, 1])
		testcaseList.append([1000000, -100000, 9, 4])
	else:
		t = int(input())
		testcaseList = []
		for testcaseIndex in range(t):
			(x, y) = list(map(int, input().split()))
			(a, b) = list(map(int, input().split()))
			testcaseList.append([x, y, a, b])
	return testcaseList

def Solver(testcaseList):
	for (x, y, a, b) in testcaseList:
		if _IS_DEBUG_MODE == True:
			print('testcase', x, y, a, b)
		costList = []
		cost = (abs(x) + abs(y)) * a
		costList.append(cost)
		cost = abs(x) * b + abs(y - x) * a
		costList.append(cost)
		cost = abs(y) * b + abs(x - y) * a
		costList.append(cost)
		cx_float = float(x - y) / 2.0
		dxy = int(cx_float - x)
		cx = x + dxy
		cy = y + dxy
		cost = abs(dxy) * b + (abs(cx) + abs(cy)) * a
		costList.append(cost)
		dxy += 1
		cx = x + dxy
		cy = y + dxy
		cost = abs(dxy) * b + (abs(cx) + abs(cy)) * a
		costList.append(cost)
		dxy -= 1
		cx = x + dxy
		cy = y + dxy
		cost = abs(dxy) * b + (abs(cx) + abs(cy)) * a
		costList.append(cost)
		if _IS_DEBUG_MODE == True:
			print(costList)
		print(min(costList))
if _IS_DEBUG_MODE == True:
	import time
	startTime = time.time()
testcaseList = Problem()
Solver(testcaseList)
if _IS_DEBUG_MODE == True:
	endTime = time.time()
	print('time', endTime - startTime)


T = int(input())
while T:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, 2 * a)
	if x < y:
		(x, y) = (y, x)
	print(b * y + (x - y) * a)
	T -= 1


def solve():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	ans1 = (x + y) * a
	if x > y:
		ans = ans + a * (x - y)
		x = y
	else:
		ans = ans + a * (y - x)
		y = x
	if x == y:
		ans = ans + b * x
		x = 0
		y = 0
	if ans1 < ans:
		return ans1
	return ans
t = int(input())
for i in range(t):
	ans = solve()
	print(ans)


t = int(input())
for i in range(t):
	(x, y) = [int(p) for p in input().rstrip().split()]
	(a, b) = [int(p) for p in input().rstrip().split()]
	print(min(a * abs(x - y) + b * min(x, y), a * (x + y)))


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print((x + y) * a)
	else:
		amount = 0
		while x != 0 or y != 0:
			if x == y:
				if x > 0:
					y -= 1 * x
				if x < 0:
					y += 1 * x
				amount += x * b
				x = 0
			elif x > y:
				amount += a * (x - y)
				x = y
			else:
				amount += a * (y - x)
				y = x
		print(amount)


n1 = int(input())
for x in range(n1):
	n2 = input().split(' ')
	n3 = input().split(' ')
	x = int(n2[0])
	y = int(n2[1])
	a = int(n3[0])
	b = int(n3[1])
	print(min(b * min(x, y) + a * abs(x - y), a * (x + y)))


import sys
input = sys.stdin.readline
from collections import *
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b - 2 * a >= 0:
		print((x + y) * a)
	else:
		print(min(x, y) * b + (max(x, y) - min(x, y)) * a)


t = int(input())
for i in range(t):
	(x, y) = input().split()
	(a, b) = input().split()
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	(p, q) = (0, 0)
	if x > y:
		p = x - y
		q = y
	if x == y and x > 0:
		q = x
	if x < y:
		p = y - x
		q = x
	j = p * a + q * b
	k = (x + y) * a
	print(min(j, k))


t = int(input())
for i in range(t):
	ans = 0
	(x, y) = tuple(map(int, input().split()))
	(a, b) = tuple(map(int, input().split()))
	if x > y:
		(x, y) = (y, x)
	diff = y - x
	ans = ans + a * diff
	diff = x - 0
	ans = ans + min(b * diff, 2 * a * diff)
	print(ans)


def get_ans(x, y, a, b):
	if b / 2 <= a:
		if x > y:
			return a * (x - y) + b * y
		if x == y:
			return b * x
		else:
			return a * (y - x) + b * x
	else:
		return a * (x + y)
n = int(input())
lis = []
for i in range(n):
	(x, y) = [int(x) for x in input('').split()]
	(a, b) = [int(x) for x in input('').split()]
	lis.append(get_ans(x, y, a, b))
for i in lis:
	print(i)


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	k = max(x, y) - abs(x - y)
	b = min(b, a * 2)
	n = max(x, y) - k
	print(k * b + n * a)


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	(r, s) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	elif s <= 2 * r:
		print(min(x, y) * s + (max(x, y) - min(x, y)) * r)
	else:
		print((x + y) * r)


import math
n1 = int(input())
for i in range(n1):
	t = list(map(int, input().strip().split()))[:2]
	u = list(map(int, input().strip().split()))[:2]
	x = min(t[0], t[1])
	y = max(t[0], t[1])
	a = u[0]
	b = u[1]
	if x == 0 and y == 0:
		print(0)
	elif x == 0 and y > 0:
		print(y * a)
	elif x < 0 and y == 0:
		print(-x * a)
	elif x < 0 and y > 0:
		print((y - x) * a)
	elif x * y > 0:
		x = abs(x)
		y = abs(y)
		t1 = abs(x - y)
		min1 = min(x, y)
		if b < 2 * a:
			print(t1 * a + min1 * b)
		else:
			print((x + y) * a)


from posixpath import split

def pay1(x, y, a, b):
	big = 0
	small = 0
	if x > y:
		big = x
		small = y
	else:
		big = y
		small = x
	return (big - small) * a + small * b

def pay2(x, y, a, b):
	big = 0
	small = 0
	if x > y:
		big = x
		small = y
	else:
		big = y
		small = x
	return big * b + (big - small) * a

def pay3(x, y, a, b):
	return x * a + y * a
n = int(input())
ans = []
for i in range(n):
	(x, y) = [int(m) for m in input().split()]
	(a, b) = [int(m) for m in input().split()]
	ans.append(min(pay1(x, y, a, b), pay2(x, y, a, b), pay3(x, y, a, b)))
for i in ans:
	print(i)


from sys import stdin, stdout
for testcases in range(int(stdin.readline())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	elif x == 0 or y == 0:
		print(a * max(x, y))
	else:
		choice1 = (x + y) * a
		choice2 = a * (max(x, y) - min(x, y)) + b * min(x, y)
		print(min(choice1, choice2))


N = int(input())
while N > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = a * (abs(x) + abs(y))
	r = a * abs(x - y) + b * min(abs(x), abs(y))
	print(min(r, d))
	N -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	t = []
	if x == y == 0:
		print(0)
	else:
		z = abs(x - y)
		z = z * a
		l = min(x, y)
		l = l * b
		t.append(l + z)
		t.append(a * (x + y))
		print(min(t))


from sys import stdin, stdout
t = int(stdin.readline())
for _ in range(t):
	(x, y) = stdin.readline().split()
	x = int(x)
	y = int(y)
	(a, b) = stdin.readline().split()
	a = int(a)
	b = int(b)
	if 2 * a < b:
		b = 2 * a
	c = min(x, y)
	res = c * b + a * (x - c) + a * (y - c)
	print(res)


from sys import *
t = int(input())
for h in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	n = min(x, y)
	print(min(b, 2 * a) * n + a * abs(x - y))


results = []
T = int(input())
for case in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	dif = abs(x - y)
	best = int(b < 2 * a) * (dif * a + min(x, y) * b) + int(b >= 2 * a) * a * (x + y)
	results.append(best)
for result in results:
	print(result)


for _ in range(int(input())):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	cs1 = min(x, y) * b + abs(x - y) * a
	cs2 = (x + y) * a
	print(min(cs1, cs2))


t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	m = abs(min(x, y))
	c = abs(x - y) * a + b * m if b <= 2 * a else abs(x - y) * a + 2 * a * m
	print(c)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = 0
	l = 0
	l = min(x, y) * a + max(x, y) * a
	d = min(x, y) * b + abs(x - y) * a
	print(min(l, d))


t = int(input())
for i in range(t):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	minimum = min(x, y)
	maximum = max(x, y)
	if 2 * a > b:
		if maximum >= 0 and minimum >= 0:
			diff = maximum - minimum
			print(minimum * b + diff * a)
		elif maximum < 0 and minimum < 0:
			maximum = abs(maximum)
			minimum = abs(minimum)
			diff = minimum - maximum
			print(maximum * b + diff * a)
		elif maximum > 0 and minimum < 0:
			minimum = abs(minimum)
			print(maximum * a + minimum * a)
	else:
		maximum = abs(maximum)
		minimum = abs(minimum)
		print(maximum * a + minimum * a)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	flag = 0
	dollar = 0
	if a * 2 <= b:
		flag = 1
	if x == 0 and y == 0:
		dollar = 0
	elif x == 0 or y == 0:
		dollar = max(x, y) * a
	elif x == y and flag:
		dollar = a * x * 2
	elif x == y and (not flag):
		dollar = b * x
	elif flag:
		dollar = (max(x, y) - min(x, y)) * a + min(x, y) * 2 * a
	else:
		dollar = (max(x, y) - min(x, y)) * a + min(x, y) * b
	print(dollar)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

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

def array():
	return [int(i) for i in input().split()]
for _ in range(int(input())):
	(x, y) = value()
	(a, b) = value()
	ans1 = a * (x + y)
	k = min(x, y)
	ans2 = k * b
	x -= k
	y -= k
	ans2 += (x + y) * a
	print(min(ans1, ans2))


import math
for w in range(int(input())):
	(x, y) = list(map(int, input().split()))
	ent = list(map(int, input().split()))
	dif = abs(x - y)
	a = dif * ent[0]
	if x >= y:
		x -= dif
	else:
		y -= dif
	if x * 2 * ent[0] < x * ent[1]:
		a += x * 2 * ent[0]
	else:
		a += x * ent[1]
	print(a)


cases = int(input())
for i in range(cases):
	inp1 = input().split()
	x = int(inp1[0])
	y = int(inp1[1])
	inp2 = input().split()
	a = int(inp2[0])
	b = int(inp2[1])
	sol = 0
	minn = min(x, y)
	b_needed = minn
	a_needed = abs(x - y)
	if 2 * a > b:
		sol = a_needed * a + b_needed * b
	elif 2 * a <= b:
		sol = a_needed * a + b_needed * 2 * a
	print(sol)


for u in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = abs(x - y) * a + b * min(x, y)
	c = (x + y) * a
	print(min(s, c))


import sys
readline = sys.stdin.readline
print = lambda string: sys.stdout.write(str(string) + '\n')
n = int(readline())
for i in range(n):
	given = [int(x) for x in readline().split()]
	x = given[0]
	y = given[1]
	given = [int(x) for x in readline().split()]
	single = given[0]
	double = given[1]
	if double < single * 2 and abs(x - y) >= abs(x) - abs(y):
		print(min(x, y) * double + (max(x, y) - min(x, y)) * single)
	else:
		print((abs(x) + abs(y)) * single)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	else:
		calc = 0
		if x == 0 or y == 0:
			if y == 0:
				calc = x * a
			else:
				calc = y * a
			print(calc)
		else:
			if x < y:
				(x, y) = (y, x)
			calc1 = a * (x + y)
			calc2 = y * b + (x - y) * a
			if calc2 < calc1:
				print(calc2)
			else:
				print(calc1)


n = int(input())

def solve(x, y, a, b):
	cost = 0
	if b > 2 * a:
		cost = a * (x + y)
	else:
		cost = b * min(x, y) + a * abs(x - y)
	return cost
for _ in range(n):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(solve(x, y, a, b))


import math
import collections
from sys import *
t = int(stdin.readline())
for _ in range(t):
	(x, y) = list(map(int, stdin.readline().split()))
	(a, b) = list(map(int, stdin.readline().split()))
	mn = min(x, y)
	ans = abs(x - y) * a
	ans = ans + min(mn * b, 2 * a * mn)
	print(ans)


T = int(input())
for t in range(T):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if 2 * a <= b:
		print((abs(x) + abs(y)) * a)
		continue
	else:
		ans = min(x, y) * b
		(x, y) = (x - min(x, y), y - min(x, y))
		ans += max(x, y) * a
		print(ans)


from math import ceil, sqrt, floor
import sys
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print(a * (x + y))
	else:
		print(b * min(x, y) + a * abs(x - y))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		res = min((x + y) * a, x * b)
		print(res)
		continue
	res = min(x, y) * b
	res += abs(x - y) * a
	res2 = (x + y) * a
	print(min(res, res2))


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	count = min(x, y) * b + (max(x, y) - min(x, y)) * a
	cnt = (x + y) * a
	print(min(cnt, count))


n = int(input())
for v in range(n):
	(b, c) = map(int, input().split())
	(d, e) = map(int, input().split())
	if b == 0 and c == 0:
		print(0)
	elif b == c:
		if c * e > 2 * b * d:
			print(2 * b * d)
		else:
			print(c * e)
	elif b < c:
		if b * e > 2 * b * d:
			print((c - b) * d + 2 * b * d)
		else:
			print((c - b) * d + b * e)
	elif c * e > 2 * c * d:
		print((b - c) * d + 2 * c * d)
	else:
		print((b - c) * d + c * e)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if abs(x) < abs(y):
		(x, y) = (y, x)
	x2y = abs(x - y) * a + b * abs(y)
	xy20 = (abs(x) + abs(y)) * a
	print(min(x2y, xy20))


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(x, y) = MAP()
	(a, b) = MAP()
	if x > y:
		(x, y) = (y, x)
	ans = x * min(a * 2, b) + (y - x) * a
	print(ans)


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(x, y) = (a[0], a[1])
	k = max(x, y) - min(x, y)
	r = (x + y) * b[0]
	p = k * b[0] + min(x, y) * b[1]
	print(min(r, p))


from sys import stdin, exit
input = stdin.readline

def i():
	return input()

def ii():
	return int(input())

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

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

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	(x, y) = iis()
	(a, b) = iis()
	op = []
	op.append((abs(x) + abs(y)) * a)
	if b < a * 2:
		op.append(abs(x) * b + abs((y - x) * a))
		op.append(abs(y) * b + abs((x - y) * a))
		op.append(abs(x - y) * a + abs(min(abs(x), abs(y)) * b))
		op.append(abs(y - x) * a + abs(min(abs(x), abs(y)) * b))
	print(min(op))


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	small = min(x, y)
	large = max(x, y)
	if x == 0 and y == 0:
		print(0)
	else:
		c1 = x * a + y * a
		c2 = abs(x - y) * a + small * b
		c3 = small * b + (large - small) * a
		print(min(c1, min(c2, c3)))


t = int(input())
for i in range(t):
	ans = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	K = min(abs(x), abs(y))
	if abs(x) == abs(y):
		first = a * abs(x) * 2
		second = b * abs(x)
	elif abs(x) > abs(y):
		first = a * (abs(x) + abs(y))
		second = b * K + a * (abs(x) - K)
	elif abs(x) < abs(y):
		first = a * (abs(x) + abs(y))
		second = b * K + a * (abs(y) - K)
	print(min(first, second))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	if a * 2 <= b:
		print(a * (x + y))
	else:
		ans = x * b + (y - x) * a
		print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = a + a
	if x + y == 0:
		print(0)
		continue
	if s <= b:
		print(a * (x + y))
	else:
		if x >= y:
			print(b * y + (x - y) * a)
		if y > x:
			print(x * b + (y - x) * a)


t = int(input())
while t != 0:
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	p = max(x, y)
	q = min(x, y)
	s = min(q * b + (p - q) * a, (p + q) * a, p * b + (p - q) * a)
	print(s)
	t = t - 1


num = int(input())
ans = []
for i in range(num):
	(xx, yy) = input().split(' ')
	(aa, bb) = input().split(' ')
	(x, y, a, b) = (int(xx), int(yy), int(aa), int(bb))
	if a * 2 >= b:
		ans.append(a * abs(y - x) + b * min(abs(x), abs(y)))
	elif a * 2 < b:
		ans.append(a * (abs(x) + abs(y)))
for i in range(num):
	print(ans[i])


a = int(input())
for i in range(0, a):
	(b, c) = map(int, input().split())
	(d, e) = map(int, input().split())
	print(min(abs(b - c) * d + min(b, c) * e, abs(b - c) * d + min(b, c) * 2 * d))


for _ in range(int(input())):
	(k, j) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a >= b:
		if k > j:
			d = k - j
			s = d * a + b * j
		elif j > k:
			d = j - k
			s = d * a + b * k
		else:
			s = b * k
	elif k > j:
		d = k - j
		s = d * a + 2 * a * j
	elif j > k:
		d = j - k
		s = d * a + 2 * a * k
	else:
		s = a * 2 * k
	print(s)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	e = min(a, b)
	if 2 * c < d:
		print((a + b) * c)
	else:
		print(e * d + c * abs(a - b))


t = int(input())
t_arr = []
for _ in range(t):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	total = 0
	if b <= 2 * a:
		diff = abs(x - y)
		if diff > 0:
			total += a * diff
			if x > y:
				diff = x - diff
			else:
				diff = y - diff
			total += b * diff
		else:
			total = b * x
	else:
		diff = x + y
		total = diff * a
	t_arr.append(total)
for i in t_arr:
	print(i)


t = int(input())
p = t
while p > 0:
	(x, y) = input().split(' ')
	(x1, y1) = input().split(' ')
	x = int(x)
	y = int(y)
	x1 = int(x1)
	y1 = int(y1)
	q = x + y
	c1 = q * x1
	if x <= y:
		r = x
	else:
		r = y
	c2 = r * y1
	x = x - r
	y = y - r
	c2 = c2 + (x + y) * x1
	print(min(c1, c2))
	p = p - 1


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	min_val = abs(x + y) * a
	val = 0
	if x != y:
		val = abs(x - y) * a
		if x < y:
			y = x
		else:
			x = y
	val += x * b
	if val < min_val:
		min_val = val
	print(min_val)


def equal(x, a, b):
	if x == 0:
		return 0
	if a * 2 > b:
		return b * abs(x)
	else:
		return 2 * a * abs(x)
n = int(input())
for _ in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y == 0:
		print(0)
	elif x == y:
		z = equal(x, a, b)
		print(z)
	elif x * y >= 0:
		x = abs(x)
		y = abs(y)
		if x > y:
			z = equal(y, a, b)
			print(z + (x - y) * a)
		else:
			z = equal(x, a, b)
			print(z + (y - x) * a)
	else:
		print(abs(x - y) * a)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	if x < y:
		s = s + b * x
		d = y - x
		s = s + a * d
		q = 0
		d = x + y
		q = d * a
		f = min(s, q)
	elif x > y:
		s = s + b * y
		d = x - y
		s = s + a * d
		q = 0
		d = x + y
		q = d * a
		f = min(s, q)
	else:
		s = s + b * x
		q = 0
		d = x + y
		q = d * a
		f = min(s, q)
	print(f)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff = abs(x - y)
	t1 = (x + y) * a
	t2 = min(x, y) * b + diff * a
	ans = min(t1, t2)
	print(ans)


import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

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

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	(x, y) = MAP()
	(a, b) = MAP()
	sm = min(x, y)
	la = max(x, y)
	ans = min((x + y) * a, sm * b + (la - sm) * a)
	print(ans)
	t -= 1


from sys import stdin
from heapq import nsmallest
ip = stdin.readline
for _ in range(int(ip())):
	(x, y) = map(int, ip().split())
	(a, b) = map(int, ip().split())
	ans = 0
	if x > y:
		(x, y) = (y, x)
	if 2 * a < b:
		ans = a * (x + y)
	else:
		ans = b * x + a * (y - x)
	print(ans)


t = int(input())
while t:
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	ans = 0
	if b <= 2 * a:
		if x < y:
			small = x
		else:
			small = y
		x = x - small
		y = y - small
		ans += small * b
		if x == 0:
			ans += a * (y - 0)
		else:
			ans += a * (x - 0)
	else:
		ans += (x + y) * a
	print(ans)
	t -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = [int(x) for x in input().split()]
	p = max(x, y)
	q = min(x, y)
	X = b * q + (p - q) * a
	Y = a * q + a * p
	print(min(X, Y))


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	price = 0
	maxi = max(x, y)
	mini = min(x, y)
	ans = min((x + y) * a, mini * b + (maxi - mini) * a)
	print(ans)
	t -= 1


test_cases = int(input())
for case in range(test_cases):
	(x, y) = [int(s) for s in input().split()]
	(a, b) = [int(s) for s in input().split()]
	result = 0
	if b >= 2 * a:
		result = (abs(x) + abs(y)) * a
	else:
		for_a = abs(abs(x) - abs(y))
		result += for_a * a
		for_b = min(abs(x), abs(y))
		result += for_b * b
	print(result)


t = int(input())
for t1 in range(t):
	(x, y) = [int(n1) for n1 in input().split()]
	(a, b) = [int(n1) for n1 in input().split()]
	if 2 * a < b:
		print(x * a + y * a)
	else:
		print(abs(x - y) * a + b * min(x, y))


def min_cost(a, b, x, y):
	if x == 0 and y == 0:
		return 0
	elif x == y:
		cost_a = 2 * a * x
		cost_b = b * x
		return min(cost_a, cost_b)
	elif x == 0 and y > 0:
		return a * y
	elif x > 0 and y == 0:
		return a * x
	else:
		cost = 0
		if x > y:
			cost1 = 2 * y * a
			cost2 = y * b
			return min(cost1, cost2) + (x - y) * a
		else:
			cost1 = 2 * x * a
			cost2 = x * b
			return min(cost1, cost2) + (y - x) * a
test = int(input())
while test > 0:
	test -= 1
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	print(min_cost(a, b, x, y))


T = int(input())
for i in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if b > a and 2 * a < b:
		ans = x * a + y * a
	if b > a and 2 * a >= b:
		if x > y:
			ans = y * b + (x - y) * a
		elif y > x:
			ans = x * b + (y - x) * a
		else:
			ans = x * b
	if a >= b:
		if x > y:
			ans = y * b + (x - y) * a
		elif y > x:
			ans = x * b + (y - x) * a
		else:
			ans = x * b
	print(ans)


tll = int(input())
while tll > 0:
	tll -= 1
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	n = abs(x - y)
	s = min(x, y)
	t1 = max(x, y)
	ans1 = 0
	ans1 += n * a
	ans2 = ans1
	ans1 += s * b
	ans2 += a * (2 * s)
	print(min(ans1, ans2))


t = int(input())
for test in range(t):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if 2 * a <= b:
		print((x + y) * a)
	else:
		cost = 0
		(x, y) = (min(x, y), max(x, y))
		cost += b * x
		y -= x
		cost += y * a
		print(cost)


n = int(input())
for i in range(n):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	v = abs(x - y)
	v1 = min(x, y)
	print(min(v * a + v1 * b, a * (x + y)))


t = int(input().strip())
for _ in range(t):
	(x, y) = list(map(int, input().strip().split(' ')))
	(a, b) = list(map(int, input().strip().split(' ')))
	(x, y) = (abs(x), abs(y))
	if x > y:
		(x, y) = (y, x)
	if a * 2 < b:
		print(x * 2 * a + (y - x) * a)
	else:
		print(x * b + (y - x) * a)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
		continue
	dif = abs(x - y)
	min1 = min(x, y)
	mul = 2 * a
	if 2 * a > b:
		mul = b
	print(mul * min1 + dif * a)


t = int(input())
for _ in range(t):
	(x, y) = sorted([int(x) for x in input().split()])
	(a, b) = [int(x) for x in input().split()]
	count = 0
	count2 = 0
	c = y
	print(min(a * (x + y), b * x + a * (y - x)))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = min(x, y) * b
	d += (max(x, y) - min(x, y)) * a
	e = (x + y) * a
	f = max(x, y) * b
	f += (max(x, y) - min(x, y)) * a
	final = min(d, e)
	final = min(final, f)
	print(final)


import sys
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
ni = lambda : int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda : list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda : float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda : list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda : stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda : stdin.readline().split()

def sol(a, b, x, y):
	p = min(x, y) * b + (max(x, y) - min(x, y)) * a
	q = (x + y) * a
	print(min(p, q))
t = ni()
for i in range(t):
	(x, y) = na()
	(a, b) = na()
	sol(a, b, x, y)


import sys
input = sys.stdin.readline
output = sys.stdout

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def solve(x, y, a, b):
	if 2 * a <= b:
		res = (x + y) * a
	elif x == y:
		res = x * b
	elif x > y:
		res = y * b + (x - y) * a
	elif x < y:
		res = x * b + (y - x) * a
	print(res)
n = inp()
for i in range(n):
	my_list1 = inlt()
	my_list2 = inlt()
	a1 = my_list1[0]
	a2 = my_list1[1]
	b1 = my_list2[0]
	b2 = my_list2[1]
	solve(a1, a2, b1, b2)


for _ in range(int(input())):
	q = input().split()
	w = input().split()
	x = int(q[0])
	y = int(q[1])
	a = int(w[0])
	b = int(w[1])
	if x >= 0 and y >= 0:
		z = (max(x, y) - min(x, y)) * a
		if a * 2 >= b:
			z += min(x, y) * b
		else:
			z += min(x, y) * a * 2
	elif x < 0 and y < 0:
		z = (min(x, y) - max(x, y)) * a
		if a * 2 >= b:
			z += max(x, y) * b
		else:
			z += max(x, y) * a * 2
	else:
		z = x * a + y * a
	print(z)


def output(x, a):
	print('{0}: {1}'.format(x, a))

def solve():
	(x, y) = [int(x) for x in input().split(' ')]
	(a, b) = [int(x) for x in input().split(' ')]
	if 2 * a <= b:
		print('{0}'.format((x + y) * a))
	else:
		total = 0
		f = min(x, y)
		total = total + f * b
		total = total + (max(x, y) - f) * a
		print(total)
nums = int(input())
for _ in range(1, nums + 1):
	solve()


t = int(input())
for tt in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	r = (x + y) * a
	rs = min(x, y) * b + (max(x, y) - min(x, y)) * a
	print(min(r, rs))


for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if 2 * a < b:
		b = 2 * a
	z = max(x, y) - min(x, y)
	cost = z * a + b * min(x, y)
	print(cost)


def main():
	t = int(input())
	for __ in range(t):
		(a, b) = map(int, input().split())
		(x, y) = map(int, input().split())
		if a > b:
			(a, b) = (b, a)
		print(min(2 * a * x, a * y) + abs(a - b) * x)
main()


q = int(input())
h = []
for i in range(0, q):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	res = 0
	if x == 0 and y == 0:
		res = 0
	elif x > 0 and y > 0:
		m = min(x, y)
		res = min(x * a + y * a, m * b + abs(x - y) * a)
	elif x < 0 and y < 0:
		v = max(x, y)
		res = min(abs(x) * a + abs(y) * a, v * b + abs(x - y) * a)
	elif x > 0 and y < 0:
		res = x * a + abs(y) * a
	elif x < 0 and y > 0:
		res = y * a + abs(x) * a
	elif x == 0 and y > 0:
		res = y * a
	elif y == 0 and x > 0:
		res = x * a
	elif x == 0 and y < 0:
		res = abs(y) * a
	elif y == 0 and x < 0:
		res = abs(x) * a
	h.append(res)
print(*h, sep='\n')


t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if x == y == 0:
		res = 0
	elif y < 0 < x or x < 0 < y:
		res = (abs(x) + abs(y)) * a
	elif (x, y > 0) or (x, y < 0):
		z = a * abs(abs(x) - abs(y))
		c = min(abs(x), abs(y))
		if a < b / 2:
			res = z + c * 2 * a
		else:
			res = z + c * b
	print(res)


t = int(input())
for ooo in range(t):
	(x, y) = [int(aaa) for aaa in input().split()]
	(a, b) = [int(aaa) for aaa in input().split()]
	(x, y) = (max(x, y), min(x, y))
	if b <= 2 * a:
		print(y * b + a * (x - y))
	else:
		print((x + y) * a)


tim = int(input())
while tim:
	tim -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		(x, y) = (y, x)
	ans = a * (abs(x) + abs(y))
	if x > 0:
		ans = min(ans, b * x + a * (y - x))
	elif y < 0:
		(x, y) = (abs(y), abs(x))
		ans = min(ans, b * x + a * (y - x))
	print(ans)


T = int(input())
for i in range(T):
	xy = input().split(' ')
	x = int(xy[0])
	y = int(xy[1])
	ab = input().split(' ')
	a = int(ab[0])
	b = int(ab[1])
	ans = 0
	if 2 * a < b:
		ans = a * (x + y)
	else:
		ans = b * min(x, y) + a * (max(x, y) - min(x, y))
	print(ans)


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	x = L[0]
	y = L[1]
	ch = input()
	L = [int(i) for i in ch.split()]
	a = L[0]
	b = L[1]
	s = (max(x, y) - min(x, y)) * a
	s += min(x, y) * min(2 * a, b)
	print(s)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a == b:
		if x > y:
			ans = y * a + (x - y) * a
			print(ans)
		elif x < y:
			ans = x * a + (y - x) * a
			print(ans)
		else:
			ans = x * a
			print(ans)
	elif a > b:
		ans = min(x, y) * b + abs(x - y) * a
		print(ans)
	else:
		ans = x * a + y * a
		ans1 = min(x, y) * b + abs(x - y) * a
		print(min(ans, ans1))
	t = t - 1


from sys import stdin, stdout
t = int(stdin.readline().strip())
for T in range(t):
	(x, y) = [int(n) for n in stdin.readline().split()]
	(a, b) = [int(n) for n in stdin.readline().split()]
	s = min(a * abs(x - y) + b * min(x, y), a * x + a * y)
	print(s)


for p in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = (x + y) * a
	(m, n) = (max(x, y), min(x, y))
	d = n * b + (m - n) * a
	print(min(c, d))


test = int(input())
for tes in range(test):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < 0 and y > 0 or (y < 0 and x > 0):
		print(a + b)
		continue
	(x, y) = (abs(x), abs(y))
	s1 = (x + y) * a
	minxy = min(x, y)
	s2 = minxy * b + (y - minxy) * a + (x - minxy) * a
	print(min(s1, s2))


import sys
input = sys.stdin.buffer.readline

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

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	(x, y) = I()
	(a, b) = I()
	(x, y) = (max(x, y), min(x, y))
	print(min(y * b + a * (x - y), (y + x) * a))


test = int(input())
for t in range(test):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < y:
		(x, y) = (y, x)
	if 2 * a <= b:
		print((x + y) * a)
	else:
		print(y * b + (x - y) * a)


m = int(input())
while m != 0:
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(min((x + y) * a, abs(x - y) * a + min(x, y) * b))
	m = m - 1


mn = 1000000000000000000
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a < b:
		m = a * x + a * y
		if mn > m:
			mn = m
		m = b * min(x, y) + a * abs(x - y)
		if mn > m:
			mn = m
		print(mn)
		mn = 1000000000000000000
	elif a > b:
		m = b * min(x, y) + a * abs(x - y)
		if mn > m:
			mn = m
		print(mn)
		mn = 1000000000000000000
	elif a == b:
		m = b * min(x, y) + a * abs(x - y)
		if mn > m:
			mn = m
		print(mn)
		mn = 1000000000000000000


def roadtozero(x, y, a, b):
	res = 0
	if x > y:
		diff = x - y
		temp = x - diff
	else:
		diff = y - x
		temp = y - diff
	res = diff * a + temp * b
	res1 = (x + y) * a
	if res > res1:
		return res1
	else:
		return res
t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(roadtozero(x, y, a, b))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res = (x + y) * a
	if x == y:
		r = x * b
		if r < res:
			res = r
	else:
		diff = abs(x - y)
		r = a * diff
		m = min(x, y)
		r += m * b
		if r < res:
			res = r
	print(res)


T = int(input())
for tc in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a < b / 2:
		res = (x + y) * a
	else:
		res = min(x, y) * b + abs(x - y) * a
	print(res)


test_cases = int(input())
for test_case in range(test_cases):
	(x, y) = [int(inp) for inp in input().split()]
	(a, b) = [int(inp) for inp in input().split()]
	(x, y) = (max(x, y), min(x, y))
	if 2 * a <= b:
		print((x + y) * a)
	else:
		print((x - y) * a + y * b)


import sys
t = int(input())
for q in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if b > 2 * a:
		ans = (abs(x) + abs(y)) * a
	else:
		if x < 0 and y > 0 or (x > 0 and x < 0):
			ans = (abs(x) + abs(y)) * a
		ans = abs(x - y) * a + min(abs(x), abs(y)) * b
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	count = 0
	count1 = 0
	count2 = 0
	if x == 0 and y == 0:
		count = 0
	else:
		count += a * abs(x - y)
		count2 += b * min(x, y)
		count1 += a * min(x, y) * 2
		if count2 > count1:
			count += count1
		else:
			count += count2
	print(count)


import os

def f(x, y, a, b):
	if 2 * a <= b or x * y <= 0:
		return (abs(x) + abs(y)) * a
	else:
		x = abs(x)
		y = abs(y)
		m = min(x, y)
		M = max(x, y)
		return m * b + (M - m) * a

def pp(input):
	n_test = int(input())
	for i in range(n_test):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		print(f(x, y, a, b))
if 'paalto' in os.getcwd():
	from string_source import string_source
	pp(string_source('7\n1 3\n391 555\n0 0\n9 4\n-1 0\n1 100\n-5 0\n1 100\n4 4\n1 100\n4 4\n100 1\n4 5\n100 1\n'))
else:
	pp(input)


import collections, heapq, itertools, math, functools
groupby = itertools.groupby
rs = lambda : input()
ri = lambda : int(input())
rm = lambda : map(int, input().split())
rai = lambda : [int(x) for x in input().split()]

def solve():
	dif = abs(x - y)
	gap = min(abs(x), abs(y))
	if b <= 2 * a:
		return gap * b + dif * a
	else:
		return gap * 2 * a + dif * a
for t in range(ri()):
	(x, y) = rm()
	(a, b) = rm()
	print(solve())


from sys import stdin

def list_int():
	s = stdin.readline()[:-1]
	return list(map(int, s.split()))

def list_float():
	s = stdin.readline()[:-1]
	return list(map(float, s.split()))

def list_str():
	s = stdin.readline()[:-1]
	return list(s.split())

def space_int():
	s = stdin.readline()[:-1]
	return map(int, s.split())

def space_float():
	s = stdin.readline()[:-1]
	return map(float, s.split())

def space_str():
	s = stdin.readline()[:-1]
	return s.split()

def _int():
	s = stdin.readline()[:-1]
	return int(s)

def _str():
	s = stdin.readline()[:-1]
	return s

def _float():
	s = stdin.readline()[:-1]
	return float(s)

def _gcd(a, b):
	if a == 0:
		return b
	return _gcd(b % a, a)

def _sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	return prime
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
maxi = -2 ** 32
mini = 2 ** 32
mod = 10 ** 9 + 7
for _ in range(int(input())):
	(x, y) = space_int()
	(a, b) = space_int()
	if x > 0 and y > 0 or (x < 0 and y < 0):
		c1 = min(x, y)
		c2 = max(x, y)
		ans1 = b * c1 + a * (c2 - c1)
		ans2 = a * (abs(x) + abs(y))
	else:
		ans1 = a * (abs(x) + abs(y))
		ans2 = ans1
	print(min(ans1, ans2))


def proba(x, y, a, b):
	if x == 0 and y == 0:
		return 0
	if x < y:
		min = x
		max = y
	else:
		min = y
		max = x
	sum = 0
	if 2 * a < b:
		sum += 2 * min * a
	else:
		sum += min * b
	sum += (max - min) * a
	return sum
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(proba(x, y, a, b))


t = int(input())
for _ in range(t):
	(x, y) = [int(v) for v in input().split(' ')]
	(a, b) = [int(v) for v in input().split(' ')]
	if x < y:
		(x, y) = (y, x)
	n = (x - y) * a
	n += min(2 * a, b) * y
	print(n)


import sys

def I():
	return sys.stdin.readline().rstrip()
for _ in range(int(I())):
	(x, y) = map(int, I().split())
	(a, b) = map(int, I().split())
	b = min(b, a + a)
	print(min(x, y) * b + a * (max(x, y) - min(x, y)))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	z = min(x, y)
	q = abs(x - y)
	w = a * q + z * b
	e = a * q + z * a * 2
	print(min(w, e))


from math import *
nbtest = int(input())
for i in range(nbtest):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	if x * y < 0:
		print(a * (x + y))
	else:
		print(min(min(abs(x), abs(y)) * b + a * abs(y - x), (x + y) * a))


n = int(input())
for i in range(n):
	r = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a > b:
		r = min(x, y) * b + (max(x, y) - min(x, y)) * a
	else:
		r = x * a + y * a
	print(r)


import math
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, a + a)
	if x < y:
		(x, y) = (y, x)
	print(y * b + (x - y) * a)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt

def solve():
	(x, y) = read()
	(a, b) = read()
	if x == 0 and y == 0:
		print(0)
		return
	s = 0
	s += abs(x - y) * a
	x = y = min(x, y)
	s += min(2 * x * a, x * b)
	print(s)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


t = int(input())
ans = []
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = 0
	if x == 0 and y == 0:
		ans.append(m)
	else:
		p = max(x, y)
		q = min(x, y)
		m = (p - q) * a
		m = m + min((q - 0) * b, 2 * (q - 0) * a)
		ans.append(m)
for i in ans:
	print(i)


def solve(a, b, x, y):
	if x == y:
		if x == 0:
			return 0
		return min(b * x, a * x * 2)
	elif x > y:
		ans = (x - y) * a + y * b
		ans = min(ans, a * x + a * y)
		return ans
	else:
		ans = (y - x) * a + x * b
		ans = min(ans, a * x + a * y)
		return ans
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(solve(a, b, x, y))


t = int(input())
for i in range(t):
	(a, b) = list(map(int, input().split()))
	(c, d) = list(map(int, input().split()))
	g = [a, b]
	g.sort()
	(a, b) = g
	ans = 0
	if 2 * c < d:
		ans = (a + b) * c
		print(ans)
	else:
		ans += a * d
		ans += (b - a) * c
		print(ans)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	money = 0
	(x, y) = map(int, sys.stdin.readline().split())
	(a, b) = map(int, sys.stdin.readline().split())
	if x == 0 or y == 0:
		if x == 0 and y != 0:
			money += a * y
		if y == 0 and x != 0:
			money += a * x
	elif 2 * a >= b:
		money += b * min(x, y)
		if x < y:
			money += a * (y - x)
		if y < x:
			money += a * (x - y)
	else:
		money += 2 * a * min(x, y)
		if x < y:
			money += a * (y - x)
		if y < x:
			money += a * (x - y)
	print(money)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(x, y) = map(int, sys.stdin.readline().split())
	(a, b) = map(int, sys.stdin.readline().split())
	if 2 * a < b:
		b = 2 * a
	answ = b * min(x, y)
	m = min(x, y)
	answ += a * (x + y - 2 * m)
	print(answ)


t = int(input())
cnt = 0
su = 0
r = []
q = []
x = []

def init(a):
	for p in range(len(a)):
		a[p] = int(a[p])
	return a
for i in range(t):
	d = input().split()
	p = input().split()
	d = init(d)
	p = init(p)
	x = int(max(d))
	y = int(min(d))
	a = p[0]
	b = p[1]
	if 2 * a <= b:
		print((x + y) * a)
	elif 2 * a > b:
		print(y * b + (x - y) * a)


lst = []
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, a + a)
	if x < y:
		(x, y) = (y, x)
	lst.append(y * b + (x - y) * a)
for i in lst:
	print(i)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mx = max(x, y)
	mn = min(x, y)
	s1 = mn * b + (mx - mn) * a
	s2 = (x + y) * a
	s3 = mx * b + (mx - mn) * a
	print(min(s1, s2, s3))


t = int(input())
for t1 in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	allByOne = a * (abs(x) + abs(y))
	minDif = min(abs(x), abs(y))
	mixed = minDif * b + (max(abs(x), abs(y)) - minDif) * a
	print(min(allByOne, mixed))


t = int(input())
for i in range(t):
	l1 = str.split(input(), ' ')
	l2 = str.split(input(), ' ')
	x = int(l1[0])
	y = int(l1[1])
	a = int(l2[0])
	b = int(l2[1])
	if b >= 2 * a:
		ans = abs(x)
		ans = abs(y) + ans
		ans = ans * a
		print(ans)
	elif a > 0 and b < 0 or (a < 0 and b > 0):
		ans = abs(x)
		ans = abs(y) + ans
		ans = ans * a
		print(ans)
	else:
		x = abs(x)
		y = abs(y)
		if x > y:
			ans = y * b
			x = x - y
			ans = ans + x * a
			print(ans)
		else:
			ans = x * b
			y = y - x
			ans = ans + y * a
			print(ans)


import os
T = int(input())
for times in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y and x == 0:
		print(0)
	elif a * 2 < b:
		print((abs(x) + abs(y)) * a)
	elif x * y > 0:
		little = min(abs(x), abs(y))
		ans = little * b + (max(abs(x), abs(y)) - little) * a
		print(ans)
	else:
		ans = (abs(x) + abs(y)) * a
		print(ans)


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	if 2 * c <= d:
		print(abs(a) * c + abs(b) * c)
	elif a == 0 and b == 0:
		print('0')
	elif a > 0 and b > 0:
		if a > b:
			x = a - b
			print(d * b + c * x)
		else:
			x = b - a
			print(d * a + c * x)
	elif a < 0 and b < 0:
		if a > b:
			x = a - b
			print(d * b + c * x)
		else:
			x = b - a
			print(d * a + c * x)
	else:
		print(abs(a) * c + abs(b) * c)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 1 and y == 0:
		print(a)
	elif y == 1 and x == 0:
		print(a)
	elif x == 0 and y == 0:
		print(0)
	elif 2 * a < b:
		temp = a * (x + y)
		print(temp)
	else:
		if x > y:
			s = y * b
			s = s + (x - y) * a
		else:
			s = x * b
			s = s + (y - x) * a
		print(s)


def roadTo0(nums, money):
	(x, y) = sorted(nums)
	(a, b) = money
	if a * 2 < b:
		return (x + y) * a
	return x * b + (y - x) * a
testCases = int(input())
nums = []
money = []
for a in range(testCases):
	nums.append(input().split())
	money.append(input().split())
nums = [list(map(int, a)) for a in nums]
money = [list(map(int, a)) for a in money]
for idx in range(len(nums)):
	print(roadTo0(nums[idx], money[idx]))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	num1 = abs(x - y) * a + min(x, y) * b
	num2 = abs(x - y) * a + 2 * min(x, y) * a
	print(min(num1, num2))


t = int(input(''))
for u in range(t):
	list = []
	(x, y) = map(int, input('').split(' '))
	(a, b) = map(int, input('').split(' '))
	if x > y:
		v = x - y
		r = y * b + v * a
		list.append(r)
		list.append(a * x + y * a)
	elif x < y:
		v = y - x
		r = x * b + v * a
		list.append(r)
		list.append(x * a + y * a)
	else:
		list.append(x * a + y * a)
		list.append(x * b)
	print(min(list))


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	p1 = a * x + a * y
	p2 = min(x, y) * b + abs(x - y) * a
	print(min(p1, p2))


t = int(input())
for ds in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	q = 0
	if y > 0 and x > 0:
		q = min(x, y) * min(b, a * 2)
		s = min(x, y)
		x -= s
		y -= s
	if y < 0 and x < 0:
		q = max(x, y) * min(b, a * 2)
		s = max(x, y)
		x -= s
		y -= s
	if x * y < 0:
		q = (abs(x) + abs(y)) * a
	if x == 0:
		q += abs(y) * a
	if y == 0:
		q += abs(x) * a
	print(q)


def dollar(x, y, a, b):
	if y > x:
		(x, y) = (y, x)
	d = x - y
	count = d * a
	if 2 * a < b:
		count += 2 * a * y
	else:
		count += b * y
	return count
t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(dollar(x, y, a, b))


j = int(input())
while j > 0:
	xy = input().split(' ')
	modifiers = input().split(' ')
	if (int(xy[0]) + int(xy[1])) * int(modifiers[0]) < abs(int(xy[0]) - int(xy[1])) * int(modifiers[0]) + min(int(xy[0]), int(xy[1])) * int(modifiers[1]):
		print((int(xy[0]) + int(xy[1])) * int(modifiers[0]))
	else:
		print(abs(int(xy[0]) - int(xy[1])) * int(modifiers[0]) + min(int(xy[0]), int(xy[1])) * int(modifiers[1]))
	j -= 1


t = int(input())
while t > 0:
	t = t - 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if min(x, y) >= 0:
		print(abs(x - y) * a + min(2 * a * min(x, y), min(x, y) * b))
	elif max(x, y) == 0:
		print(0)


import sys
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(x, y) = ilele()
	(a, b) = ilele()
	if x == 0 and y == 0:
		print(0)
	else:
		Ans = 0
		if 2 * a >= b:
			z = max(x, y)
			zz = min(x, y)
			Ans += b * zz
			z -= zz
			Ans += a * z
		else:
			Ans = a * (x + y)
		print(Ans)


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	s1 = 0
	s2 = 0
	if abs(abs(b) - abs(a)) > 0:
		s1 += abs(abs(b) - abs(a)) * c
	if abs(a) >= abs(b):
		s1 += abs(b) * d
	if abs(b) > abs(a):
		s1 += abs(a) * d
	s2 = (abs(b) + abs(a)) * c
	print(min(s1, s2))


def cost(x, y, a, b):
	if x < y:
		temp = x
		x = y
		y = temp
	if 2 * a <= b:
		return (x + y) * a
	else:
		return y * b + (x - y) * a
x = int(input())
m = []
for i in range(x):
	y = input()
	z = input()
	w = y + ' ' + z
	u = w.split(' ')
	u1 = [int(t) for t in u]
	m.append(u1)
for j in range(x):
	print(cost(m[j][0], m[j][1], m[j][2], m[j][3]))


a = int(input())
for _ in range(a):
	(x, y) = map(int, input().split())
	(v, b) = map(int, input().split())
	cou = 0
	cou1 = (x + y) * v
	mi = abs(min(x, y))
	su = abs(max(x, y) - min(x, y))
	cou = mi * b + su * v
	print(min(cou1, cou))


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mini = min(x, y)
	maxi = max(x, y)
	if 2 * mini * a < mini * b:
		ans = 2 * mini * a
	else:
		ans = mini * b
	ans += (maxi - mini) * a
	print(ans)


from sys import stdin, stdout

def find(K, N, A, B):
	(a, b) = sorted([N, K])
	if a < 0 and b > 0:
		return A * (a + b)
	else:
		return min(B * a + A * (b - a), A * (a + b))

def main():
	for _ in range(int(stdin.readline())):
		(N, K) = list(map(int, stdin.readline().split()))
		(A, B) = list(map(int, stdin.readline().split()))
		print(find(K, N, A, B))
main()


t = int(input())
for i in range(t):
	xy = list(map(int, input().split()))
	x = xy[0]
	y = xy[1]
	ab = list(map(int, input().split()))
	a = ab[0]
	b = ab[1]
	cost = 0
	if x > y:
		(x, y) = (y, x)
	cost += a * (y - x)
	if 2 * a > b:
		cost += b * x
	else:
		cost += 2 * a * x
	print(cost)


a = int(input())
for i in range(0, a):
	(b, c) = map(int, input().split())
	(d, e) = map(int, input().split())
	ans = 0
	ans2 = 0
	ans += min(b, c) * e
	e = max(b, c) - min(b, c)
	ans += e * d
	ans2 += (b + c) * d
	print(min(ans, ans2))


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7

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

def main():
	T = int(input())
	for i in range(T):
		(x, y) = sorted(getlist())
		(a, b) = getlist()
		if a * 2 <= b:
			ans = a * (abs(x) + abs(y))
			print(ans)
		else:
			ans = x * b + (y - x) * a
			print(ans)
main()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(first, second) = map(int, input().split())
	if x > y:
		get = (x, y)
		(y, x) = get
	print(min((x + y) * first, x * second + (y - x) * first))


t = int(input())
for i in range(t):
	(x, y) = [int(k) for k in input().split()]
	(a, b) = [int(k) for k in input().split()]
	dob = min(x, y)
	sin = max(x, y) - dob
	if 2 * a >= b:
		print(dob * b + sin * a)
	else:
		print(dob * (2 * a) + sin * a)


import io
import os
from collections import Counter, defaultdict, deque

def solve(X, Y, A, B):
	if 2 * A < B:
		return A * (X + Y)
	return min(X, Y) * B + abs(X - Y) * A
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(X, Y) = [int(x) for x in input().split()]
	(A, B) = [int(x) for x in input().split()]
	ans = solve(X, Y, A, B)
	print(ans)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(x, y) = (abs(x), abs(y))
	total2 = 0
	total1 = a * (x + y)
	total2 += b * min(x, y)
	total2 += a * abs(x - y)
	print(min(total1, total2))


from sys import stdin
t = int(stdin.readline())
for z in range(t):
	(x, y) = map(int, stdin.readline().strip().split())
	(a, b) = map(int, stdin.readline().strip().split())
	d1 = max(x, y) - min(x, y)
	a1 = d1 * a
	sol1 = min(x, y) * b
	sol2 = 2 * min(x, y) * a
	ans = min(sol2, sol1)
	print(ans + a1)


from sys import stdin, stdout
import math, collections
mod = 998244353
for _ in range(int(stdin.readline())):
	(x, y) = sorted(map(int, stdin.readline().split()))
	(a, b) = map(int, stdin.readline().split())
	if 2 * a < b:
		stdout.write(str((x + y) * a) + '\n')
	else:
		stdout.write(str((y - x) * a + x * b) + '\n')


from sys import stdin
input = stdin.readline
import bisect
import math
for xoxo in range(1):
	for _ in range(int(input())):
		ans = 0
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		if a * 2 > b:
			ans += min(x, y) * b
		else:
			ans += min(x, y) * 2 * a
		ans += a * abs(x - y)
		print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = map(int, input().split())
	tamt = 0
	if 2 * a < b:
		b = 2 * a
	if n > 0 and m > 0:
		min1 = min(n, m)
		max1 = max(n, m)
		single = max1 - min1
		tamt += min1 * b
		tamt += single * a
	elif n < 0 and m < 0:
		min1 = min(n, m)
		max1 = max(n, m)
		single = max1 - min1
		tamt += abs(max1) * b
		tamt += single * a
	else:
		tamt += abs(min(n, m)) * a
		tamt += abs(max(n, m)) * a
	print(tamt)


t = int(input())
while t:
	(x, y) = map(int, input().rstrip().split())
	(a, b) = map(int, input().rstrip().split())
	if y > x:
		(x, y) = (y, x)
	ans = (x - y) * a
	ans += min(2 * y * a, y * b)
	print(ans)
	t -= 1


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
		continue
	elif x == 0 and y != 0:
		print(a * y)
	elif y == 0 and x != 0:
		print(a * x)
	elif x == y:
		r1 = a * (x + y)
		r2 = b * x
		print(min(r1, r2))
	elif x > y:
		ans = (x - y) * a
		r1 = a * 2 * y
		r2 = b * y
		ans += min(r1, r2)
		print(ans)
	elif x < y:
		ans = (y - x) * a
		r1 = a * 2 * x
		r2 = b * x
		ans += min(r1, r2)
		print(ans)


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

def linp():
	x = [int(i) for i in input().split()]
	return x
T = inp()
ans = []
for t in range(T):
	(x, y) = linp()
	(a, b) = linp()
	if x < y:
		(x, y) = (y, x)
	d = abs(x - y)
	if abs(y) * b + d * a <= (abs(x) + abs(y)) * a:
		ans.append(abs(y) * b + d * a)
	else:
		ans.append((abs(x) + abs(y)) * a)
for a in ans:
	print(a)


t = int(input())
while t > 0:
	t -= 1
	xy = input().split()
	x = int(xy[0])
	y = int(xy[1])
	ab = input().split()
	(a, b) = (int(ab[0]), int(ab[1]))
	(x, y) = (min(x, y), max(x, y))
	doller = 0
	while y != 0:
		if x == 0:
			doller += y * a
			y = 0
		else:
			dx = min(2 * a, b)
			y -= x
			doller += dx * x
			x = 0
	print(doller)


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = I()
for _ in range(n):
	(x, y) = M()
	(a, b) = M()
	ans = 0
	ans2 = 0
	ans += min(x, y) * b
	ans += a * (max(x, y) - min(x, y))
	ans2 += a * (x + y)
	print(min(ans2, ans))


for t in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	ans = b * m
	ans += (x - m) * a + (y - m) * a
	c = x * a + y * a
	print(min(c, ans))


from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for t in range(test):
		l = [int(i) for i in input().split(' ')]
		x = l[0]
		y = l[1]
		l = [int(i) for i in input().split(' ')]
		a = l[0]
		b = l[1]
		count = 0
		if 2 * a <= b:
			count += a * (x + y)
		elif x > y:
			count += b * y + a * (x - y)
		else:
			count += b * x + a * (y - x)
		print(count)
main()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	s = s + a * abs(x - y)
	p = b * (max(x, y) - abs(x - y))
	q = a * (max(x, y) - abs(x - y)) * 2
	s = s + min(p, q)
	print(s)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	m = max(x, y)
	m1 = min(x, y)
	z = m - m1
	print(z * a + min(m1 * b, 2 * m1 * a))


for _ in range(int(input())):
	(x, y) = sorted([int(i) for i in input().split()])
	(a, b) = [int(i) for i in input().split()]
	if a * 2 < b:
		b = a * 2
	print(a * (y - x) + b * x)


T = int(input())
for _ in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	mi = min(x, y)
	ma = max(x, y)
	ans = 0
	if 2 * a < b:
		ans = 2 * a * mi + (ma - mi) * a
	else:
		ans = b * mi + (ma - mi) * a
	print(ans)


t = int(input())
for tc in range(t):
	s = input().split()
	(x, y) = (int(s[0]), int(s[1]))
	s1 = input().split()
	(a, b) = (int(s1[0]), int(s1[1]))
	if x == 0 and y == 0:
		print(0)
	elif b <= 2 * a:
		print(min(x, y) * b + abs(y - x) * a)
	else:
		print((x + y) * a)


def f1():
	t = int(input())
	while t != 0:
		t = t - 1
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		s = x
		l = y
		if x > y:
			s = y
			l = x
		ans = 0
		if 2 * a < b:
			ans = ans + s * 2 * a
			l = l - s
			s = 0
		else:
			ans = ans + s * b
			l = l - s
			s = 0
		ans = ans + l * a
		print(ans)
f1()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s = 0
	m = min(2 * a, b)
	p = min(x, y)
	n = max(x, y)
	s += min(x, y) * m
	s += (n - p) * a
	print(s)


def sol():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a < b:
		return (x + y) * a
	return abs(x - y) * a + min(x, y) * b
t = int(input())
for _ in range(t):
	print(sol())


t = int(input())
v = []
amt = []
temp = []
res = []
for i in range(t):
	temp = list(map(int, input().split()))
	v.append(temp)
	temp = list(map(int, input().split()))
	amt.append(temp)
for i in range(t):
	a = v[i][0] + v[i][1]
	a = a * amt[i][0]
	d = min(v[i])
	b = d * amt[i][1]
	d = max(v[i]) - min(v[i])
	b += d * amt[i][0]
	if a > b:
		res.append(b)
	else:
		res.append(a)
for i in res:
	print(i)


cases = int(input())
for i in range(cases):
	line1 = input().split(' ')
	x = int(line1[0])
	y = int(line1[1])
	line2 = input().split(' ')
	a = int(line2[0])
	b = int(line2[1])
	use = 0
	mi = min(x, y)
	ma = max(x, y)
	use += mi * b
	use += (ma - mi) * a
	use2 = 0
	diff = ma - mi
	use2 += diff * a
	use2 += mi * b
	use3 = (x + y) * a
	print(min(use, use2, use3))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res = 0
	if not (x == 0 and y == 0):
		r1 = a * (abs(x) + abs(y))
		r2 = b * min(abs(x), abs(y)) + a * abs(x - y)
		res = min(r1, r2)
	print(res)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	z = abs(x - y)
	q = z * a
	q1 = min(x, y) * min(2 * a, b)
	print(q + q1)


def main():
	n = int(input())
	while n:
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		btimes = b * min(x, y)
		atimes = a * (max(x, y) - min(x, y))
		if atimes + btimes < a * (x + y):
			print(atimes + btimes)
		else:
			print(a * (x + y))
		n -= 1
main()


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a <= b:
		print(a * (abs(x) + abs(y)))
	elif 2 * a > b:
		if x >= 0 and y >= 0:
			z = min(x, y)
			u = x + y - z - z
			print(z * b + u * a)
		elif x <= 0 and y <= 0:
			z = abs(max(x, y))
			u = abs(x + y + z + z)
			print(z * b + u * a)
		elif x < 0 and y > 0:
			print(a * (y - x))
		elif x > 0 and y < 0:
			print(a * (x - y))


t = int(input())
while t != 0:
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	b = min(b, 2 * a)
	print(abs(x - y) * a + min(abs(x), abs(y)) * b)
	t -= 1


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans1 = (max(x, y) - min(x, y)) * a + b * min(x, y)
	ans2 = (x + y) * a
	print(min(ans1, ans2))
	t -= 1


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a < b:
		if x != y:
			z = min(x, y)
			if z == x:
				q = 2 * z * a
				y = y - x
				q = q + y * a
			else:
				q = 2 * z * a
				x = x - y
				q = q + x * a
		else:
			q = 2 * x * a
	elif x != y:
		z = min(x, y)
		if z == x:
			q = z * b
			y = y - x
			q = q + y * a
		else:
			q = z * b
			x = x - y
			q = q + x * a
	else:
		q = x * b
	print(q)


t = int(input())
while t != 0:
	t -= 1
	(x, y) = input().split()
	(a, b) = input().split()
	x = int(x)
	y = int(y)
	a = int(a)
	b = int(b)
	type(a)
	sum = 0
	z = min(x, y)
	if 2 * a > b:
		sum += b * z
		x -= z
		y -= z
	else:
		sum += 2 * a * z
		x -= z
		y -= z
	if x > 0:
		sum += x * a
	elif y > 0:
		sum += y * a
	print(sum)


def min(a, b):
	if a >= b:
		return b
	return a
t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	op1 = 100000000000000000000000000000000000
	op2 = 1000000000000000000000000000000000000
	op3 = 0
	if x < 0 and y < 0 or (x > 0 and y > 0):
		if x < 0:
			x = x * -1
		if y < 0:
			y = y * -1
		op1 = x - y
		if op1 < 0:
			op1 *= -1
		op1 *= a
		op2 = min(x, y) * b
	if x < 0:
		x = x * -1
	if y < 0:
		y = y * -1
	op3 = x * a + y * a
	r = min(op1 + op2, op3)
	print(r)
	t -= 1


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().strip().split())
	(a, b) = map(int, input().strip().split())
	cost = 0
	if x == 0 and y == 0:
		cost = 0
	if b >= 2 * a:
		cost = a * (x + y)
	if b < 2 * a:
		cost = abs(x - y) * a + min(x, y) * b
	print(cost)


t = int(input())
while t:
	(x, y) = map(int, input().rstrip().split(' '))
	(a, b) = map(int, input().rstrip().split(' '))
	z = abs(x - y)
	try_1 = a * x + a * y
	try_2 = b * (max(x, y) - z) + z * a
	print(min(try_1, try_2))
	t = t - 1


def roadzero(a, b, ca, cb):
	cost = 0
	if a > b:
		(a, b) = (b, a)
	cost += ca * (b - a)
	if 2 * ca < cb:
		cost += a * (2 * ca)
	else:
		cost += a * cb
	return cost
test = int(input())
for i in range(test):
	(a, b) = map(int, input().split())
	(costa, costb) = map(int, input().split())
	print(roadzero(a, b, costa, costb))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	n_a = 2 * a
	cost = min(n_a, b) * min(x, y)
	cost += a * (max(x, y) - min(x, y))
	print(cost)


I = input
pr = print

def main():
	for _ in range(int(I())):
		(x, y) = map(int, I().split())
		(a, b) = map(int, I().split())
		if x < y:
			(x, y) = (y, x)
		b = min(b, 2 * a)
		pr(y * b + (x - y) * a)
main()


I = lambda : map(int, input().split())
for _ in range(int(input())):
	(x, y) = I()
	(a, b) = I()
	print(a * abs(x - y) + min(2 * a, b) * min(x, y))


def game(x, y, a, b):
	if b >= 2 * a:
		return (abs(x) + abs(y)) * a
	if x >= 0 and y >= 0:
		return abs(x - y) * a + min(x, y) * b
	elif x <= 0 and y <= 0:
		return abs(x - y) * a + abs(max(x, y)) * b
	else:
		return (abs(x) + abs(y)) * A
for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(game(x, y, a, b))


number = int(input())
for i in range(number):
	inputString = input()
	(x, y) = list(map(int, inputString.split(' ')))
	inputString = input()
	(a, b) = list(map(int, inputString.split(' ')))
	delta = 0
	minXY = 0
	if x > y:
		delta = x - y
		minXY = y
	else:
		delta = y - x
		minXY = x
	costTogether = delta * a + minXY * b
	costAOnly = (x + y) * a
	if costTogether > costAOnly:
		print(costAOnly)
	else:
		print(costTogether)


t = int(input())
for p in range(0, t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	chota = min(x, y)
	bada = max(x, y)
	ans1 = b * chota
	temp = bada - chota
	ans1 += temp * a
	ans2 = a * (chota + bada)
	print(min(ans1, ans2))


test_case = int(input())
list = []
d = False
for attempts in range(test_case):
	times1 = 0
	times2 = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b <= 2 * a:
		while x > 0 and y > 0:
			d = True
			small = min(x, y)
			x -= small
			y -= small
			times1 = small
		if x > 0:
			times2 += x
		if y > 0:
			times2 += y
	else:
		times2 += x + y
	g = a * times2 + b * times1
	list.append(g)
for items in list:
	print(items)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	result = 0
	if x == 0 and y == 0:
		result = 0
	elif x == y:
		result = min(x * a * 2, x * b)
	else:
		menor = min(x, y)
		result += min(menor * 2 * a, menor * b)
		result += abs(x - y) * a
	print(result)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	z = min(x, y)
	tot = z * min(2 * a, b)
	tot1 = (max(x, y) - z) * a
	print(tot + tot1)


t = int(input())
res = ''
for x in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	s1 = abs(x - y) * a + min(x, y) * b
	s2 = (x + y) * a
	res += str(min(s1, s2)) + '\n'
print(res)


porn_collection = int(input())
for _ in range(porn_collection):
	(n, k) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b >= a * (1 + 1):
		print(abs(n) * a + abs(k) * a)
	elif n < 0 and k > 0 or (n > 0 and k < 0):
		print(abs(n - 0) * a + (k - 0) * a)
	else:
		print(abs(n - k) * a + abs(min(abs(n), abs(k))) * b)


for case in range(int(input())):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	x = abs(x)
	y = abs(y)
	(larger, smaller) = (None, None)
	if x > y:
		larger = x
		smaller = y
	elif x < y:
		larger = y
		smaller = x
	else:
		larger = x
		smaller = y
	answer = (larger - smaller) * a + smaller * b
	answer2 = (larger + smaller) * a
	listAnswers = [answer, answer2]
	print(min(listAnswers))


def solve(x, y, a, b):
	if b >= a * 2:
		return (x + y) * a
	else:
		return min(x, y) * b + (max(x, y) - min(x, y)) * a
[print(solve(*map(int, input().split()), *map(int, input().split()))) for _ in range(int(input()))]


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = (max(x, y) - min(x, y)) * a + min(x, y) * b
	d = (x + y) * a
	e = max(x, y) * b + a * (max(x, y) - min(x, y))
	print(min(c, d, e))
	t -= 1


size = int(input())
for i in range(size):
	str1 = input().split()
	x = int(str1[0])
	y = int(str1[1])
	str1 = input().split()
	a = int(str1[0])
	b = int(str1[1])
	diff = abs(y - x)
	comm = max(x, y) - diff
	if a + a < b:
		print(a * (x + y))
	else:
		print(a * diff + b * comm)


t = int(input())
while t > 0:
	s = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(mx, mn) = (max(x, y), min(x, y))
	(MX, MN) = (max(2 * a, b), min(2 * a, b))
	s += mn * MN + abs(x - y) * a
	print(s)
	t -= 1


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().strip().split())
	(a, b) = map(int, input().strip().split())
	if a * 2 <= b:
		print((x + y) * a)
	else:
		c = min(x, y)
		x = x - c
		y = y - c
		tot = c * b
		print(tot + max(x, y) * a)


t = int(input())
s = []
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		k = (x - y) * a
		if 2 * a > b:
			k = y * b + k
		else:
			k = y * 2 * a + k
		s.append(k)
	if x < y:
		k = (y - x) * a
		if 2 * a > b:
			k = x * b + k
		else:
			k = x * 2 * a + k
		s.append(k)
	if y == x:
		if 2 * a > b:
			k = y * b
		else:
			k = y * 2 * a
		s.append(k)
for item in s:
	print(item)


from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = map(int, input().split())
	x = min(abs(m - n) * a + min(m, n) * b, (m + n) * a)
	print(str(x) + '\n')


n = int(input())
a = []
for i in range(n * 2):
	t = input().split()
	a.append(t)
for l in range(n):
	money1 = 0
	money2 = 0
	if 2 * int(a[l * 2 + 1][0]) >= int(a[l * 2 + 1][1]):
		if int(a[l * 2][1]) != int(a[l * 2][0]):
			m = int(a[l * 2][1]) - int(a[l * 2][0])
			if m > 0:
				t = int(a[l * 2][0])
			else:
				t = int(a[l * 2][1])
			money1 = abs(m) * int(a[l * 2 + 1][0])
			if int(a[l * 2][1] == 0):
				money2 = 0
			else:
				mn = int(a[l * 2][0]) - int(a[l * 2][1])
				money2 = int(a[l * 2 + 1][1]) * t
			sum1 = money1 + money2
			print(sum1)
		else:
			int(a[l * 2][1]) == int(a[l * 2][0])
			if int(a[l * 2][1] == 0):
				money2 = 0
			elif int(a[l * 2][1]) != 0:
				money2 = int(a[l * 2 + 1][1]) * int(a[l * 2][0])
			sum1 = money1 + money2
			print(sum1)
	elif 2 * int(a[l * 2 + 1][0]) <= int(a[l * 2 + 1][1]):
		if int(a[l * 2][1]) != int(a[l * 2][0]):
			mmm = int(a[l * 2][1]) - int(a[l * 2][0])
			if mmm > 0:
				t = int(a[l * 2][0])
			else:
				t = int(a[l * 2][1])
			money1 = abs(mmm) * int(a[l * 2 + 1][0])
			if int(a[l * 2][0] == 0):
				money2 = 0
			else:
				money2 = 2 * t * int(a[l * 2 + 1][0])
			sum1 = money1 + money2
			print(sum1)
		elif int(a[l * 2][1]) == int(a[l * 2][0]):
			if int(a[l * 2][0] == 0):
				money2 = 0
			else:
				int(a[l * 2][0]) != 0
				money2 = 2 * int(a[l * 2 + 1][0]) * int(a[l * 2][0])
			sum1 = money1 + money2
			print(sum1)


t = int(input())
ans = []
while t:
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	sum = 0
	if x > y:
		(x, y) = (y, x)
	if 2 * a > b:
		sum += a * (y - x)
		y = x
		sum += b * x
	else:
		sum = a * (x + y)
	ans.append(sum)
	t -= 1
for i in ans:
	print(i)


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(x, y) = map(int, sys.stdin.readline().split())
	(a, b) = map(int, sys.stdin.readline().split())
	result = 0
	ab = a + b
	if a * 2 < b:
		result = (x + y) * a
	else:
		ab
		result = min(x, y) * b + abs(x - y) * a
	print(result)


for _ in range(int(input())):
	numbers = sorted(list(map(int, input().split())))
	cost = list(map(int, input().split()))
	price1 = price2 = 0
	price1 += numbers[-1] - numbers[-2]
	price1 *= cost[0]
	price2 = price1
	price1 += numbers[0] * cost[-1]
	price2 += numbers[0] * cost[0] * 2
	if price1 < price2:
		print(price1)
	else:
		print(price2)


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().rstrip().split()))
	(a, b) = list(map(int, input().rstrip().split()))
	if x == 0 and y == 0:
		print(0)
	else:
		ans = 0
		if x > y:
			(x, y) = (y, x)
		if 2 * a < b:
			ans += x * (2 * a)
		else:
			ans += x * b
		ans += (y - x) * a
		print(ans)


t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	p = min(a * (x + y), a * abs(y - x) + b * min(x, y))
	print(p)
	t = t - 1


def result(x, y, a, b):
	return a * (max(x, y) - min(x, y)) + min(2 * a, b) * min(x, y)
t = int(input())
for i in range(0, t):
	s1 = input()
	b1 = s1.split(' ')
	x = int(b1[0])
	y = int(b1[1])
	s2 = input()
	b2 = s2.split(' ')
	a = int(b2[0])
	b = int(b2[1])
	print(result(x, y, a, b))


def solve(x, y, a, b):
	low = min(x, y)
	hight = max(x, y)
	ret = min(x * a + y * a, low * b + (hight - low) * a)
	print(ret)
T = int(input())
while T > 0:
	(x, y) = [int(x) for x in input().split(' ')]
	(a, b) = [int(x) for x in input().split(' ')]
	solve(x, y, a, b)
	T -= 1


MOD = 1000000007
mod = 10009

def primeseive(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	ans = [i for i in range(2, n + 1) if prime[i]]
	print(ans)

def checkprime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def xymodm(x, y, m):
	res = 1
	x = x % m
	if x == 0:
		return 0
	while y > 0:
		if y & 1:
			res = res * x % m
		y = y // 2
		x = x * x % m
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def solve(x, y, a, b):
	if a + a <= b:
		ans = (x + y) * a
	elif x >= y:
		ans = abs(x - y) * a + y * b
	else:
		ans = abs(x - y) * a + x * b
	print(ans)
for i in range(int(input())):
	(n, k) = map(int, input().split())
	(a, b) = map(int, input().split())
	solve(n, k, a, b)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans1 = (abs(x) + abs(y)) * a
	if x < 0 and y < 0:
		ans1 = min(ans1, abs(max(x, y)) * b + abs(max(x, y) - min(x, y)) * a)
		print(abs(max(x, y)) * b + abs(max(x, y) - min(x, y) * a))
	elif x > 0 and y > 0:
		ans1 = min(ans1, abs(min(x, y) * b + (max(x, y) - min(x, y)) * a))
	print(ans1)


inp = []
for i in range(int(input())):
	inp.append(input().split() + input().split())
for (x, y, a, b) in inp:
	(x, y, a, b) = (int(x), int(y), int(a), int(b))
	total = abs(x - y) * a
	c = min(x, y)
	if 2 * a < b:
		total += 2 * a * c
	else:
		total += b * c
	print(total)


t = int(input())
for V1 in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	cntA = 0
	cntB = 0
	cntA = cntA + abs(x - y)
	if b < 2 * a:
		cntB = cntB + min(x, y)
	else:
		cntA = cntA + 2 * min(x, y)
	print(cntA * a + cntB * b)


for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x * y > 0:
		(x, y) = (abs(max(x, y)), abs(min(x, y)))
		c = (x + y) * a
		c1 = y * b + (x - y) * a
		print(min(c1, c))
	elif x * y < 0:
		(x, y) = (max(x, y), min(x, y))
		c1 = abs(y * b) + (x - y) * a
		c2 = x * b + abs((y - x) * a)
		print(min(c1, c2))
	elif x == 0 and y != 0:
		print(abs(y * a))
	elif x != 0 and y == 0:
		print(abs(x * a))
	else:
		print(0)


t = int(input())
for _ in range(t):
	l1 = [int(x) for x in input().split()]
	(targ, targ1) = (l1[0], l1[1])
	l2 = [int(x) for x in input().split()]
	(a, b) = (l2[0], l2[1])
	if 2 * a > b:
		print(min(targ, targ1) * b + (max(targ, targ1) - min(targ, targ1)) * a)
	else:
		print((targ + targ1) * a)


sum = 0
noInputs = int(input())
for i in range(noInputs):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	maximum = max(x, y)
	minimum = min(x, y)
	sum = min((maximum - minimum) * a + minimum * b, (maximum + minimum) * a)
	print(sum)
	sum = 0


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(c, d) = map(int, input().split())
	minn = min(a, b)
	maxx = max(a, b)
	high = minn * d
	x = maxx - minn
	low = x * c
	p = high + low
	h = a * c + b * c
	print(min(p, h))


tests = int(input())
ans = [0] * tests
for i in range(tests):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	b = min(b, 2 * a)
	if x < y:
		(x, y) = (y, x)
	ans[i] = y * b + (x - y) * a
for sol in ans:
	print(sol)


inputLine = input()
finalAns = []
for index in range(int(inputLine)):
	inputLine = input()
	tempStr = inputLine.split(' ')
	x = int(tempStr[0])
	y = int(tempStr[1])
	inputLine = input()
	tempStr = inputLine.split(' ')
	costA = int(tempStr[0])
	costB = int(tempStr[1])
	if x == 0 and y == 0:
		finalAns.append(0)
	elif x == y:
		finalAns.append(2 * costA * x if 2 * costA * x <= costB * x else costB * x)
	else:
		thisMax = x if x >= y else y
		thisMin = y if y < x else x
		fWay = costA * thisMin + costA * thisMax
		sWay = costB * thisMin + costA * (thisMax - thisMin)
		finalAns.append(fWay if fWay <= sWay else sWay)
for eachAns in finalAns:
	print(eachAns)


t = int(input())
while t != 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	diff = x - y
	if diff < 0:
		diff = -diff
	p = min(x, y)
	fin = diff * a + p * b
	fin1 = x * a + y * a
	print(min(fin, fin1))
	t = t - 1


def main():
	n_num = int(input())
	for k in range(n_num):
		(x, y) = sorted(list(map(int, input().split(' '))))
		(a, b) = list(map(int, input().split(' ')))
		print(min(a * (y - x) + b * x, x * a + y * a))
main()


for _ in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ans = 0
	t = min(x, y)
	r = abs(y - x)
	ans += t * b + r * a
	print(min(ans, (x + y) * a))


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

def lisdiv():
	return list(map(int, list(input())))
t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b > 2 * a:
		b = 2 * a
	x1 = min(x, y)
	y1 = max(x, y)
	total = 0
	if x1 <= 0 and y1 >= 0:
		total = (y1 - x1) * a
	elif x1 <= 0 and y1 <= 0:
		total = (y1 - x1) * a + y1 * -1 * b
	else:
		total = (y1 - x1) * a + x1 * b
	print(total)


from sys import stdin, stdout
import bisect
import math
import itertools
I = lambda : map(int, input().split())
IS = lambda : map(str, input().split())
IA = lambda : list(map(str, input().split()))
IAS = lambda : list(map(str, input().split()))
t = int(input())
for _ in range(t):
	(x, y) = I()
	(a, b) = I()
	print(min((x + y) * a, (max(x, y) - min(x, y)) * a + min(x, y) * b))


T = int(input())
for t in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	decrease_all_one_by_one = a * (x + y)
	equal_both_decrease_simultaneously = a * abs(x - y) + b * min(x, y)
	print(min(decrease_all_one_by_one, equal_both_decrease_simultaneously))


from sys import stdin
a = int(stdin.readline())
for b in range(0, a):
	c = stdin.readline().split()
	d = stdin.readline().split()
	X = int(c[0])
	Y = int(c[1])
	A = int(d[0])
	B = int(d[1])
	if 2 * A <= B:
		print((abs(X) + abs(Y)) * A)
	elif A * B < 0:
		print((abs(X) + abs(Y)) * A)
	else:
		C = min(abs(X), abs(Y))
		print(C * B + (max(abs(X), abs(Y)) - C) * A)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(t1, t2) = (abs(y - x), x + y)
	ans = min(t1 * a + b * min(x, y), t2 * a)
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d = 0
	if x < y:
		d += x * b + (y - x) * a
	elif y < x:
		d += y * b + (x - y) * a
	else:
		d = y * b
	if a * (x + y) < d:
		print(a * (x + y))
	else:
		print(d)


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if 2 * a < b or x * y < 0:
		result = a * (abs(x) + abs(y))
	else:
		dup = min(abs(x), abs(y))
		result = b * dup + abs(abs(x) - abs(y)) * a
	print('{}'.format(result))


t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = 0
	if x == 0 and y == 0:
		print(0)
	else:
		res = abs(x - y)
		mn = min(x, y)
		ans = res * a
		if 2 * a < b:
			ans += mn * a * 2
		else:
			ans += mn * b
		print(ans)


from sys import setrecursionlimit
from collections import deque
import heapq
import functools

def IntInput():
	return int(input())

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

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

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

def modInverse(p, a, m):
	return p % m * pow(a % m, m - 2, m) % m

def compare(item1, item2):
	return item2[0] - item1[0] if item1[0] != item2[0] else item1[1] - item2[1]

def DFS(s, n, paths, answer):
	visited = [False] * (n + 1)
	stack = []
	stack.append(s)
	visited[s] = True
	DFSArray = []
	while stack:
		s = stack.pop()
		DFSArray.append(s)
		flag = 0
		for i in paths[s]:
			if visited[i] == False:
				flag = 1
				stack.append(i)
				visited[i] = True
		if not flag:
			answer[s - 1][1] = 0
	while DFSArray != []:
		s = DFSArray.pop()
		if answer[s - 1][1] < 0:
			answer[s - 1][1] = 0
			for i in paths[s]:
				if answer[i - 1][1] >= 0:
					answer[s - 1][1] += answer[i - 1][1] + 1
	return answer

def BFS(s, n, paths, answer):
	visited = [False] * (n + 1)
	answer[s - 1][0] = 0
	queue = deque()
	queue.append(s)
	visited[s] = True
	while queue:
		s = deque.popleft(queue)
		for i in paths[s]:
			if visited[i] == False:
				queue.append(i)
				answer[i - 1][0] = answer[s - 1][0] + 1
				visited[i] = True
	return answer
numbers = ['1110111', '0010010', '1011101', '1011011', '0111010', '1101011', '1101111', '1010010', '1111111', '1111011']
Dict_Numbers = {'1110111': 0, '0010010': 1, '1011101': 2, '1011011': 3, '0111010': 4, '1101011': 5, '1101111': 6, '1010010': 7, '1111111': 8, '1111011': 9}
for _ in range(int(input())):
	(x, y) = M_IntInput()
	(a, b) = M_IntInput()
	if b >= 2 * a:
		print(a * (abs(x) + abs(y)))
	elif x * y > 0:
		print(b * min(x, y) + a * abs(x - y))
	else:
		print(a * (abs(x) + abs(y)))


import sys
input = sys.stdin.readline
from collections import defaultdict as dd
t = int(input())
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	res = a * abs(x - y)
	c = min(2 * a, b)
	res += c * min(x, y)
	print(res)
	t -= 1


t = int(input())
calc = []
for i in range(t):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	calc.append([x, y, a, b])
for i in range(len(calc)):
	(x, y) = (calc[i][0], calc[i][1])
	(a, b) = (calc[i][2], calc[i][3])
	a_count = 0
	if 2 * a < b:
		print(a * (x + y))
	else:
		if x > y:
			a_count = x - y
			x = y
		else:
			a_count = y - x
			y = x
		print(a_count * a + x * b)


j = int(input())
for i in range(j):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if 2 * a < b:
		print((x + y) * a)
	else:
		c = abs(x - y)
		d = min(x, y)
		print(c * a + d * b)


def dollar(x, y, a, b):
	diff = abs(x - y)
	ans1 = diff * a
	k = min(x, y)
	z = k - 0
	ans2 = z * b
	ans = ans1 + ans2
	print(min(ans, (x + y) * a))
t = int(input())
for i in range(t):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	ans = dollar(x, y, a, b)
	ans


t = int(input())
i = 0
while i < t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if y > x:
		(x, y) = (y, x)
	if a + a <= b:
		print((x + y) * a)
	else:
		print(y * b + (x - y) * a)
	i = i + 1


t = int(input())
output = []
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	one = (x + y) * a
	two = (max(x, y) - min(x, y)) * a + min(x, y) * b
	output.append(min(one, two))
for i in range(t):
	print(output[i])


T = int(input())
for _ in range(T):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	else:
		temp = 0
		if x >= y:
			temp = min(a * (x + y), a * (x - y) + b * y)
			print(temp)
		else:
			temp = min(a * (x + y), a * (y - x) + b * x)
			print(temp)


test = int(input())

def solve():
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ll = x - y
	if abs(ll) > max(abs(x), abs(y)):
		print(abs(ll) * a)
	else:
		r1 = abs(ll) * a + min(abs(x), abs(y)) * b
		r2 = (abs(x) + abs(y)) * a
		if r1 > r2:
			print(r2)
		else:
			print(r1)
for x in range(test):
	solve()


n = int(input())
for _ in range(n):
	(x, y) = sorted(map(int, input().split()))
	(a, b) = map(int, input().split())
	b = min(b, 2 * a)
	if x == y:
		print(x * b)
	elif x >= 0 and y >= 0:
		res = (x + y) * a
		res = min(res, x * b + (y - x) * a)
		print(res)
	elif x <= 0 and y <= 0:
		(x, y) = (-y, -x)
		res = (x + y) * a
		res = min(res, x * b + (y - x) * a)
		print(res)
	elif x >= 0 and y <= 0:
		res = (x - y) * a
		print(res)
	else:
		(x, y) = (y, x)
		res = (x - y) * a
		print(res)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	(x, y) = map(int, stdin.readline().split())
	(a, b) = map(int, stdin.readline().split())
	if x == 0 and y == 0:
		print(0)
	elif x == 0:
		print(abs(y) * a)
	elif y == 0:
		print(abs(x) * a)
	elif x > 0 and y > 0 or (x < 0 and y < 0):
		x = abs(x)
		y = abs(y)
		if y < x:
			(y, x) = (x, y)
		amount = min(x * b, 2 * a * x)
		amount += (y - x) * a
		print(amount)
	elif x > 0 and y < 0 or (x < 0 and y > 0):
		x = abs(x)
		y = abs(y)
		amount = x * a + y * a
		print(amount)


t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().strip().split()))
	(a, b) = list(map(int, input().strip().split()))
	if 2 * a <= b:
		print((x + y) * a)
	else:
		minv = min(x, y)
		x -= minv
		y -= minv
		print(b * minv + a * max(x, y))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	val1 = (x + y) * a
	if x == y:
		print(min(2 * x * a, x * b))
	elif x < y:
		val2 = x * b + (y - x) * a
		print(min(val1, val2))
	else:
		val3 = y * b + (x - y) * a
		print(min(val1, val3))


def solve():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if b > a * 2:
		print(a * (x + y))
	else:
		mn = min(x, y)
		d = max(x, y) - mn
		print(mn * b + d * a)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	v1 = min(x, y) * b + (max(x, y) - min(x, y)) * a
	v2 = (x + y) * a
	print(v1 if v1 < v2 else v2)


def main():
	n = int(input())
	for i in range(n):
		(k, m) = map(int, input().split())
		(a, b) = map(int, input().split())
		if b <= 2 * a:
			print(min(k, m) * b + abs(k - m) * a)
		elif b > 2 * a:
			print(a * (k + m))
main()


num = int(input())
for _ in range(num):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if x < y:
		(x, y) = (y, x)
	sellect = b if b <= 2 * a else a
	if sellect == b:
		ans = y * b + (x - y) * a
	else:
		ans = (x + y) * a
	print(ans)


t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	res = 0
	if 2 * a <= b:
		res = abs(x) * a + abs(y) * a
	elif x >= 0 and y >= 0 or (x <= 0 and y <= 0):
		min_num = min(abs(x), abs(y))
		res += min_num * b
		res += max(abs(x) - min_num, abs(y) - min_num) * a
	else:
		res += abs(x) * a + abs(y) * a
	print(res)


def main():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	A = abs(x - y)
	B = min(x, y)
	if 2 * a < b:
		print((x + y) * a)
	else:
		print(B * b + A * a)
for _ in range(int(input())):
	main()


t = int(input())
for i in range(t):
	sum = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	while x != 0 and y != 0 or x != 0 or y != 0:
		if 2 * a >= b:
			if x == y:
				sum = sum + b * y
				(x, y) = (0, 0)
			elif x < y:
				sum = sum + (y - x) * a
				y = x
			elif x > y:
				sum = sum + (x - y) * a
				x = y
		else:
			sum = sum + (x + y) * a
			(x, y) = (0, 0)
	print(sum)


import math
t = int(input())
xList = list()
yList = list()
aList = list()
bList = list()
for i in range(t):
	(x, y) = [int(s) for s in input().split()]
	(a, b) = [int(s) for s in input().split()]
	xList.append(x)
	yList.append(y)
	aList.append(a)
	bList.append(b)
for i in range(t):
	mx = max(xList[i], yList[i])
	mn = min(xList[i], yList[i])
	dif = abs(xList[i] - yList[i])
	s1 = mn * bList[i] + dif * aList[i]
	s2 = xList[i] * aList[i] + yList[i] * aList[i]
	print(min(s1, s2))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	p = min(x, y) * b + abs(x - y) * a
	p1 = (x + y) * a
	print(min(p1, p))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x1 = abs(x)
	y1 = abs(y)
	if x * y < 0:
		print(abs(x - y) * a)
	elif 2 * a < b:
		print(abs(x + y) * a)
	elif x1 < y1:
		print(x1 * b + abs(x - y) * a)
	else:
		print(y1 * b + abs(x - y) * a)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	(ax, ay) = (abs(x), abs(y))
	if x >= 0 and y <= 0 or (x <= 0 and y >= 0):
		print((ax + ay) * a)
	elif b >= 2 * a:
		print((ax + ay) * a)
	else:
		print(min(ax, ay) * b + a * abs(ax - ay))


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	(x, y) = list(map(int, input().split()))
	total = 0
	if y > 2 * x:
		y = 2 * x
	if a * b >= 0:
		a = abs(a)
		b = abs(b)
		p = min(a, b)
		q = max(a, b)
		total = p * y + (q - p) * x
	else:
		total = x * abs(a) + x * abs(b)
	print(total)


t = int(input())
c = []
for i in range(t):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	if 2 * a < b:
		f = abs(x - y) * a + abs(min(x, y)) * 2 * a
	else:
		f = abs(x - y) * a + abs(min(x, y)) * b
	c.append(f)
for k in c:
	print(k)


def check(x, y, a, b):
	if b > 2 * a:
		return (x + y) * a
	return abs(x - y) * a + min(x, y) * b
t = int(input())
while t:
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(check(x, y, a, b))
	t -= 1


i = 0
r = int(input())
while i < r:
	(x, y) = [int(x) for x in input().split(' ')]
	(a, b) = [int(x) for x in input().split(' ')]
	c = x - y
	c = abs(c)
	total = 0
	total += c * a
	if 2 * a < b:
		total += 2 * a * min(x, y)
	else:
		total += b * min(x, y)
	print(total)
	i += 1


answer = []
for i in range(int(input())):
	sum = 0
	sum1 = 0
	sum2 = 0
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if x == 0 and y == 0:
		sum = 0
	elif x < 0 and y < 0 or (x > 0 and y > 0):
		if abs(x) > abs(y):
			sum1 += b * y + a * (x - y)
			sum2 += (abs(x) + abs(y)) * a
			sum = min(sum1, sum2)
		else:
			sum1 += b * x + a * (y - x)
			sum2 += (abs(x) + abs(y)) * a
			sum = min(sum1, sum2)
	elif x == 0:
		sum += abs(y) * a
	elif y == 0:
		sum += abs(x) * a
	else:
		sum += (abs(x) + abs(y)) * a
	answer.append(sum)
for i in range(len(answer)):
	print(answer[i])


t = int(input())
for i in range(t):
	(n1, n2) = map(int, input().split())
	(a, b) = map(int, input().split())
	if n1 == n2:
		m = n1 * b
		k = n1 * a + n2 * a
		print(min(m, k))
	elif n1 < n2:
		f = n2 - n1
		v = f * a
		x = n1 * b
		y = n1 * a + n1 * a
		print(min(v + x, v + y))
	elif n1 > n2:
		f = n1 - n2
		v = f * a
		x = n2 * b
		y = n2 * a + n2 * a
		print(min(v + x, v + y))


t = int(input())
for _ in range(t):
	m = list(map(int, input().split()))
	(a, b) = map(int, input().split())
	m.sort()
	if b < 2 * a:
		print(min(m[1] * b + (m[1] - m[0]) * a, m[0] * b + (m[1] - m[0]) * a))
	else:
		print(int((m[1] + m[0]) * a))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	one_ans = (x + y) * a
	two_ans = min(x, y) * b + abs(x - y) * a
	ans = min(one_ans, two_ans)
	print(ans)


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(x, y) = iia()
	(a, b) = iia()
	res = float('inf')
	res = min(res, x * a + y * a)
	m = min(x, y)
	res = min(res, (max(x, y) - m) * a + m * b)
	print(res)


a = int(input())
for i in range(a):
	(n_1, n_2) = map(int, input().split())
	(d_1, d_2) = map(int, input().split())
	e = min(n_1, n_2)
	e *= d_2
	d1 = max(n_1, n_2) - min(n_1, n_2)
	d = d1 * d_1
	q = d1 * d_1
	q += n_1 * d_2
	print(min(d + e, q, (n_1 + n_2) * d_1))


m = int(input())
for i in range(m):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if a * 2 < b:
		ans = x + y
		print(ans * a)
	elif x > y:
		print(y * b + (x - y) * a)
	else:
		print(x * b + (y - x) * a)


import sys
from math import log2, floor, ceil, sqrt
sys.setrecursionlimit(7 * 10 ** 4)
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 998244353
for _ in range(int(ri())):
	(x, y) = Ri()
	(a, b) = Ri()
	ans = 0
	if b <= 2 * a:
		if x < y:
			ans = ans + x * b
			y -= x
			x -= x
			ans += y * a
		else:
			ans = ans + y * b
			x -= y
			y = 0
			ans += x * a
	else:
		ans = x * a + y * a
	print(ans)


t = int(input())
for tt in range(t):
	(x, y) = [int(i) for i in str.split(input(), ' ')]
	(a, b) = [int(i) for i in str.split(input(), ' ')]
	cost = 0
	cost += abs(x - y) * a
	if 2 * a < b:
		cost += 2 * a * min(x, y)
	else:
		cost += b * min(x, y)
	print(cost)


t = int(input())
for _ in range(t):
	(x, y) = [int(i) for i in input().split(' ')]
	(a, b) = [int(i) for i in input().split(' ')]
	count = 0
	if x < y:
		(x, y) = (y, x)
	d = b - a
	if d <= a:
		count = (x - y) * a + y * b
	else:
		count = a * (x + y)
	print(count)


t = int(input())
for i in range(t):
	winner = []
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	winner.append((x + y) * a)
	if x <= y:
		double = x
		y -= x
		x -= x
	else:
		double = y
		x -= y
		y -= y
	single = x + y
	winner.append(a * single + b * double)
	print(min(winner))


t = int(input())
ans = []
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost = 0
	mini = min(x, y)
	if b < 2 * a:
		cost += b * mini + a * abs(x - y)
	else:
		cost += a * (x + y)
	print(cost)


t = int(input())
for testcase in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost1 = abs(x) * a + abs(y) * a
	if x < 0 and y < 0:
		cost2 = abs(max(x, y)) * b + abs(x - y) * a
	elif x > 0 and y > 0:
		cost2 = min(x, y) * b + abs(x - y) * a
	else:
		c1 = max(abs(x), abs(y)) * b + (abs(x) + abs(y)) * a
		c2 = min(abs(x), abs(y)) * b + (abs(x) + abs(y)) * a
		cost2 = min(c1, c2)
	print(min(cost1, cost2))


for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	result = a * (abs(x) + abs(y))
	if x >= 0 and y >= 0 or (x < 0 and y < 0):
		result = min(a * abs(x - y) + b * min(x, y), result)
	print(result)


def solution():
	from sys import stdout, stdin
	(_input, _print) = (stdin.readline, stdout.write)
	for _ in range(int(input())):
		(x, y) = [int(i) for i in input().split()]
		(a, b) = [int(i) for i in input().split()]
		if b > 2 * a:
			print((x + y) * a)
		else:
			print(min(x, y) * b + (max(x, y) - min(x, y)) * a)
solution()


t = int(input())
while t:
	t -= 1
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if x > y:
		(x, y) = (y, x)
	diff = y - x
	ans = a * diff
	ans1 = ans
	ans += b * x
	ans1 += 2 * x * a
	print(min(ans, ans1))


import sys, collections
tc = int(sys.stdin.readline())
for _ in range(tc):
	(x, y) = map(int, sys.stdin.readline().split())
	(a, b) = map(int, sys.stdin.readline().split())
	if 2 * a >= b:
		cost = 0
		both = min(x, y)
		x -= both
		y -= both
		cost += b * both
		if x == 0:
			cost += a * y
		else:
			cost += a * x
	else:
		cost = a * (x + y)
	print(cost)


def solution(x, y, a, b):
	return min((x + y) * a, abs(x - y) * a + b * min(x, y))

def main():
	for test in range(int(input())):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		print(solution(x, y, a, b))
main()


T = int(input().strip())
for t in range(T):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	if 2 * a <= b:
		print((x + y) * a)
	else:
		mxy = min(x, y)
		rem = x + y - 2 * mxy
		print(mxy * b + rem * a)


answer = []
t = int(input())
for i in range(0, t):
	(x, y) = map(int, input().rstrip().split())
	(a, b) = map(int, input().rstrip().split())
	min_v = min(x, y)
	max_v = max(x, y)
	diff1 = min_v - 0
	diff2 = max_v - min_v
	ans = 0
	if 2 * a < b:
		ans += 2 * a * diff1
		ans += diff2 * a
	else:
		ans += b * diff1
		ans += diff2 * a
	answer.append(ans)
print(*answer, sep='\n')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	z = min(x, y)
	s = abs(x - y) * a
	print(s + min(z * b, 2 * z * a))


import math
num_case = int(input())
for i in range(num_case):
	se = input().split()
	se1 = input().split()
	datax_y = []
	for i in se:
		datax_y.append(int(i))
	dataa_b = []
	for i in se1:
		dataa_b.append(int(i))
	if 2 * dataa_b[0] >= dataa_b[1]:
		if datax_y[0] <= datax_y[1]:
			result = datax_y[0] * dataa_b[1] + (datax_y[1] - datax_y[0]) * dataa_b[0]
		else:
			result = datax_y[1] * dataa_b[1] + (datax_y[0] - datax_y[1]) * dataa_b[0]
	else:
		result = (datax_y[0] + datax_y[1]) * dataa_b[0]
	print(result)


t = int(input())
for i in range(t):
	tot = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
	else:
		ma = max(x, y)
		mi = min(x, y)
		d = ma - mi
		result = d * a
		ste = mi - 0
		final = result + min(b * ste, 2 * a * ste)
		print(final)


t = int(input())
for z in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(min(abs(min(x, y)) * b + (abs(max(x, y)) - abs(min(x, y))) * a, a * (abs(x) + abs(y))))


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	ans = a * abs(x) + a * abs(y)
	tmp = 0
	if x > 0 and y > 0:
		min_ = min(x, y)
		tmp += b * abs(min_)
		x -= min_
		y -= min_
	if x < 0 and y < 0:
		max_ = max(x, y)
		tmp += b * abs(max_)
		x -= max_
		y -= max_
	tmp += a * abs(x) + a * abs(y)
	print(min(tmp, ans))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y:
		print(min(b * x, 2 * x * a))
	elif y > x:
		temp = x * b + (y - x) * a
		print(min(temp, (x + y) * a))
	else:
		temp = y * b + (x - y) * a
		print(min(temp, (x + y) * a))


def find(x, y, a, b):
	if x == 0:
		return a * abs(y)
	elif y == 0:
		return a * abs(x)
	elif x * y < 0:
		return abs(x) * a + abs(y) * a
	else:
		diff = abs(x - y)
		sec_oper_it = min(abs(x), abs(y))
		second_operation_cost = sec_oper_it * b
		first_operation_cost = diff * a
		only_first_operation_cost = abs(x) * a + abs(y) * a
		return min(only_first_operation_cost, second_operation_cost + first_operation_cost)
cases = int(input())
for _ in range(cases):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(find(x, y, a, b))


T = int(input())
for t in range(T):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if x == 0 or y == 0:
		print(a * max(abs(x), abs(y)))
		continue
	(x, y) = (min(x, y), max(x, y))
	if x < 0 and y > 0:
		print(a * (abs(x) + abs(y)))
	else:
		answer = a * abs(x - y)
		b = min(b, 2 * a)
		answer += b * abs(x)
		print(answer)


import sys
import math
t = int(input())
for i in range(0, t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x > y:
		temp = x
		x = y
		y = temp
	count = 0
	count += (y - x) * a
	minA = x * 2 * a
	minB = x * b
	count += min(minA, minB)
	print(count)


Test = int(input())
for T in range(Test):
	Lista = list(map(int, input().split()))
	Cuotas = list(map(int, input().split()))
	Lista.sort()
	(X, Y) = (Lista[0], Lista[1])
	if X != Y:
		Cuota1 = Y - X
		Cuota2 = X
		Res1 = Cuota1 * Cuotas[0] + Cuota2 * Cuotas[1]
	else:
		Res1 = Cuotas[1] * X
	Res2 = (X + Y) * Cuotas[0]
	print(min(Res1, Res2))


for ttt in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x >= y:
		(p, q, r) = (0, 0, 0)
		p += a * (x - y) + y * b
		q += a * (x + y)
		r += a * (x - y) + x * b
		print(min(p, q, r))
	else:
		(p, q, r) = (0, 0, 0)
		p += a * (y - x) + x * b
		q += a * (x + y)
		r += a * (y - x) + y * b
		print(min(p, q, r))


for _ in range(int(input())):
	Numbers = list(map(int, input().split()))
	X = list(map(int, input().split()))
	Sum = 0
	if 0 not in Numbers:
		if X[0] * 2 > X[1]:
			Sum += min(Numbers) * X[1]
			Min = min(Numbers)
			Numbers[0] -= Min
			Numbers[1] -= Min
	print(sum(Numbers) * X[0] + Sum)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	c = 0
	c = min(m * b, m * a * 2)
	c = c + (x + y - 2 * m) * a
	print(c)


T = int(input())
for t in range(T):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	if 2 * a <= b:
		print((x + y) * a)
	if 2 * a > b:
		print(min(x, y) * b + abs(x - y) * a)


i = int(input())
for x in range(i):
	spent = 0
	(x, y) = list(map(int, input().split(' ')))
	(a, b) = list(map(int, input().split(' ')))
	maximum = max([x, y])
	minimum = min([x, y])
	if minimum * a + maximum * a < a * (maximum - minimum) + b * minimum:
		spent += minimum * a + maximum * a
	else:
		spent += b * minimum
		spent += a * (maximum - minimum)
	print(spent)


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	if l[0] == 0 and l[1] == 0:
		a = 0
	elif 2 * l1[0] < l1[1] or l[0] * l[1] < 0:
		a = l1[0] * (abs(l[0]) + abs(l[1]))
	else:
		b = min(abs(l[0]), abs(l[1]))
		a = l1[1] * b + abs(abs(l[0]) - abs(l[1])) * l1[0]
	print('{}'.format(a))


def get():
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	sb = 0
	if 2 * a < b:
		sb = (x + y) * a
	else:
		sa = abs(x - y) * a
		sb = min(x, y) * b + sa
	print(sb)
for _ in range(int(input())):
	get()


n_cases = int(input())
for case_num in range(n_cases):
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if b >= 2 * a:
		print(a * abs(x) + a * abs(y))
	else:
		cost = 0
		if x > 0 and y > 0:
			m = min(x, y)
			cost += b * m
			x -= m
			y -= m
		cost += a * abs(x) + a * abs(y)
		print(cost)


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	m = min(x, y)
	print(min((x + y) * a, m * b + (x + y - 2 * m) * a))
	t -= 1


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	g = min(x, y)
	h = max(x, y)
	h = (h - g) * a
	h += g * min(2 * a, b)
	print(h)


def cost(x, y, a, b):
	tot = 0
	com = min(x, y)
	if 2 * a > b:
		tot += com * b
	else:
		tot += com * 2 * a
	tot += (x - com) * a + (y - com) * a
	return tot
for i in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(cost(x, y, a, b))


t = int(input())
for _ in range(t):
	(a, b) = [int(x) for x in input().split()]
	(c, d) = [int(x) for x in input().split()]
	ans = 0
	x = min(a, b)
	y = max(a, b)
	ans += (y - x) * c
	y = x
	if 2 * c < d:
		ans += x * c * 2
	else:
		ans += x * d
	print(ans)


ans = []
te = int(input())
for i in range(te):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ekh = x - y
	if ekh < 0:
		ekh = -ekh
	m = min(min(x, y) * b, min(x, y) * 2 * a)
	ans.append(m + ekh * a)
for i in range(te):
	print(ans[i])


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x * y < 0:
		print((abs(x) + abs(y)) * a)
		continue
	x = abs(x)
	y = abs(y)
	m = min(x, y)
	g = max(x, y)
	if 2 * a > b:
		ans = m * b + (g - m) * a
	else:
		ans = (x + y) * a
	print(ans)


from sys import stdin
test = int(stdin.readline())
while test > 0:
	(x, y) = [int(w) for w in stdin.readline().split()]
	(a, b) = [int(w) for w in stdin.readline().split()]
	res = a * abs(x - y) + min(2 * a * min(x, y), b * min(x, y))
	print(res)
	test -= 1


import math
for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	arr = [x * a + y * a, x * b + abs(y - x) * a, abs(y - x) * a + y * b]
	print(min(arr))


import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)
ntc = next(ints)
for tc in range(ntc):
	(x, y) = (next(ints), next(ints))
	(a, b) = (next(ints), next(ints))
	print(min(b, 2 * a) * min(x, y) + a * (max(x, y) - min(x, y)))


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(x, y) = mints()
	(a, b) = mints()
	if x > y:
		(x, y) = (y, x)
	r = min(a * abs(y - x) + b * abs(x), a * abs(x - y) + b * abs(y))
	print(min(r, (abs(x) + abs(y)) * a))
for i in range(mint()):
	solve()


from sys import stdin

def func():
	return
for _ in range(int(stdin.readline())):
	l = list(map(int, stdin.readline().split()))
	(a, b) = map(int, stdin.readline().split())
	x = min(l)
	y = max(l)
	ans = min(b * x + a * (y - x), a * (x + y))
	print(ans)


inp = input()
num_cases = int(inp)
for _ in range(num_cases):
	(x, y) = list(map(lambda x: int(x), input().split(' ')))
	(a, b) = list(map(lambda x: int(x), input().split(' ')))
	T = 0
	while not x == y == 0:
		closer_amt = lambda d, e: abs(x) - abs(x + d) + (abs(y) - abs(y + e))
		cost = lambda op: a if op[0] == 'a' else b
		op1 = (cost('a'), -1, 0, closer_amt(-1, 0))
		op2 = (cost('a'), 0, -1, closer_amt(0, -1))
		op3 = (cost('a'), 1, 0, closer_amt(1, 0))
		op4 = (cost('a'), 0, 1, closer_amt(0, 1))
		op5 = (cost('b'), -1, -1, closer_amt(-1, -1))
		op6 = (cost('b'), 1, 1, closer_amt(1, 1))
		options = list(filter(lambda op: op[3] > 0, [op1, op2, op3, op4, op5, op6]))
		option = min(options, key=lambda op: op[0] / op[3])
		(xm, ym) = option[1:3]
		amount = 1
		last_closer = closer_amt(amount * xm, amount * ym)
		if xm == 0:
			amount = abs(y) - 1
		elif ym == 0:
			amount = abs(x) - 1
		else:
			amount = min(abs(x), abs(y))
		while True:
			this_closer = closer_amt((amount + 1) * xm, (amount + 1) * ym)
			if this_closer < last_closer or (x != 0 and x + xm * amount == 0) or (y != 0 and y + ym * amount == 0):
				break
			last_closer = this_closer
			amount += 1
		x = x + xm * amount
		y = y + ym * amount
		T += option[0] * amount
	print(T)


(t, xy, ab) = (int(input()), [], [])
for i in range(t):
	xy.append(sorted(list(map(int, input().split()))))
	ab.append(list(map(int, input().split())))
for i in range(t):
	if ab[i][0] * 2 <= ab[i][1]:
		print((xy[i][0] + xy[i][1]) * ab[i][0])
	else:
		print(xy[i][0] * ab[i][1] + (xy[i][1] - xy[i][0]) * ab[i][0])


import math
t = int(input())
while t > 0:
	(x, y) = [int(x) for x in input().split()]
	(a, b) = [int(x) for x in input().split()]
	if x > y:
		(x, y) = (y, x)
	if x == y:
		if x == 0:
			ans = 0
		else:
			ans1 = x * b
			ans = 2 * (x * a)
			if ans > ans1:
				ans = ans1
	elif x == 0:
		ans = a * y
	else:
		ans = (y - x) * a + x * b
		ans1 = (x + y) * a
		if ans > ans1:
			ans = ans1
	print(ans)
	t = t - 1


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(x, y, a, b):
	cost = 0
	if b <= 2 * a:
		min_val = min(x, y)
		cost += b * min_val
		x -= min_val
		y -= min_val
		max_val = max(x, y)
		cost += max_val * a
	else:
		cost = (x + y) * a
	print(cost)
t = int(input())
for i in range(t):
	(x, y) = to_list(input())
	(a, b) = to_list(input())
	solve(x, y, a, b)


num = int(input())
for j in range(num):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	amount = 0
	if 2 * a > b:
		if x > 0 and y > 0:
			amount = min(x, y) * b + abs(x - y) * a
		elif x > 0 and y < 0:
			amount = abs(x - y) * a
		elif x < 0 and y > 0:
			amount = abs(y - x) * a
		elif x < 0 and y < 0:
			amount = abs(max(x, y)) * b + abs(x - y) * a
		else:
			amount = abs(x + y) * a
	else:
		amount = (abs(x) + abs(y)) * a
	print(amount)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	x = abs(x)
	y = abs(y)
	ca = 0
	cb = 0
	if x == y == 0:
		print(0)
	elif a * 2 > b:
		if x > 0 and y > 0 and (x == y):
			cb += x * b
		elif x > 0 and y > 0 and (x > y):
			d = y
			cb += b * d
			x -= d
			y -= d
			ca += a * x
			x -= x
		elif x > 0 and y > 0 and (y > x):
			d = x
			cb += b * d
			x -= d
			y -= d
			ca += a * y
			y -= y
		elif x == 0 and y != 0:
			d = y
			ca += a * d
		elif y == 0 and x != 0:
			d = x
			ca += a * d
		print(ca + cb)
	else:
		if x > 0 and y > 0:
			d1 = x
			d2 = y
			ca += a * d1
			ca += a * d2
			x -= d1
			y -= d2
		elif x == 0 and y != 0:
			d = y
			ca += a * d
		elif y == 0 and x != 0:
			d = x
			ca += a * d
		print(ca + cb)


t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	sum = 0
	sum1 = 0
	sum += (x + y) * a
	p = min(x, y)
	sum1 += p * b
	z = max(x, y) - p
	sum1 += z * a
	if sum < sum1:
		print(sum)
	else:
		print(sum1)


t = int(input())
l = []
for i in range(t):
	(x, y) = input().split()
	(a, b) = input().split()
	l.append([int(x), int(y), int(a), int(b)])
for j in l:
	if j[0] < j[1]:
		cal1 = (j[0] + j[1]) * j[2]
		cal2 = (j[1] - j[0]) * j[2] + j[0] * j[3]
	else:
		cal1 = (j[0] + j[1]) * j[2]
		cal2 = (j[0] - j[1]) * j[2] + j[1] * j[3]
	if cal1 > cal2:
		print(cal2)
	else:
		print(cal1)


t = int(input())
for _ in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	total = 0
	if b <= a * 2:
		m = min(x, y)
		total += m * b
		x -= m
		y -= m
	total += (x + y) * a
	print(total)


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
livalor = lambda valor, x: [valor for i in range(x)]
stent = lambda : [i for i in inp()]
filldp = lambda valor, x, y: [[valor for i in range(y)] for i in range(x)]
mi = min
ma = max
t = iinp()
for _ in range(t):
	(x, y) = ent()
	(a, b) = ent()
	if x == y == 0:
		print(0)
	elif x == y and x > 0:
		print(mi(x * b, x * a * 2))
	elif x == y and x < 0:
		print(mi(x * b * -1, x * a * 2 * -1))
	elif x < 0 and y > 0:
		print(a * x * -1 + a * y)
	elif x > 0 and y < 0:
		print(a * x + y * a * -1)
	else:
		if x < 0:
			x = x * -1
		if y < 0:
			y = y * -1
		tmp = ma(x, y)
		x = mi(x, y)
		y = tmp
		cont = a * (y - x)
		print(mi(cont + x * b, x * a + y * a))


for _ in range(int(input())):
	(x, y) = [int(x) for x in input().rstrip().split(' ')]
	(a, b) = [int(x) for x in input().rstrip().split(' ')]
	val1 = (x + y) * a
	val2 = min(x, y) * b
	val2 += (max(x, y) - min(x, y)) * a
	print(min(val1, val2))


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

def inp():
	return map(int, input().split())
for _ in range(int(input())):
	(x, y) = inp()
	(a, b) = inp()
	if x > y:
		n = (y, x) = (x, y)
	diff = y - x
	ans = a * diff
	if 2 * a < b:
		ans += x * 2 * a
	else:
		ans += x * b
	print(ans)


for i in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	ans = x + y - 2 * min(x, y)
	ans *= a
	if b < 2 * a:
		ans += min(x, y) * b
	else:
		ans += min(x, y) * 2 * a
	print(ans)


T = int(input())
for t in range(T):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	res = abs(x - y) * a
	v = min(abs(x), abs(y))
	res += min(b, 2 * a) * v
	print(res)


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == y and (x == 0 and y == 0):
		print('0')
	else:
		s = b * min(x, y)
		s += abs(x - y) * a
		s1 = a * x + a * y
		print(min(s, s1))
	t -= 1


t = input()
lst = list()
i = 1
while i <= int(t):
	(x, y) = input().split()
	(a, b) = input().split()

	def fun(m, n, o, p):
		if m >= n:
			if 2 * o <= p:
				return (m + n) * o
			else:
				return (m - n) * o + n * p
		elif 2 * o <= p:
			return (m + n) * o
		else:
			return (n - m) * o + m * p
	k = fun(int(x), int(y), int(a), int(b))
	lst.append(k)
	i = i + 1
for thing in lst:
	print(thing)


t = int(input())
for _ in range(t):
	(x, y) = [int(i) for i in input().split(' ')]
	(a, b) = [int(i) for i in input().split(' ')]
	if a <= b / 2:
		print(a * (x + y))
		continue
	diff = abs(x - y)
	mini = min(x, y)
	print(a * abs(x - y) + b * mini)


t = int(input())
for i in range(t):
	(x, y) = input().split()
	(x, y) = (int(x), int(y))
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	pay = 0
	diff = abs(x - y)
	pay = pay + diff * a
	mn = min(2 * a, b)
	pay = pay + (max(x, y) - diff) * mn
	print(pay)


import math
import sys, collections
from sys import stdin, stdout

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

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

def get_string():
	return sys.stdin.readline().strip()

def input():
	return sys.stdin.readline().strip()

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')

def is_subsequence(x, y):
	x = list(x)
	for letter in y:
		if x and x[0] == letter:
			x.pop(0)
	return not x

def sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, mt.ceil(mt.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def getFactorization(x):
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def getFloor(A, x):
	(left, right) = (0, len(A) - 1)
	(ind, floor) = (-1, -1)
	while left <= right:
		mid = (left + right) // 2
		if x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			ind = mid
			left = mid + 1
	return ind

def check(st):
	n = len(st)
	digitSum = 0
	for i in range(0, n):
		digitSum = digitSum + int(st[i])
	return digitSum % 9 == 0

def isPowerOfTwo(n):
	if n == 0:
		return False
	while n != 1:
		if n % 2 != 0:
			return False
		n = n // 2
	return True

def kitte(n):
	c = 0
	while n != 0:
		n = n // 2
		c += 1
	return c

def aa(b, c):
	m = min(b, c)
	b -= m
	c -= m
	if c > 0 and b > 0:
		return m + (b + c) // 3
	else:
		return m

def bb(a, c):
	m = min(a, c)
	a -= m
	c -= m
	if c > 0 and a > 0:
		return m + (a + c) // 3
	else:
		return m

def cc(b, a):
	m = min(b, a)
	b -= m
	a -= m
	if a > 0 and b > 0:
		return m + (b + a) // 3
	else:
		return m
mod = 10 ** 9 + 7

def main():
	for tt in range(int(input())):
		(x, y) = get_ints()
		(a, b) = get_ints()
		if 2 * a <= b:
			print((x + y) * a)
		else:
			print(min(x, y) * b + (max(x, y) - min(x, y)) * a)
main()


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	c = abs(x - y)
	d = min(x, y)
	e = max(x, y)
	if x == 0 and y == 0:
		ans = 0
	elif b >= 2 * a:
		ans = (x + y) * a
	else:
		ans = d * b + c * a
	print(ans)


def solve():
	num_cases = int(input())
	for case in range(num_cases):
		(x, y) = [int(x) for x in input().split()]
		(a, b) = [int(x) for x in input().split()]
		if 2 * a <= b:
			cost = a * (x + y)
		else:
			cost = b * min(x, y) + a * abs(x - y)
		print(cost)
	return
solve()


def precio(x: int, y: int, a: int, b: int) -> int:
	res = 0
	if b < 2 * a:
		res = b * min(x, y)
		if x < y:
			y = y - x
			x = 0
			res = res + y * a
		else:
			x = x - y
			y = 0
			res = res + x * a
	else:
		res = x * a + y * a
	return res
t = 0
x = 0
y = 0
a = 0
b = 0
t = int(input())
for t in range(0, t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(precio(x, y, a, b))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	(x, y) = map(int, input().split())
	r = max(a, b)
	s = min(a, b)
	cost1 = (r - s) * x + s * y
	cost2 = x * abs(a - 0) + x * abs(b - 0)
	print(min(cost1, cost2))


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

def ii():
	return int(input())
testcases = int(input())
for t in range(testcases):
	(x, y) = li()
	(a, b) = li()
	sum = 0
	if 2 * a < b:
		sum += a * (x + y)
	else:
		dif = abs(x - y)
		sum += b * min(x, y) + a * dif
	print(sum)


s = 0
n = int(input())
for i in range(n):
	(x, y) = input().split()
	(a, b) = input().split()
	if int(a) * 2 >= int(b):
		if int(x) > int(y):
			o = int(y) * int(b)
			o += (int(x) - int(y)) * int(a)
		else:
			o = int(x) * int(b)
			o += (int(y) - int(x)) * int(a)
	else:
		o = (int(x) + int(y)) * int(a)
	print(o)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print(0)
		continue
	if x == 0:
		print(y * a)
		continue
	if y == 0:
		print(x * a)
		continue
	if b >= 2 * a:
		print((x + y) * a)
	else:
		d = abs(x - y)
		print(min(x, y) * b + d * a)


t = int(input())
for tt in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	cost1 = x * a + y * a
	if b < a:
		print(min(x, y) * b + (max(x, y) - min(x, y)) * a)
	else:
		print(min(cost1, min(x, y) * b + (max(x, y) - min(x, y)) * a))


t = int(input())
while t:
	t = t - 1
	l = list(map(int, input().split()))
	(x, y) = (l[0], l[1])
	l1 = list(map(int, input().split()))
	(a, b) = (l1[0], l1[1])
	(p, q) = (max(x, y), min(x, y))
	p1 = a * (p + q)
	p2 = a * (p - q) + b * q
	if p1 > p2:
		print(p2)
	else:
		print(p1)


from collections import Counter
import math
mod = 10 ** 9 + 7
for i in range(int(input())):
	ans = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	q = abs(x - y)
	ans += a * q
	z = min(x, y)
	x = z
	y = z
	if 2 * a < b:
		ans += 2 * x * a
	else:
		ans += y * b
	print(ans)


t = int(input())

def mini(h, i):
	if h > i:
		return i
	else:
		return h
while t:
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if a > b / 2.0:
		dol = b * mini(x, y) + abs(x - y) * a
	else:
		dol = a * (x + y)
	print(dol)
	t = t - 1


a = int(input())
for x in range(a):
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	answer = 0
	if b[0] * b[1] > 0 and 2 * c[0] > c[1]:
		b[0] = abs(b[0])
		b[1] = abs(b[1])
		b.sort()
		answer = b[0] * c[1] + c[0] * (b[1] - b[0])
	else:
		answer = c[0] * abs(b[0]) + c[0] * abs(b[1])
	print(answer)


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	f = 0
	minimum = min(x, y)
	while x > 0 and y > 0:
		if b < 2 * a:
			f += b * minimum
			x -= minimum
			y -= minimum
		else:
			f += a * minimum
			if x > y:
				y -= minimum
			else:
				x -= minimum
	while x > 0 and y == 0:
		f += a * x
		x -= x
	while x == 0 and y > 0:
		f += a * y
		y -= y
	print(f)


def f(x, y, a, b):
	ans = 0
	if x > y:
		ans += (x - y) * a
		ans += y * b
	else:
		ans += (y - x) * a
		ans += x * b
	if ans > (x + y) * a:
		ans = (x + y) * a
	print(ans)
t = int(input())
for _ in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	f(x, y, a, b)


def main(x, y, a, b):
	s1 = x * a + y * a
	s2 = (max(x, y) - min(x, y)) * a + min(x, y) * b
	return min(s1, s2)
t = int(input())
for i in range(t):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	print(main(x, y, a, b))


def solve():
	return a * abs(x - y) + min(b, 2 * a) * min(x, y)
t = int(input())
for i in range(1, t + 1):
	(x, y) = [int(s) for s in input().split(' ')]
	(a, b) = [int(s) for s in input().split(' ')]
	print(solve())


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x == 0 and y == 0:
		print('0')
	else:
		checksum = abs(x) * a + abs(y) * a
		difference = abs(abs(x) - abs(y))
		difference = difference * a
		difference = difference + min(x, y) * b
		if difference < checksum:
			print(difference)
		else:
			print(checksum)


def fn(x, y, a, b):
	if x == 0 and y == 0:
		return 0
	elif x == y:
		return min(x * b, 2 * x * a)
	else:
		return abs(x - y) * a + fn(min(x, y), min(x, y), a, b)
for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	print(fn(x, y, a, b))


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	input = sys.stdin.readline

def takeInput():
	return [int(x) for x in input().strip().split()]
t = int(input())
while t != 0:
	t -= 1
	(x, y) = takeInput()
	(a, b) = takeInput()
	ans = 0
	(x1, y1) = (abs(x), abs(y))
	ans1 = b * min(x1, y1) + a * abs(x1 - y1)
	ans2 = a * (x1 + y1)
	print(min(ans1, ans2))


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	equal = a * (max(x, y) - min(x, y))
	zero = b * min(x, y)
	one_by_one = a * (x + y)
	print(min(equal + zero, one_by_one))


def max_ele(x, y):
	if x > y:
		temp = x
		x = y
		y = temp
	return (x, y)
t = int(input())
while t:
	t -= 1
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	(x, y) = max_ele(x, y)
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	print((y - x) * a + min(b * x, 2 * x * a))


t = int(input())
for i in range(t):
	s = 0
	ss = 0
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < 0 and y < 0 or (x > 0 and y > 0):
		s = (max(abs(x), abs(y)) - min(abs(x), abs(y))) * a + min(abs(x), abs(y)) * b
		ss = (abs(x) + abs(y)) * a
	else:
		ss = (abs(x) + abs(y)) * a
		s = ss
	print(min(s, ss))


import math
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	(a, b) = [int(i) for i in input().split()]
	print(abs(x - y) * a + min(a * 2, b) * min(x, y))


import math

def main():
	for q in range(int(input())):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		ans = (max(x, y) - min(x, y)) * a
		if 2 * a > b:
			ans += min(x, y) * b
		else:
			ans += min(x, y) * 2 * a
		print(ans)
main()


import sys
input = sys.stdin.buffer.readline

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

def yo():
	for _ in range(int(input().strip())):
		(x, y) = map(int, input().split())
		(a, b) = map(int, input().split())
		change = x + y
		cost = 0
		if change == 0:
			print(0)
		elif b < 2 * a:
			smallest = min(x, y)
			cost += min(x, y) * b
			change -= smallest * 2
			cost += change * a
			print(cost)
		else:
			cost += change * a
			print(cost)
yo()


testes = int(input())
respostas = []
for x in range(testes):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	pagamento = 0
	if x > y:
		maior = x
		menor = y
	elif x < y:
		maior = y
		menor = x
	if x == 0 and y == 0:
		respostas.append(0)
	elif x == y:
		if a * x * 2 >= b * x:
			respostas.append(b * x)
		elif a * x * 2 < b * x:
			respostas.append(a * x * 2)
	elif x == 0 and y != 0:
		respostas.append(y * a)
	elif x != 0 and y == 0:
		respostas.append(x * a)
	elif x != y:
		if a * (x + y) >= b * menor + a * (x - menor + (y - menor)):
			respostas.append(b * menor + a * (x - menor + (y - menor)))
		elif a * (x + y) < b * menor + a * (x - menor + (y - menor)):
			respostas.append(a * (x + y))
for x in respostas:
	print(x)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(x, y) = [int(c) for c in input().split()]
	(a, b) = [int(c) for c in input().split()]
	(x, y) = (min(x, y), max(x, y))
	ans1 = (x + y) * a
	ans2 = x * b + (y - x) * a
	ans = min(ans1, ans2)
	print(ans)


for t in range(int(input())):
	(x, y) = list(map(int, input().split()))
	(a, b) = list(map(int, input().split()))
	c1 = a * abs(x - y) + b * min(y, x)
	c2 = a * x + a * y
	print(min(c1, c2))


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	if x < y:
		x1 = x
		y1 = y
	else:
		x1 = y
		y1 = x
	d1 = b * x1 + (y1 - x1) * a
	d2 = (y1 - x1) * a + x1 * b
	d3 = y1 * a + x1 * a
	m = min(d1, d2, d3)
	print(m)


n = int(input())
for i in range(0, n):
	sum = 0
	l = []
	(x, y) = (int(x) for x in input().split())
	(a, b) = (int(x) for x in input().split())
	l.append(x)
	l.append(y)
	if x >= 0 and y >= 0 or (x <= 0 and y <= 0):
		if 2 * a > b:
			z = min(l)
			sum1 = b * z
			sum2 = (max(l) - min(l)) * a
			print(sum1 + sum2)
		elif x >= 0 and y >= 0:
			print((x + y) * a)
		else:
			print((x + y) * a * -1)
	elif x > 0 and y < 0:
		print(x * a + y * a * -1)
	else:
		print(x * a * -1 + y * a)


import math
import bisect

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

def list_input():
	return list(num_input())
for _ in range(int(input())):
	(x, y) = num_input()
	(a, b) = num_input()
	if b >= 2 * a:
		ans = (x + y) * a
	elif x < y:
		ans = b * x + (y - x) * a
	else:
		ans = b * y + (x - y) * a
	print(ans)


def solution(x, y, a, b):
	if x > 0 and y > 0 or (x < 0 and y < 0):
		if b < 2 * a:
			k = min(abs(x), abs(y))
			m = max(abs(x), abs(y))
			return k * b + a * (m - k)
		else:
			return a * (abs(x) + abs(y))
	else:
		return a * (abs(x) + abs(y))
n = int(input())
for i in range(n):
	(x, y) = map(int, input().split(' '))
	(a, b) = map(int, input().split(' '))
	print(solution(x, y, a, b))


def calculate(x, y, a, b):
	f = (x + y) * a
	s = min(abs(x), abs(y)) * b + (max(abs(x), abs(y)) - min(abs(x), abs(y))) * a
	r = min(f, s)
	return r
n = int(input())
for i in range(n):
	nums = list(map(int, input().split()))
	prices = list(map(int, input().split()))
	r = calculate(*nums, *prices)
	print(r)


import math, sys
import heapq
from fractions import Fraction
from collections import Counter, defaultdict

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

def ls():
	return list(map(int, list(input())))

def la():
	return list(input())

def ii():
	return int(input())

def dic(x):
	return defaultdict(lambda : x)

def isPrime(n):
	i = 2
	if n == 1:
		return False
	while i <= int(math.sqrt(n)):
		if n % i == 0:
			return False
		i = i + 1
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def binarySearch(arr, x):
	(l, r) = (0, len(arr) - 1)
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return True
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return False
t = ii()
for _ in range(t):
	(x, y) = li()
	(a, b) = li()
	total = abs(x - y) * a
	if min(x, y) * 2 * a < b * min(x, y):
		total += min(x, y) * 2 * a
	else:
		total += b * min(x, y)
	print(total)


import sys
input = sys.stdin.readline
import heapq
import copy
import math

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def bin_search(arr, l, r, val):
	if arr[r] <= val:
		return r + 1
	if r - l < 2:
		if arr[l] > val:
			return l
		else:
			return r
	mid = int((l + r) / 2)
	if arr[mid] <= val:
		return bin_search(arr, mid, r, val)
	else:
		return bin_search(arr, l, mid, val)

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	for test in range(tests):
		[x, y] = inlt()
		[a, b] = inlt()
		if b > 2 * a:
			print(a * (x + y))
		else:
			X = min(x, y)
			Y = max(x, y)
			print(b * X + a * (Y - X))
	return 0
main()


import sys
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

class Solution:

	def func(self, x, y, a, b):
		if abs(x) < abs(y):
			temp = x
			x = y
			y = temp
		if 2 * a > b:
			if x * y >= 0:
				return abs(y) * b + abs(x - y) * a
			else:
				return a * (abs(x) + abs(y))
		else:
			return a * (abs(x) + abs(y))
sol = Solution()
n = inp()
for _ in range(n):
	(x, y) = invr()
	(a, b) = invr()
	print(Solution.func(sol, x, y, a, b))


t = int(input())
for _ in range(t):
	(x, y) = (int(i) for i in input().split())
	(a, b) = (int(i) for i in input().split())
	total = 0
	if 2 * a <= b:
		total = a * (x + y)
	else:
		M = max(x, y)
		m = min(x, y)
		total = b * m + a * (M - m)
	print(total)


from math import *
for zz in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	d1 = abs(x)
	d2 = abs(y)
	if x >= 0 and y >= 0 or (x <= 0 and y <= 0):
		print(min((min(d1, d2) * b + (max(d2, d1) - min(d1, d2)) * a, d2 * a + d1 * a)))
	else:
		print(min(d2 * a + d1 * a, min(d2, d1) * b + (d1 + d2) * a))


for z in range(int(input())):
	(x, y) = map(int, input().split())
	(a, b) = map(int, input().split())
	count = 0
	cost = 0
	if x == y == 0:
		print(count)
		continue
	else:
		if 2 * a >= b:
			val = abs(x - y)
			numb = max(x, y) - val
			cost = val * a + numb * b
		if 2 * a < b:
			cost = (x + y) * a
	print(cost)


def main():
	t = int(input())
	for i in range(t):
		(x, y) = [int(x) for x in input().split(' ')]
		(a, b) = [int(x) for x in input().split(' ')]
		if 2 * a <= b:
			print((abs(x) + abs(y)) * a)
			continue
		total = 0
		while x != 0 or y != 0:
			if x > 0 and y > 0:
				operations = min(x, y)
				total += b * operations
				x -= operations
				y -= operations
			elif x < 0 and y < 0:
				operations = min(-x, -y)
				total += b * operations
				x += operations
				y += operations
			else:
				total += (abs(x) + abs(y)) * a
				break
		print(total)
		continue
main()


for nt in range(int(input())):
	(x, y) = map(int, input().split())
	(x2, y2) = map(int, input().split())
	ans = 0
	ans += abs(x - y) * x2
	print(ans + min(2 * x2 * min(x, y), y2 * min(x, y)))