#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    bool no(false), flag(true);
    int mark(-1), cnt(0), foo(0);
    for (int i = 0; i < n; i++) {
      foo = b[i] - a[i];
      if (foo < 0) {
        no = true;
        break;
      }
      if (foo == 0) {
        mark = -1;
        continue;
      }
      if (mark == -1) {
        cnt++;
        mark = foo;
        continue;
      }
      if (mark != foo) {
        cnt++;
        mark = foo;
      }
    }
    cout << (cnt <= 1 && !no ? "YES" : "NO") << '\n';
  }
}
