#include <bits/stdc++.h>
using namespace std;
void BoostIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
}
int32_t main() {
  BoostIO();
  int64_t t;
  cin >> t;
  while (t--) {
    int64_t n;
    cin >> n;
    vector<int64_t> a(n);
    vector<int64_t> b(n);
    for (int64_t i = 0; i < n; ++i) {
      cin >> a[i];
    }
    for (int64_t i = 0; i < n; ++i) {
      cin >> b[i];
    }
    bool inc = 0, dec = 0, sosat = 0;
    for (int64_t i = 0; i < n; ++i) {
      if (b[i] - a[i] > 0) {
        if (!inc) {
          sosat = 1;
          break;
        }
      } else if (b[i] - a[i] < 0) {
        if (!dec) {
          sosat = 1;
          break;
        }
      }
      if (a[i] == 1) inc = 1;
      if (a[i] == -1) dec = 1;
    }
    if (sosat)
      cout << "NO" << '\n';
    else
      cout << "YES" << '\n';
  }
  return 0;
}
