#include <bits/stdc++.h>
using namespace std;
void solve(vector<long long> &a, vector<long long> &b, long long n) {
  long long diff;
  long long i;
  for (i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      cout << "NO\n";
      return;
    } else if (a[i] < b[i]) {
      diff = b[i] - a[i];
      break;
    }
  }
  if (i == n) {
    cout << "YES\n";
    return;
  }
  for (; i < n; i++) {
    if (a[i] > b[i]) {
      cout << "NO" << '\n';
      return;
    } else if (a[i] == b[i])
      break;
    else if (b[i] - a[i] != diff) {
      cout << "NO\n";
      return;
    }
  }
  for (; i < n; i++) {
    if (a[i] != b[i]) {
      cout << "NO" << '\n';
      return;
    }
  }
  cout << "YES\n";
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (long long i = 0; i < n; i++) {
      cin >> b[i];
    }
    solve(a, b, n);
  }
  return 0;
}
