#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
constexpr int N = 2e5 + 5;
int t, n;
void Solve() {
  cin >> n;
  vector<int> a(n + 1), b(n + 1);
  vector<int> have(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  bool f = 1;
  for (int i = 1; i <= n; i++)
    have[i] = have[i - 1] | (a[i] == 1 ? 1 : (a[i] == -1 ? 2 : 0));
  for (int i = n; f && i > 0; i--) {
    if (a[i] < b[i] && (have[i - 1] & 1) == 0) f = 0;
    if (a[i] > b[i] && (have[i - 1] & 2) == 0) f = 0;
  }
  cout << (f ? "YES" : "NO") << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> t;
  while (t--) Solve();
  return 0;
}
