#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-ffloat-store")
#pragma GCC optimize("-fno-defer-pop")
int main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T;
  cin >> T;
  while (T--) {
    long long int n;
    cin >> n;
    long long int arr[n + 1], brr[n + 1];
    for (long long int i = 0; i < n; i++) cin >> arr[i];
    for (long long int i = 0; i < n; i++) cin >> brr[i];
    map<long long int, long long int> mp;
    long long int flg = 0;
    long long int st = -1;
    for (long long int i = 0; i < n; i++) {
      if (arr[i] != brr[i]) {
        st = i;
        break;
      }
    }
    if (st != -1) {
      long long int diff = brr[st] - arr[st];
      if (diff < 0) {
        flg = 1;
      } else {
        for (long long int i = st; i < n; i++) {
          if (arr[i] != brr[i]) {
            long long int x = brr[i] - arr[i];
            if (x != diff) {
              flg = 1;
              break;
            }
          } else {
            for (long long int j = i; j < n; j++) {
              if (arr[j] != brr[j]) {
                flg = 1;
                break;
              }
            }
            break;
          }
        }
      }
    }
    if (flg)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
