#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], b[maxn];
int main() {
  int n, x, T;
  cin >> T;
  while (T--) {
    cin >> n;
    set<int> s;
    s.clear();
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
    }
    int l = 1, r = n;
    while (l <= n && a[l] == b[l]) l++;
    while (r >= 1 && a[r] == b[r]) r--;
    if (l > r) {
      cout << "YES\n";
      continue;
    }
    int flag = 1;
    if (a[l] - b[l] > 0) flag = 0;
    for (int i = l + 1; i <= r; i++) {
      if (a[l] - b[l] != a[i] - b[i]) flag = 0;
    }
    if (flag)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
