#include <bits/stdc++.h>
using namespace std;
template <class T>
bool mini(T &a, T b) {
  return a > b ? (a = b, 1) : 0;
}
template <class T>
bool maxi(T &a, T b) {
  return a < b ? (a = b, 1) : 0;
}
const int maxN = 1e5 + 5;
int n, t;
bool res;
int a[maxN], b[maxN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    res = true;
    for (long long i = (1), _b = (n); i <= (_b); i++) cin >> a[i];
    vector<pair<long long, long long> > c;
    for (long long i = (1), _b = (n); i <= (_b); i++) {
      cin >> b[i];
      if (a[i] > b[i]) res = false;
      if (a[i] < b[i]) c.push_back(pair<long long, long long>(b[i] - a[i], i));
    }
    if (!res) {
      cout << "NO\n";
      continue;
    }
    if ((int)(c).size()) {
      int k = c[0].first;
      for (long long i = (0), _b = ((int)(c).size()); i < (_b); i++)
        if (c[i].first != k) {
          res = false;
          break;
        }
      if (c[(int)(c).size() - 1].second - c[0].second + 1 != (int)(c).size())
        res = false;
    }
    if (res)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
