#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  if (b == 1) return a;
  if (b == 0) return 1;
  long long temp = power(a, b / 2);
  long long ans = temp * temp;
  if (b & 1) ans *= a;
  return ans;
}
long long power(long long a, long long b, long long p) {
  a = a % p;
  if (b == 1) return a;
  if (b == 0) return 1;
  long long temp = power(a, b / 2, p);
  long long ans = (temp * temp) % p;
  if (b & 1) ans = (a * ans) % p;
  return ans % p;
}
long long inv(long long a, long long m) { return power(a, m - 2, m); }
signed main() {
  cin.sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 1], b[n + 1];
    for (long long i = 1; i <= n; i++) cin >> a[i];
    for (long long i = 1; i <= n; i++) cin >> b[i];
    map<long long, long long> mark;
    bool flag = true;
    for (long long i = 1; i <= n; i++) {
      if (i == 1) {
        if (a[i] != b[i]) {
          flag = false;
          break;
        }
        mark[a[i]] = 1;
        continue;
      }
      if (b[i] > a[i]) {
        if (mark.count(1)) {
          mark[a[i]] = 1;
          continue;
        } else
          flag = false;
      } else if (b[i] < a[i]) {
        if (mark.count(-1)) {
          mark[a[i]] = 1;
          continue;
        } else
          flag = false;
      } else
        mark[a[i]] = 1;
    }
    if (flag)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
