#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, r;
  cin >> t;
  vector<bool> bb;
  while (t) {
    t--;
    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];
    int co = 1, l = 0, k;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        if (co == 1) {
          if (l == 0) {
            k = b[i] - a[i];
            l++;
            if (k < 0) {
              bb.push_back(0);
              goto s2;
            }
          } else {
            if (b[i] - a[i] != k) {
              bb.push_back(0);
              goto s2;
            }
          }
        } else {
          bb.push_back(0);
          goto s2;
        }
      } else {
        if (l != 0) co++;
      }
    }
    bb.push_back(1);
  s2:;
  }
  for (int i = 0; i < bb.size(); i++) {
    if (bb[i] == 1)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
