#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto &x : a) cin >> x;
    for (auto &x : b) cin >> x;
    int first_diff = -1;
    int last_diff = -1;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        first_diff = i;
        break;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] != b[i]) {
        last_diff = i;
        break;
      }
    }
    if (first_diff == -1) {
      cout << "YES\n";
    } else {
      bool fucked = false;
      int diff = a[first_diff] - b[first_diff];
      if (diff > 0) fucked = true;
      for (int i = first_diff; i <= last_diff; i++) {
        if (a[i] - b[i] != diff) {
          fucked = true;
        }
      }
      if (fucked)
        cout << "NO\n";
      else
        cout << "YES\n";
    }
  }
}
