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