#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
const long double PI = acos(-1);
long long euclid(long long x, long long y, long long a, long long b) {
  return (a - x) * (a - x) + (b - y) * (b - y);
}
void solve() {
  long long n;
  cin >> n;
  long long i;
  std::vector<long long> a(n), b(n);
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) cin >> b[i];
  map<long long, long long> m;
  for (i = 0; i < n; i++) {
    if (a[i] < b[i]) {
      if (m[1] != 1) {
        cout << "NO" << endl;
        return;
      }
    }
    if (a[i] > b[i]) {
      if (m[-1] != 1) {
        cout << "NO" << endl;
        return;
      }
    }
    m[a[i]] = 1;
  }
  cout << "YES" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1, i = 1;
  cin >> t;
  while (i <= t) {
    solve();
    i++;
  }
  return 0;
}
