#include <bits/stdc++.h>
using namespace std;
template <class T> int sgn(T x) { return (x > 0) - (x < 0); }
template<class T>
struct Point {
typedef Point P;
T x, y;
explicit Point(T x=0, T y=0) : x(x), y(y) {}
bool operator<(P p) const { return tie(x,y) < tie(p.x,p.y); }
bool operator==(P p) const { return tie(x,y)==tie(p.x,p.y); }
P operator+(P p) const { return P(x+p.x, y+p.y); }
P operator-(P p) const { return P(x-p.x, y-p.y); }
P operator*(T d) const { return P(x*d, y*d); }
P operator/(T d) const { return P(x/d, y/d); }
T dot(P p) const { return x*p.x + y*p.y; }
T cross(P p) const { return x*p.y - y*p.x; }
T cross(P a, P b) const { return (a-*this).cross(b-*this); }
T dist2() const { return x*x + y*y; }
double dist() const { return sqrt((double)dist2()); }
// angle to x-axis in interval [-pi, pi]
double angle() const { return atan2(y, x); }
P unit() const { return *this/dist(); } // makes dist()=1
P perp() const { return P(-y, x); } // rotates +90 degrees
P normal() const { return perp().unit(); }
// returns point rotated 'a' radians ccw around the origin
P rotate(double a) const {
return P(x*cos(a)-y*sin(a),x*sin(a)+y*cos(a)); }
friend ostream& operator<<(ostream& os, P p) {
return os << "(" << p.x << "," << p.y << ")"; }
};
using P = Point<int64_t>;
const int64_t INF = 4E18;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t; cin >> t;
while (t--) {
int n; cin >> n;
vector<int> f(n);
for (int i = 0; i < n; i++) {
cin >> f[i];
}
vector<P> pts(n);
for (int i = 0; i < n; i++) {
cin >> pts[i].x >> pts[i].y;
}
vector dp(n, vector(n + 1, vector<int64_t>(2, -INF)));
for (int i = 0; i < n; i++) {
for (int len = 1; len <= n; len++) {
int j = (i + len) % n;
if (f[i] == f[j]) {
dp[i][len][0] = 0;
}
}
}
auto area = [](P a, P b, P c) {
return abs(a.cross(b) + b.cross(c) + c.cross(a));
};
int64_t ans = 0;
for (int len = 0; len <= n; len++) {
for (int i = 0; i < n; i++) {
for (int typ = 0; typ < 2; typ++) {
if (dp[i][len][typ] < 0) {
continue;
}
// cerr << i << " " << len << " " << typ << ": " << dp[i][len][typ] << '\n';
if (typ == 0) {
assert(f[i] == f[(i + len) % n]);
ans = max(ans, dp[i][len][0]);
}
int j = (i + len) % n;
for (int nxt = 1; nxt + len <= n; nxt++) {
if (typ == 0) {
int ni = (i - nxt + n) % n;
// cerr << " -> " << ni << " " << len + nxt << " " << 1 << ": " << dp[i][len][0] + area(pts[i], pts[j], pts[ni]) << '\n';
dp[ni][len + nxt][1] = max(dp[ni][len + nxt][1], dp[i][len][0] + area(pts[i], pts[j], pts[ni]));
} else {
int nj = (j + nxt) % n;
if (f[i] == f[nj]) {
// cerr << " -> " << i << " " << len + nxt << " " << 0 << ": " << dp[i][len][1] + area(pts[i], pts[j], pts[nj]) << '\n';
dp[i][len + nxt][0] = max(dp[i][len + nxt][0], dp[i][len][1] + area(pts[i], pts[j], pts[nj]));
}
}
}
}
}
}
cout << ans << '\n';
}
}