#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
long long me(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  if (x == 0) return 0;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  c_p_c();
  long long t;
  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 i = 0; i < n; i++) cin >> b[i];
    long long c[n];
    multiset<long long> s;
    long long l = 0;
    vector<long long> v;
    long long g = 0;
    long long temp = 0;
    long long g1 = 0;
    for (long long i = 0; i < n; i++) {
      c[i] = b[i] - a[i];
      if (c[i] == 0 && g1 == 1) {
        break;
      }
      if (c[i] < 0) {
        cout << "NO\n";
        l = 1;
        break;
      }
      if (c[i] != 0 && (temp == c[i] || g == 0)) {
        a[i] = a[i] + c[i];
        temp = c[i];
        g = 1;
        g1 = 1;
      }
    }
    if (l == 1) {
      continue;
    }
    long long flg = 0;
    for (long long i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        flg = 1;
        break;
      }
    }
    if (flg == 1) {
      cout << "NO\n";
    } else {
      cout << "YES\n";
    }
  }
  return 0;
}
