#include <bits/stdc++.h>
const int MAX_N = 1e5 + 5;
int t, n, a[MAX_N], b[MAX_N];
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
    for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
    int l = 0, r = n - 1;
    while (a[l] == b[l] && l <= n) ++l;
    while (a[r] == b[r] && r >= 0) --r;
    int dif = std::min(0, a[l] - b[l]);
    for (int j = l; j <= r; ++j)
      if (a[j] - b[j] != dif) {
        printf("NO\n");
        goto done;
      }
    printf("YES\n");
  done:
    continue;
  }
  return 0;
}
