#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long N = 1e5 + 200;
const int INF = 0x3f3f3f3f;
const double eps = 1e-7;
long long ins[N] = {0}, ls[N] = {0};
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n + 1), b(n + 1);
    ins[0] = 0, ls[0] = 0;
    for (int i = 1; i < n + 1; ++i) {
      scanf("%lld", &a[i]);
      ins[i] = ins[i - 1] + (a[i] == 1);
      ls[i] = ls[i - 1] + (a[i] == -1);
    }
    for (int i = 1; i < n + 1; ++i) {
      scanf("%lld", &b[i]);
    }
    int flag = 1;
    for (int i = n; i >= 1; i--) {
      if (a[i] == b[i]) continue;
      if (a[i] > b[i] && ls[i - 1]) continue;
      if (a[i] < b[i] && ins[i - 1]) continue;
      flag = 0;
    }
    if (!flag) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
