#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false), cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int arr1[n], arr2[n];
    for (int i = 0; i < n; i++) {
      cin >> arr1[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> arr2[i];
    }
    if (n == 1) {
      if (arr1[0] == arr2[0])
        cout << "YES" << endl;
      else if (arr1[0] < arr2[0])
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else {
      int diff1 = 0, flag = 0, i = 0;
      for (; i < n; i++) {
        if ((arr1[i] - arr2[i]) < 0) {
          diff1 = (arr1[i] - arr2[i]);
          break;
        } else if (arr1[i] - arr2[i] > 0) {
          flag = 1;
          break;
        } else
          continue;
      }
      if (diff1 != 0) {
        int diff = diff1;
        for (; i < n; i++) {
          diff1 = (arr1[i] - arr2[i]);
          if (diff1 == diff)
            continue;
          else if (diff1 == 0) {
            break;
          } else {
            flag = 1;
            break;
          }
        }
      }
      if (diff1 == 0) {
        for (; i < n; i++) {
          diff1 = (arr1[i] - arr2[i]);
          if (diff1 == 0)
            continue;
          else {
            flag = 1;
            break;
          }
        }
      }
      if (flag == 0)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
