#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, N;
  cin >> T;
  while (T--) {
    cin >> N;
    int res[N], t, f = 0, f1 = 0;
    for (int i = 0; i < N; i++) cin >> res[i];
    for (int i = 0; i < N; i++) {
      cin >> t;
      res[i] = t - res[i];
      if (res[i] < 0) {
        f = 1;
      }
    }
    if (f) {
      cout << "NO" << endl;
      continue;
    }
    for (int i = 0; i < N; i++) {
      if ((i - 1) >= 0 && res[i] != 0 && res[i - 1] == 0 && f1 == 1) {
        f = 1;
        break;
      }
      if ((i - 1) >= 0 && (res[i] != 0 && res[i - 1] != 0) &&
          res[i] != res[i - 1]) {
        f = 1;
        break;
      }
      if (res[i] != 0) f1 = 1;
    }
    if (f) {
      cout << "NO" << endl;
      continue;
    }
    cout << "YES" << endl;
  }
}
