#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    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];
    }
    bool ok = true;
    vector<int> A;
    for (int i = 0; i < (n); i++) {
      if (b[i] < a[i]) {
        ok = false;
        break;
      }
      if (a[i] != b[i]) A.push_back(i);
    }
    if (ok && A.size() > 0) {
      int k = b[A[0]] - a[A[0]];
      for (int i = 1; i < A.size(); i++) {
        int x = A[i];
        if (A[i] - A[i - 1] != 1) {
          ok = false;
          break;
        } else if (b[x] - a[x] != k) {
          ok = false;
          break;
        }
      }
    }
    cout << (ok ? "YES" : "NO") << endl;
  }
}
