#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long par[100005];
long long parent(long long i) {
  while (par[i] != i) {
    par[i] = par[par[i]];
    i = par[i];
  }
  return i;
}
void uni(long long x, long long y) {
  long long parx = parent(x);
  long long pary = parent(y);
  par[parx] = pary;
}
int main() {
  long long t = 1;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    long long b[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long j = 0; j < n; j++) cin >> b[j];
    long long diff[n];
    for (long long i = 0; i < n; i++) {
      diff[i] = b[i] - a[i];
    }
    long long i = 0;
    for (i = 0; i < n; i++) {
      if (diff[i] != 0) break;
    }
    long long c = i;
    for (; i < n; i++) {
      if (diff[i] != diff[c]) break;
    }
    long long f = 1;
    for (; i < n; i++) {
      if (diff[i] != 0) {
        f = 0;
        break;
      }
    }
    if (diff[c] < 0 || f == 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
