#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  vector<int> d(2, 0);
  for (int i = 0; i < n; ++i) {
    if (a[i] > b[i] && !d[0]) {
      cout << "NO\n";
      return;
    } else if (a[i] < b[i] && !d[1]) {
      cout << "NO\n";
      return;
    }
    if (a[i] == -1) d[0] = 1;
    if (a[i] == 1) d[1] = 1;
  }
  cout << "YES\n";
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
