#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    set<int> s;
    int f = 1, c = 0;
    for (int i = 0; i < n;) {
      if (b[i] - a[i] < 0) {
        f = 0;
        break;
      } else if (b[i] != a[i]) {
        c++;
        int d = b[i] - a[i];
        s.insert(d);
        while (b[i] - a[i] == d) {
          i++;
        }
      } else {
        i++;
      }
    }
    if (s.size() > 1 || c > 1) {
      f = 0;
    }
    if (f == 0) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
