#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int a[100005], n, b[100005];
void solve() {
  bool f1, f2;
  f1 = f2 = 0;
  int x;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n; i++) {
    x = b[i];
    if (x < a[i]) {
      if (!f2) {
        cout << "NO\n";
        return;
      }
    } else if (x > a[i]) {
      if (!f1) {
        cout << "NO\n";
        return;
      }
    }
    if (a[i] == -1) {
      f2 = 1;
    } else if (a[i] == 1)
      f1 = 1;
  }
  cout << "YES\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}
