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