#include <bits/stdc++.h>
using namespace std;
int main() {
  int test;
  cin >> test;
  while (test--) {
    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];
    vector<int> temp;
    int flag = 1;
    set<int> s;
    for (int i = 0; i < n; i++) {
      if (b[i] - a[i] < 0) {
        cout << "NO\n";
        flag = 0;
        break;
      } else if (b[i] - a[i] > 0) {
        s.insert(b[i] - a[i]);
        temp.push_back(i);
      }
    }
    if (s.size() > 1 && flag == 1) {
      flag = 0;
      cout << "NO\n";
    }
    if (temp.size() > 1) {
      for (int i = 1; i < temp.size(); i++) {
        if (temp[i] - temp[i - 1] != 1 && flag == 1) {
          cout << "NO\n";
          flag = 0;
          break;
        }
      }
    }
    if (flag) cout << "YES\n";
  }
}
