#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, d = 0;
    bool res = true, done = false;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) {
      if ((b[i] < a[i]) || (done && b[i] - a[i] != 0) ||
          (d && b[i] - a[i] != 0 && b[i] - a[i] != d)) {
        res = false;
        break;
      }
      if (b[i] > a[i]) d = b[i] - a[i];
      if (d && b[i] == a[i]) done = true;
    }
    if (res)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
