#include <bits/stdc++.h>
using namespace std;
long long mod = 10000000000;
long long gcd(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
long long fastexp(long long x, long long n) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result *= x;
    x *= x;
    n = n / 2;
  }
  return result;
}
long long modularExp(long long x, long long n, long long mod) {
  long long result = 1;
  while (n > 0) {
    if (n % 2 == 1) result = (result * x) % mod;
    x = ((x % mod) * (x % mod)) % mod;
    n = n / 2;
  }
  return (result) % mod;
}
bool isPrime(long long n) {
  for (long long i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
bool mycomp(pair<long long, long long> &a, pair<long long, long long> &b) {
  if (a.first != b.first)
    return a.first < b.first;
  else
    return a.second < b.second;
}
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  vector<long long> b(n + 1);
  map<long long, long long> mp;
  long long i;
  for (i = 1; i <= n; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i];
  bool f = true;
  if (a[1] != b[1]) {
    cout << "NO\n";
    return;
  }
  mp[a[1]] += 1;
  for (i = 2; i <= n; i++) {
    if (a[i] == b[i]) {
      mp[a[i]] = 1;
      continue;
    } else if (a[i] < b[i]) {
      if (mp.find(1) == mp.end()) {
        cout << "NO\n";
        return;
      }
    } else {
      if (mp.find(-1) == mp.end()) {
        cout << "NO\n";
        return;
      }
    }
    mp[a[i]] = 1;
  }
  cout << "YES\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
}
