#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n + 2], b[n + 2], diff = 50000;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    vector<int> v;
    bool flag = true;
    for (int i = 1; i <= n; i++) {
      if (b[i] == a[i]) continue;
      if (b[i] - a[i] < 0) {
        flag = false;
        break;
      }
      if (diff == 50000) {
        diff = b[i] - a[i];
        v.push_back(i);
        continue;
      }
      if (diff != b[i] - a[i]) {
        flag = false;
        break;
      }
      v.push_back(i);
    }
    for (int i = 1; i < v.size(); i++)
      if (v[i] != v[i - 1] + 1) flag = false;
    if (flag)
      cout << "YES"
           << "\n";
    else
      cout << "NO\n";
  }
}
