#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    int n, c, l = 0, r = 0, d, zero = 0, minus = 0, k = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
      cin >> c;
      c = c - a[i];
      if (!c)
        zero++;
      else if (c < 0)
        minus++;
      else if (k) {
        if (d != c) minus++;
        r = i;
      } else {
        l = i;
        k = 1;
        r = i;
        d = c;
      }
    }
    if (minus)
      cout << "NO";
    else if ((zero + r - l + k) == n)
      cout << "YES";
    else
      cout << "NO";
    cout << endl;
  }
}
