#include <bits/stdc++.h>
using namespace std;
int palindrome(string v, int s, int e) {
  if (s >= e) return 1;
  if (v[s] == v[e])
    return palindrome(v, s + 1, e - 1);
  else
    return 0;
}
long long int mx, mn;
long long int i, j, k, f, t, p, prv, d, r, sm;
long long int n, m, pos, cnt, ans, o, z, l, idx, e;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  t = 1;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<long long int> a(n), b(n);
    long long int post = 0, neg = 0, zero = 0;
    for (i = 0; i < n; cin >> a[i++])
      ;
    for (i = 0; i < n; cin >> b[i++])
      ;
    if (a[0] > 0)
      post++;
    else if (a[0] < 0)
      neg++;
    if (a[0] != b[0]) {
      cout << "NO" << endl;
      continue;
    }
    f = 0;
    for (i = 0; i < n; i++) {
      d = b[i] - a[i];
      if (d > 0) {
        if (post == 0) {
          f = 1;
          break;
        }
      } else if (d < 0) {
        if (neg == 0) {
          f = 1;
          break;
        }
      }
      if (a[i] > 0)
        post++;
      else if (a[i] < 0)
        neg++;
      if (post && neg) {
        break;
      }
    }
    cout << (f == 1 ? "NO" : "YES") << endl;
  }
  return 0;
}
