#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    bool bb = false;
    int n;
    cin >> n;
    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 diff = 0;
    bool res = true;
    for (int i = 0; i < n; i++)
      if (a[i] != b[i]) {
        if (bb || (diff && a[i] - b[i] != diff)) {
          res = false;
          break;
        }
        diff = a[i] - b[i];
      } else if (diff)
        bb = true;
    res &= diff <= 0;
    if (res)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
