#include <bits/stdc++.h>
using namespace std;
long long int nChooseR(int n, int k);
long long int gcd(long long int a, long long int b);
vector<string> split(string target, char c);
bool isPrime(long long int h);
long long int n, m, x, y, l, r, k, a[200005], b[200005], t;
long long int ans;
int mod = (int)(1e9 + 7);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < (int)(n); i++) cin >> a[i];
    for (int i = 0; i < (int)(n); i++) cin >> b[i];
    ans = 0;
    l = 1e6;
    r = 0;
    for (int i = 0; i < (int)(n); i++) {
      if (a[i] > b[i]) {
        ans = -1;
        break;
      } else if (a[i] != b[i])
        l = min(l, (long long int)i), r = max(r, (long long int)i),
        ans = b[i] - a[i];
    }
    if (ans == -1) {
      cout << "NO\n";
      continue;
    }
    if (ans == 0) {
      cout << "YES\n";
      continue;
    }
    for (int i = (l); i < (int)(r + 1); i++) {
      if (b[i] - a[i] != ans) {
        ans = -1;
        break;
      }
    }
    if (ans == -1)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
}
long long int nChooseR(int n, int k) {
  if (k > n) return 0;
  if (k * 2 > n) k = n - k;
  if (k == 0) return 1;
  long long int result = n;
  for (int i = 2; i <= k; ++i) {
    result *= (n - i + 1);
    result /= i;
  }
  return result;
}
long long int gcd(long long int a, long long int b) {
  return b == 0 ? a : gcd(b, a % b);
}
vector<string> split(string target, char c) {
  string d = "";
  vector<string> arr;
  for (auto n : target) {
    if (n != c)
      d += n;
    else if (d != "")
      arr.push_back(d), d = "";
  }
  if (d != "") arr.push_back(d), d = "";
  return arr;
}
bool isPrime(long long int g) {
  if ((g % 2 == 0 && g > 2) || g == 1) return 0;
  for (long long int i = 3; i * i <= g; i += 2)
    if (g % i == 0) return 0;
  return 1;
}
