#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int onePos = -1;
    int nOnePos = -1;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (onePos == -1 && a[i] == 1) onePos = i;
      if (nOnePos == -1 && a[i] == -1) nOnePos = i;
    }
    int possible = true;
    for (int i = 0; i < n; ++i) {
      int num;
      cin >> num;
      if ((num > a[i] && (onePos >= i || onePos == -1)) ||
          (num < a[i] && (nOnePos >= i || nOnePos == -1))) {
        possible = false;
      }
    }
    cout << (possible ? "YES" : "NO") << '\n';
  }
  return 0;
}
