#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, x = 0, y = 0, r = 0;
    cin >> n;
    bool flag = true;
    int a[n], b[n], c[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++) c[i] = b[i] - a[i];
    for (int i = 0; i < n; i++) {
      if (c[i] == 0) r += 1;
    }
    if (r == n)
      cout << "YES" << endl;
    else {
      for (int i = 0; i < n; i++) {
        if (c[i] != 0) {
          x = i;
          break;
        }
      }
      for (int i = n - 1; i >= 0; i--) {
        if (c[i] != 0) {
          y = i;
          break;
        }
      }
      for (int i = x; i < y; i++) {
        if (c[i] != c[i + 1]) {
          flag = false;
          break;
        }
      }
      if (flag == true && c[x] > 0)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
