#include <bits/stdc++.h>
int main() {
  int t, i;
  scanf("%d", &t);
  for (i = 0; i < t; i++) {
    int c = 0, n, j, d, m = 0, k = 0, p = 0, x = 0, y = 1;
    scanf("%d", &n);
    int a[n], b[n];
    for (j = 0; j < n; j++) scanf("%d", &a[j]);
    for (j = 0; j < n; j++) scanf("%d", &b[j]);
    for (j = 0; j < n; j++) {
      d = b[j] - a[j];
      if (d < 0) {
        printf("NO\n");
        y = 0;
        break;
      }
      if (c == 0 && d > 0) {
        m = d;
      }
      if (d != 0) {
        c++;
        if (c == 1) {
          k = j;
        }
        p = j;
        if (d != m) c--;
      }
    }
    x = p - k + 1;
    if (y == 0) {
      continue;
    }
    if (x == c || x == 1)
      printf("YES\n");
    else
      printf("NO\n");
  }
}
