#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int MAX = 100005;
int a[MAX], b[MAX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int x = 0, y = -1;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        x = b[i] - a[i];
        y = i;
        break;
      }
    }
    if (x == 0)
      cout << "yes" << endl;
    else if (x < 0)
      cout << "no" << endl;
    else {
      for (int i = y; i < n; i++) {
        if (a[i] == b[i])
          break;
        else
          a[i] += x;
      }
      for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
          x = 0;
          break;
        }
      }
      if (x == 0)
        cout << "no" << endl;
      else
        cout << "yes" << endl;
    }
  }
  return 0;
}
