#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c = 0, n, t, i, j, flag = 0, sum, f;
  string s, s1, s2;
  cin >> t;
  while (t--) {
    cin >> n;
    c = 0, sum = 0, flag = 0, f = 0;
    int ara[n], ara1[n];
    for (i = 0; i < n; i++) {
      cin >> ara[i];
    }
    for (i = 0; i < n; i++) {
      cin >> ara1[i];
    }
    for (i = 0; i < n; i++) {
      if (ara[i] != ara1[i]) {
        c = (ara1[i] - ara[i]);
        flag = 1;
      }
      if (flag) break;
    }
    for (i = 0; i < n; i++) {
      if (ara[i] == ara1[i])
        sum++;
      else if (ara[i] < ara1[i] && f == 0) {
        if (ara[i] + c == ara1[i]) sum++;
        if (ara[i + 1] == ara1[i + 1]) f = 1;
      }
    }
    if (sum == n)
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  }
  return 0;
}
