#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long mcm(long long a, long long b) { return (a * b) / gcd(a, b); }
bool comp(long long a, long long b) { return a > b; }
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  if (a[0] != b[0]) {
    cout << "NO\n";
  } else {
    vector<pair<bool, bool>> posneg(n + 10, pair<bool, bool>(0, 0));
    for (int i = 1; i < n; i++) {
      if (a[i - 1] == -1 || posneg[i - 1].second) {
        posneg[i].second = true;
      }
      if (a[i - 1] == 1 || posneg[i - 1].first) {
        posneg[i].first = true;
      }
    }
    for (int i = 1; i < n; i++) {
      if (a[i] != b[i]) {
        if (a[i] > b[i]) {
          if (!posneg[i].second) {
            cout << "NO\n";
            return;
          }
        } else {
          if (a[i] < b[i]) {
            if (!posneg[i].first) {
              cout << "NO\n";
              return;
            }
          }
        }
      }
    }
    cout << "YES\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
