#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, a[N], b[N], q;
void solve() {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  bool neg = false, one = false;
  for (int i = 0; i < n; i++) {
    if (b[i] > a[i] && !one) {
      cout << "NO\n";
      return;
    }
    if (b[i] < a[i] && !neg) {
      cout << "NO\n";
      return;
    }
    if (a[i] > 0) one = true;
    if (a[i] < 0) neg = true;
  }
  cout << "YES\n";
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> q;
  while (q--) solve();
  return 0;
}
