#include <bits/stdc++.h>
using namespace std;
const long long MXN = 1e6 + 7;
const long long INF = 2e18 + 7;
long long q, a[MXN], b[MXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> q;
  while (q--) {
    bool flag = true;
    long long n, mn = 0, l = 1, r = 1;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
    }
    for (int i = 1; i <= n; i++) {
      cin >> b[i];
    }
    for (int i = 1; i <= n; i++) {
      if (b[i] - a[i] < 0) {
        flag = false;
      }
    }
    for (int i = 1; i <= n; i++) {
      if (!mn && b[i] - a[i] > 0) {
        l = i;
        r = i;
        mn = b[i] - a[i];
      } else if (b[i] - a[i] == mn) {
        r = i;
      } else if (mn > 0 && b[i] - a[i] != 0 && b[i] - a[i] != mn) {
        flag = false;
        break;
      }
    }
    for (int i = l; i <= r; i++) {
      a[i] += mn;
    }
    for (int i = 1; i <= n; i++) {
      if (a[i] != b[i]) {
        flag = false;
      }
    }
    if (flag) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
