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