#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    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 stage = 0;
    int diff;
    bool yes = true;
    for (int i = 0; i < n; i++) {
      switch (stage) {
        case 0:
          if (a[i] != b[i]) {
            stage = 1;
            diff = b[i] - a[i];
            if (diff < 0) yes = false;
          }
          break;
        case 1:
          if (a[i] == b[i]) {
            stage = 2;
            break;
          }
          if (b[i] - a[i] != diff) yes = false;
          break;
        case 2:
          if (a[i] != b[i]) yes = false;
          break;
      }
      if (!yes) break;
    }
    if (yes)
      cout << "YES" << '\n';
    else
      cout << "NO" << '\n';
  }
  return 0;
}
