#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int j = 0; j < n; j++) cin >> a[j];
    for (int j = 0; j < n; j++) cin >> b[j];
    int g = 0, r = 0, f = 0, kd = 0;
    for (int j = 0; j < n; j++) {
      if (b[j] != a[j]) {
        if (f == 1) {
          cout << "NO" << endl;
          kd = 1;
          break;
        }
        if (g == 0) {
          r = b[j] - a[j];
          if (r < 0) {
            cout << "NO" << endl;
            kd = 1;
            break;
          }
          g = 1;
        } else {
          if (b[j] - a[j] != r) {
            cout << "NO" << endl;
            kd = 1;
            break;
          }
        }
      } else {
        if (g == 1) f = 1;
        g = 0;
      }
    }
    if (kd == 0) {
      if (f > 1)
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    }
  }
}
