#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n), v1(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) cin >> v1[i];
  int ind = -1, ind1 = -1;
  for (int i = 0; i < n; i++) {
    if (v[i] != v1[i]) {
      ind = i;
      break;
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (v[i] != v1[i]) {
      ind1 = i;
      break;
    }
  }
  if (ind == -1 || ind1 == -1) {
    cout << "YES\n";
  } else {
    set<int> s;
    int diff = 0;
    for (int i = ind; i <= ind1; i++) {
      s.insert(v1[i] - v[i]);
      diff = v1[i] - v[i];
    }
    if ((int)s.size() == 1 && diff > 0)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
int main() {
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
