#include <bits/stdc++.h>
using namespace std;
int a[101000];
int b[101000];
int main() {
  int T, n;
  scanf("%d", &T);
  while (T--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
    }
    for (int i = 1; i <= n; i++) {
      a[i] -= b[i];
    }
    int tmd = 0, flag = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] > 0) {
        flag = 2;
        break;
      }
      if (a[i] != 0) {
        if (a[i] == a[i - 1]) {
          continue;
        } else {
          if (flag == 1) {
            flag = 2;
            break;
          }
          flag = 1;
        }
      }
    }
    if (flag == 2) {
      printf("NO\n");
    } else {
      printf("YES\n");
    }
  }
  return 0;
}
