#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto& e : a) cin >> e;
    for (auto& e : b) cin >> e;
    int diff = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] > b[i]) {
        diff = -1;
        break;
      }
      if (a[i] < b[i]) {
        if (0 == diff) {
          diff = b[i] - a[i];
          for (; i < n && a[i] + diff == b[i]; ++i) {
          }
          --i;
        } else {
          diff = -1;
          break;
        }
      }
    }
    puts(diff >= 0 ? "YES" : "NO");
  }
  return 0;
}
