#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int l = 0, r = 0, k = 0, flag = 1;
    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];
    for (int i = 0; i < (int)(n); ++i) {
      if (b[i] - a[i] > 0) {
        l = i;
        k = b[i] - a[i];
        break;
      }
    }
    for (int i = (int)(n)-1; i >= 0; --i) {
      if (b[i] - a[i] > 0) {
        r = i;
        break;
      }
    }
    for (int z = l; z <= r; z++) {
      a[z] += k;
    }
    for (int i = 0; i < (int)(n); ++i) {
      if (a[i] != b[i]) {
        cout << "NO" << endl;
        flag = 0;
        break;
      }
    }
    if (flag == 1) cout << "YES" << endl;
  }
  return 0;
}
