#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x, long long int y, long long int m) {
  if (y == 0) return 1;
  long long int p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
long long int nCr(long long int n, long long int r, long long int m) {
  if (r > n) return 0;
  long long int a = 1, b = 1, i;
  for (i = 0; i < r; i++) {
    a = (a * n) % m;
    --n;
  }
  while (r) {
    b = (b * r) % m;
    --r;
  }
  return (a * power(b, m - 2, m)) % m;
}
void solve() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  vector<int> v(3);
  int f = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] < b[i]) {
      if (v[2] == 0) f = 1;
    }
    if (a[i] > b[i]) {
      if (v[0] == 0) f = 1;
    }
    if (a[i] == -1)
      v[0] = 1;
    else if (a[i] == 0)
      v[1] = 1;
    else
      v[2] = 1;
  }
  if (f)
    cout << "NO" << '\n';
  else
    cout << "YES" << endl;
}
int main() {
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
