#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    int l = 0;
    cin >> n;
    int a[n], b[n];
    int m = 0;
    int pos = 0;
    int k = 0;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++)
      if (a[i] != b[i]) {
        pos = i;
        k = b[i] - a[i];
        break;
      }
    if (k > 0) {
      for (int i = pos; i < n; i++)
        if (a[i] != b[i])
          a[i] = a[i] + k;
        else
          break;
    }
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) m = 1;
    }
    if (m == 1)
      cout << "NO\n";
    else
      cout << "yes\n";
  }
}
