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