#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  a = a % 1000000007;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 1000000007;
      b--;
    }
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
void solve() {
  long long n;
  cin >> n;
  long long a[n], b[n];
  for (long long i = 0; i <= n - 1; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i <= n - 1; i++) {
    cin >> b[i];
  }
  long long cnt0 = 0, cnt1 = 0, cnt2 = 0;
  if (a[0] == 1) cnt1++;
  if (a[0] == -1) cnt2++;
  if (a[0] == 0) cnt0++;
  int fl = 0;
  if (a[0] != b[0]) {
    cout << "NO" << '\n';
    return;
  } else {
    for (long long i = 1; i <= n - 1; i++) {
      if (b[i] > a[i] && cnt1 <= 0) {
        fl = 1;
        cout << "NO" << '\n';
        return;
      } else if (b[i] < a[i] && cnt2 <= 0) {
        fl = 1;
        cout << "NO" << '\n';
        return;
      }
      if (a[i] == 1) cnt1++;
      if (a[i] == -1) cnt2++;
    }
    if (fl == 0) {
      cout << "YES" << '\n';
    }
  }
  return;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
