#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[100005];
    int b[100005];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int st = 0;
    int beda;
    bool ans = 1;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i] && st == 0) {
        beda = b[i] - a[i];
        st = 1;
        if (beda < 0) {
          ans = 0;
          break;
        }
      } else if (a[i] != b[i] && st == 1) {
        if (beda != b[i] - a[i]) {
          ans = 0;
          break;
        }
      } else if (a[i] == b[i] && st == 1) {
        st = 2;
      } else if (a[i] != b[i] && st == 2) {
        ans = 0;
        break;
      }
    }
    if (!ans)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
