#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1000005;
int n;
bool vis[N];
queue<int> q2;
std::vector<vector<int> > v;
int a[N], b[N];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int f = 0;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
      cin >> b[i];
    }
    bool t = true, z = false;
    for (int i = 0; i < n; ++i) {
      if (a[i] != b[i] && f > 0 && z) {
        cout << "NO" << endl;
        t = false;
        break;
      } else if (a[i] != b[i] && f == 0) {
        f = b[i] - a[i];
      } else if (a[i] != b[i] && f != b[i] - a[i]) {
        cout << "NO" << endl;
        t = false;
        break;
      } else if (a[i] == b[i] && f > 0) {
        z = true;
      }
      if (f < 0) {
        cout << "NO" << endl;
        t = false;
        break;
      }
    }
    if (t) cout << "YES" << endl;
  }
}
