#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int test = 0; test < t; test++) {
    int n;
    cin >> n;
    vector<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];
    }
    int i = 0;
    for (; i < n && a[i] == b[i]; i++)
      ;
    if (i == n) {
      cout << "YES" << endl;
    } else {
      int d = b[i] - a[i];
      if (d < 0) {
        cout << "NO" << endl;
      } else {
        for (; i < n && a[i] + d == b[i]; i++)
          ;
        for (; i < n && a[i] == b[i]; i++)
          ;
        if (i == n) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
      }
    }
  }
}
