#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    int n, count = 0, e = 0;
    cin >> n;
    int a[n], b[n];
    for (int j = 0; j < n; j++) cin >> a[j];
    vector<int> v;
    for (int j = 0; j < n; j++) cin >> b[j];
    for (int j = 0; j < n; j++) {
      if (a[j] == b[j]) continue;
      if (count == 0) {
        while (a[j] != b[j]) {
          count++;
          v.push_back(b[j] - a[j]);
          if (j == n - 1) break;
          j++;
        }
        if (j == n - 1) break;
      }
      if (count > 0 && a[j] != b[j]) {
        e = 1;
        break;
      }
      j--;
    }
    if (e == 0) {
      for (int j = 0; j < count; j++) {
        if (v[j] < 0) {
          e = 1;
          break;
        }
        if (j < count - 1) {
          if (v[j] == v[j + 1])
            continue;
          else {
            e = 1;
            break;
          }
        }
      }
    }
    if (e == 0)
      cout << "YES";
    else
      cout << "NO";
    cout << "\n";
  }
  return 0;
}
