#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < (int)(n); i++) cin >> a[i];
    for (int i = 0; i < (int)(n); i++) cin >> b[i];
    string ret = "YES";
    bool first = false;
    int prev = 0;
    for (int i = 0; i < (int)(n); i++) {
      int dif = b[i] - a[i];
      if (dif < 0) ret = "NO";
      if (prev != dif) {
        if (!first)
          first = true;
        else if (dif != 0)
          ret = "NO";
      }
      prev = dif;
    }
    cout << ret << endl;
  }
}
