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