#include <bits/stdc++.h>
using namespace std;
int t, n;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> a(n), b(n);
    for (int &it : a) cin >> it;
    int nr = 0;
    bool neg = 0, ok = 0;
    for (int i = 0; i < n; ++i) {
      cin >> b[i];
      if (b[i] - a[i] < 0) neg = 1;
      if (b[i] - a[i]) {
        if (!(b[i - 1] - a[i - 1]) || !i)
          ++nr;
        else if (b[i - 1] - a[i - 1] != b[i] - a[i])
          ok = 1;
      }
    }
    cout << ((!ok && !neg && nr <= 1) ? "YES\n" : "NO\n");
  }
  return 0;
}
