#include <bits/stdc++.h>
using namespace std;
int main() {
  int sum, t, p, pos, a[100005], b[100005], n, f, c, f1;
  cin >> t;
  while (t--) {
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    cin >> n;
    f = 1;
    sum = 0;
    p = 0;
    f1 = 1, c = 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 (f == 1 && a[i] != b[i]) {
        if (p == 0) pos = i, p = 1, c = b[i] - a[i];
        sum++;
        f = 0;
      } else if (a[i] > b[i])
        f1 = 0;
      else if (a[i] == b[i])
        f = 1;
    }
    if (sum >= 2) {
      cout << "NO" << endl;
    } else if (f1 == 0 || c < 0)
      cout << "NO" << endl;
    else {
      if (sum == 0)
        cout << "YES" << endl;
      else {
        for (int i = pos; a[i] != b[i]; i++) {
          if (b[i] - a[i] != c) f1 = 0;
        }
        if (f1 == 0)
          cout << "NO" << endl;
        else
          cout << "YES" << endl;
      }
    }
  }
}
