#include <bits/stdc++.h>
using namespace std;
int a[100005], n, T, x, kt;
string kq;
int main() {
  cin >> T;
  while (T--) {
    cin >> n;
    kq = "YES";
    kt = 0;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    for (int i = 1; i <= n; ++i) {
      cin >> x;
      a[i] = x - a[i];
      if (a[i] < 0) kq = "NO";
      if (a[i] != a[i - 1]) kt++;
    }
    if (kt > 2 || (kt == 2 && a[n] != 0)) kq = "NO";
    cout << kq << '\n';
  }
  return 0;
}
