#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve() {
int n;
cin >> n;
int a[n], b[n];
for (int& i : a) cin >> i;
for (int& i : b) cin >> i;
bool can = true;
for (int i = 0; i < n - 3; i++) {
if (b[i] == a[i]) continue;
//simulate the operation
if ((b[i] - a[i]) == (a[i + 1] + a[i + 2])) {
a[i] += a[i + 1] + a[i + 2];
a[i + 3] += a[i + 1] + a[i + 2];
int t = a[i + 1];
a[i + 1] = -a[i + 2];
a[i + 2] = -t;
}
else {
can = false;
break;
}
}
for (int i = 0; i < n; i++) {
can &= a[i] == b[i];
}
cout << (can ? "yes" : "no") << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
solve();
}
}
Problem Link: Operating on A Practice Coding Problem - CodeChef
Please Help. Thank You.