#include <bits/stdc++.h>
using namespace std;
long long T;
long long n;
long long a[100005], b[100005];
int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> T;
  for (int t = 0; t < T; t++) {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    long long l = 1e18, r = -1e18;
    for (long long i = 1; i <= n; i++) {
      if (a[i] != b[i]) {
        l = min(l, i);
        r = max(r, i);
      }
    }
    if (l > n) {
      cout << "YES" << endl;
      continue;
    }
    for (int i = l; i <= r; i++) {
      if (a[i] > b[i] || b[l] - a[l] != b[i] - a[i]) {
        cout << "NO" << endl;
        goto end;
      }
    }
    cout << "YES" << endl;
  end:;
  }
  return 0;
}
