#include <bits/stdc++.h>
using namespace std;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const long long LINF = 1000000000000000000;
const long long MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline void add(T& a, T b) {
  a = ((a + b) % MOD + MOD) % MOD;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (int T = 0; T < t; T++) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int cnt = 0;
    bool ok = true;
    int sa = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        while (i < n && a[i] != b[i]) {
          if (a[i] > b[i]) {
            ok = false;
            break;
          }
          if (sa == 0)
            sa = b[i] - a[i];
          else {
            if (sa != b[i] - a[i]) {
              ok = false;
              break;
            }
          }
          i++;
        }
        cnt++;
      }
    }
    if (!ok)
      cout << "NO" << endl;
    else if (cnt <= 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
