#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  int t, n, flag = 0, flag1 = 0, flag2 = 0;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n;
    int a[n], b_[n], b, cons = 0;
    for (int j = 0; j < n; j++) cin >> a[j];
    for (int j = 0; j < n; j++) cin >> b_[j];
    for (int j = 0; j < n; j++) {
      b = b_[j];
      if ((b - a[j]) != 0) {
        if (cons == 0) {
          cons = b - a[j];
          flag1 = 1;
        }
        if (cons < 0) {
          flag = 1;
          break;
        }
        if (cons != (b - a[j])) {
          flag = 1;
          break;
        }
        if (flag1 == 1 && flag2 == 1) {
          flag = 1;
          break;
        }
      } else {
        if (flag1 == 1) flag2 = 1;
      }
    }
    if (flag == 1)
      cout << "NO\n";
    else
      cout << "YES\n";
    flag = flag1 = flag2 = 0;
  }
}
