#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int& x : a) {
      cin >> x;
    }
    vector<int> b(n);
    for (int& x : b) {
      cin >> x;
    }
    int l = 0, r = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        l = i;
        break;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] != b[i]) {
        r = i;
        break;
      }
    }
    bool ok = true;
    int d = a[l] - b[l];
    for (int i = l; i <= r; i++) {
      if (a[i] - b[i] != d or a[i] > b[i]) {
        ok = false;
        break;
      }
    }
    cout << ((ok) ? "YES\n" : "NO\n");
  }
}
