#include <bits/stdc++.h>
using namespace std;
inline int D() {
  int t;
  scanf("%d", &t);
  return t;
}
inline long long LLD() {
  long long t;
  scanf("%lld", &t);
  return t;
}
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double pi = 3.14159265359;
void file() {}
int main() {
  int t = D();
  while (t--) {
    int n = D();
    int a[n], b[n];
    for (int i = 0; i < n; i++) a[i] = D();
    for (int i = 0; i < n; i++) b[i] = D();
    bool flag = 0;
    int cnt = 0;
    if (b[0] < a[0]) flag = 1;
    if (b[0] > a[0]) cnt++;
    for (int i = 1; i < n; i++) {
      if (b[i] < a[i]) {
        flag = 1;
        break;
      } else if (a[i] == b[i])
        continue;
      else if (b[i] > a[i]) {
        if (b[i] - a[i] != b[i - 1] - a[i - 1]) cnt++;
        if (cnt > 1) {
          flag = 1;
          break;
        }
      }
    }
    if (flag)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
}
