#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn], b[maxn];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) a[i] -= b[i];
    int s = -1;
    for (int i = 0; i < n; ++i)
      if (a[i]) {
        s = i;
        break;
      }
    if (s == -1)
      cout << "YES\n";
    else {
      if (a[s] > 0) {
        cout << "NO\n";
      } else {
        int i = s + 1;
        while (i < n && a[i] == a[s]) ++i;
        while (i < n && a[i] == 0) ++i;
        if (i == n)
          cout << "YES\n";
        else
          cout << "NO\n";
      }
    }
  }
  return 0;
}
