#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 9;
int a[N], b[N];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    int ok = 1;
    if (a[1] != b[1]) ok = 0;
    map<int, int> cnt;
    cnt[a[1]]++;
    for (int i = 2; i <= n; i++) {
      if (a[i] < b[i] && cnt[1] == 0) ok = 0;
      if (a[i] > b[i] && cnt[-1] == 0) ok = 0;
      cnt[a[i]] = 1;
    }
    if (ok)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
