#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> A(n), B(n);
    for (int i = 0; i < n; i++) {
      cin >> A[i];
    }
    for (int j = 0; j < n; j++) {
      cin >> B[j];
    }
    bool posi = false;
    bool nega = false;
    bool f = false;
    for (int i = 0; i < n; i++) {
      if (A[i] < B[i]) {
        if (!posi) {
          cout << "NO" << endl;
          f = true;
          break;
        }
      }
      if (A[i] > B[i]) {
        if (!nega) {
          cout << "NO" << endl;
          f = true;
          break;
        }
      }
      if (A[i] == 1) posi = true;
      if (A[i] == -1) nega = true;
    }
    if (!f) {
      cout << "YES" << endl;
    }
  }
}
