#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false), cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (auto& x : a) {
      cin >> x;
    }
    for (auto& x : b) {
      cin >> x;
    }
    bool ok = true;
    int x = 0, y = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] < b[i]) {
        ok &= (y > 0);
      } else if (a[i] > b[i]) {
        ok &= (x > 0);
      }
      if (a[i] == 1) {
        ++y;
      } else if (a[i] == -1) {
        ++x;
      }
    }
    cout << (ok ? "YES\n" : "NO\n");
  }
}
