#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    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];
    vector<int> v;
    int e = 0, d = 0, f1 = 0, di = 0, l = 0;
    for (int i = 0; i < n; i++) {
      if (b[i] - a[i] < 0) {
        f1 = 1;
        break;
      } else if (b[i] - a[i] != 0) {
        e = i;
        d = b[i] - a[i];
        break;
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (b[i] - a[i] < 0) {
        f1 = 1;
        break;
      } else if (b[i] - a[i] != 0) {
        l = i;
        di = b[i] - a[i];
        break;
      }
    }
    if (di != d) {
      cout << "NO" << endl;
      continue;
    }
    for (int i = e + 1; i < l; i++) {
      if (b[i] - a[i] != d) {
        f1 = 1;
      }
    }
    if (f1 == 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
