#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int n;
int a[N], b[N];
int main() {
  int t;
  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]);
    int flag = 1;
    int sub = 0;
    int pre = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] != b[i]) {
        if ((pre && pre != i - 1) || (sub && b[i] - a[i] != sub)) {
          flag = 0;
          break;
        }
        pre = i;
        sub = b[i] - a[i];
      }
    }
    if (flag && sub >= 0)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
