#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <list>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <string.h>

using namespace std;

#define REP(i,n) for (decltype(n) i = 0; i < n; i++)

using ll = long long;
using ivec = vector<int>;
using lvec = vector<long>;
using ipair = pair<int, int>;
using llvec = vector<ll>;
using llpair = pair<ll, ll>;
#define umap unordered_map
#define uset unordered_set

#define THE_MOD 1000000007

template<typename T>
vector<T> read_args()
{
	T N;
	cin >> N;
	vector<T> v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

template<class T>
void sort(T& v)
{
	sort(v.begin(), v.end());
}

template<class T>
void rsort(T& v)
{
	sort(v.begin(), v.end(), greater<typename T::value_type>());
}

void answer(bool b)
{
	cout << (b ? "Yes" : "No") << endl;
}




ll run()
{
//	int a,b,c; cin>>a>>b>>c;
	int a,b,x,y;cin >> a>>b>>x>>y;
	if (a == b) {
		return x;
	}
	if (a < b) {
		int t1 = (b - a) * y + x;
		int t2 = (b - a) * (2 * x) + x;
		return min(t1, t2); 
	}
	{
		int t1 = (a - b - 1) * y + x;
		int t2 = (a - b - 1) * (2 * x) + x;
		return min(t1, t2); 
	}
}

int main()
{
	// std::setprecision(15)
	auto r = run();
	cout << r << endl;
	return 0;
}

#include <iostream>

using namespace std;
#define ll long long

const ll mod = 1e9 + 7;
const ll MAX = 2e5 + 1;

ll t;

ll power(ll x, ll p) {
  ll ans = 1;
  while (p) {
    if (p & 1) {
      ans = (ans * x) % mod;
      p--;
    }
    x = (x * x) % mod;
    p >>= 1;
  }
  return ans;
}

ll add(ll x, ll y) { return ((x % mod) + (y % mod)) % mod; }
ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod; }
ll sub(ll x, ll y) { return ((x % mod) - (y % mod) + mod) % mod; }
ll nC2(ll x) { return mul(mul(x, x - 1), power(2, mod - 2)); }

void Solve() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (a + b > n) {
    cout << 0 << endl;
    return;
  }
  ll tot = mul(mul(4, nC2(n - a - b + 2)), mul(n - a + 1, n - b + 1));
  ll overlap = mul(4, mul(nC2(n - a - b + 2), nC2(n - a - b + 2)));
  ll ans = sub(tot, overlap);
  cout << ans << endl;
}

signed main() {
  cin >> t;
  while (t--) {
    Solve();
  }
}