#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 100;
long long t;
long long n;
long long a[N];
long long b[N];
map<long long, long long> ma;
int main() {
  scanf("%lld", &t);
  while (t--) {
    ma.clear();
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    scanf("%lld", &n);
    for (long long i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (long long i = 1; i <= n; i++) scanf("%lld", &b[i]);
    if (a[1] != b[1]) {
      printf("NO\n");
      continue;
    }
    ma[a[1]] = 1;
    bool f = false;
    for (long long i = 2; i <= n; i++) {
      if (a[i] == b[i]) {
        ma[a[i]] = 1;
        continue;
      }
      if (f) break;
      long long cha = b[i] - a[i];
      if (cha < 0) {
        if (ma[-1] > 0) {
        } else {
          f = true;
          break;
        }
      }
      if (cha > 0) {
        if (ma[1] > 0) {
        } else {
          f = true;
          break;
        }
      }
      if (f) break;
      ma[a[i]] = 1;
    }
    if (f) {
      printf("NO\n");
    } else {
      printf("YES\n");
    }
  }
  return 0;
}
