#include <bits/stdc++.h>
using namespace std;
template <typename... T>
void read(T &...args) {
  ((cin >> args), ...);
}
template <typename... T>
void write(T &&...args) {
  ((cout << args << " "), ...);
}
void err(istringstream *iss) {}
template <typename T, typename... Args>
void err(istringstream *iss, const T &_val, const Args &...args) {
  string _name;
  *iss >> _name;
  if (_name.back() == ',') _name.pop_back();
  cerr << _name << " = " << _val << "; ", err(iss, args...);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int tc, t(1);
  for (cin >> tc; tc; ++t, --tc) {
    int n;
    read(n);
    vector<int> a(n), b(n);
    long long sum(0), jum(0);
    bool f = false;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      if (a[i] == 1)
        sum++;
      else if (a[i] == -1)
        jum++;
    }
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = n - 1; i >= 0; i--) {
      if (a[i] == 1) {
        --sum;
      } else if (a[i] == -1) {
        jum--;
      }
      if (a[i] < b[i]) {
        if (!sum) {
          f = 1;
        }
      } else if (a[i] > b[i]) {
        if (!jum) {
          f = true;
        }
      }
    }
    cout << (f ? "NO" : "YES") << endl;
  }
  return 0;
}
