#include <bits/stdc++.h>
using namespace std;
int a[100000 + 5], b[100000 + 5], c[100000 + 5];
int t;
int main() {
  cin >> t;
  while (t--) {
    int n, flag = 0, ok = 1, ans;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    for (int i = 0; i < n; i++) {
      if (a[i] == b[i] && flag == 0)
        continue;
      else if (flag == 0) {
        flag = 1;
        ans = b[i] - a[i];
        if (ans < 0) {
          ok = 0;
          break;
        }
      } else if (flag == 1) {
        if (a[i] == b[i])
          flag = 2;
        else if (a[i] + ans != b[i]) {
          ok = 0;
          break;
        }
      } else if (flag == 2) {
        if (a[i] != b[i]) {
          ok = 0;
          break;
        }
      }
    }
    if (ok == 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
