#include <bits/stdc++.h>
using namespace std;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int *arr = new int[n];
    int *brr = new int[n];
    int *crr = new int[n];
    vector<int> v;
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int i = 0; i < n; i++) cin >> brr[i];
    if (n == 1) {
      if (arr[0] > brr[0]) {
        cout << "NO" << endl;
      } else {
        cout << "YES" << endl;
      }
      continue;
    }
    int diff = 0;
    for (int i = 0; i < n; i++) {
      crr[i] = brr[i] - arr[i];
      if (crr[i] != 0 && diff == 0) diff = crr[i];
    }
    bool res = true;
    for (int i = 0; i < n; i++) {
      if (crr[i] < 0) {
        res = false;
        cout << "NO" << endl;
        break;
      }
      if (crr[i] != 0 && diff == crr[i]) {
        int temp = crr[i];
        v.push_back(i);
      } else if (crr[i] != 0 && diff != crr[i]) {
        res = false;
        cout << "NO" << endl;
        break;
      }
    }
    if (res == false) {
      continue;
    }
    for (int i = 1; i < v.size(); i++) {
      if (v[i] - v[i - 1] != 1) {
        res = false;
        break;
      }
    }
    if (res == true) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
