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