#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int ar[n], ck = 1;
    for (int i = 0; i < n; i++) {
      cin >> ar[i];
    }
    int br[n], cr[n];
    for (int i = 0; i < n; i++) {
      cin >> br[i];
      if (ar[i] > br[i]) {
        ck = 0;
      }
    }
    for (int i = 0; i < n; i++) {
      cr[i] = br[i] - ar[i];
    }
    int l = 0, r = n - 1;
    for (int i = 0; i < n; i++) {
      if (cr[i] != 0) {
        break;
      }
      l++;
    }
    for (int i = n - 1; i >= 0; i--) {
      if (cr[i] != 0) {
        break;
      }
      r--;
    }
    int dif = cr[l];
    for (int i = 1 + l; i <= r; i++) {
      if (cr[i] != dif) {
        ck = 0;
      }
    }
    if (ck) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
