#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int i = 0;
  while (i < n && b[i] - a[i] == 0) i++;
  if (i >= n) {
    cout << "YES\n";
    return;
  }
  int j = n - 1;
  while (b[j] - a[j] == 0) j--;
  int k = b[i] - a[i];
  if (k < 0) {
    cout << "NO\n";
    return;
  }
  for (; i <= j; i++)
    if (b[i] - a[i] != k) {
      cout << "NO\n";
      return;
    }
  cout << "YES\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int m, n, p, q, r, t, u, v, x, y, z;
  string s1, s2, s3;
  cin >> t;
  while (t--) solve();
}
