#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const double EPS = 1e-6;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  long long q;
  cin >> q;
  while (q--) {
    long long n, L = -1, R = -1, cnt = 0;
    cin >> n;
    vector<long long> v1(n), v2(n);
    set<long long> s;
    bool b = true;
    for (long long &c : v1) cin >> c;
    for (long long i = 0; i < n; i++) {
      cin >> v2[i];
      if (v2[i] != v1[i] && b) {
        s.insert(v2[i] - v1[i]);
        b = false;
        L = i;
        R = i;
        cnt++;
      } else if (v2[i] != v1[i]) {
        s.insert(v2[i] - v1[i]);
        R = i;
        cnt++;
      }
    }
    if (L == -1 && R == -1)
      cout << "YES" << endl;
    else if (R - L + 1 == cnt) {
      auto value = s.begin();
      if (s.size() == 0 || (s.size() == 1 && *value > 0))
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
