#include <bits/stdc++.h>
using namespace std;
int sign(int x) {
  if (x > 0)
    return 1;
  else if (x < 0)
    return -1;
  else
    return 0;
}
void solve() {
  int64_t n, m;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  if (a[0] == b[0]) {
    int f1 = 0, f2 = 0, i;
    for (i = 1; i < n; i++) {
      if (a[i - 1] == -1)
        f1 = 1;
      else if (a[i - 1] == 1)
        f2 = 1;
      if (a[i] == b[i]) continue;
      if (f1 == 1) {
        if (a[i] > b[i]) continue;
      }
      if (f2 == 1) {
        if (a[i] < b[i]) continue;
      }
      break;
    }
    if (i == n)
      cout << "YES";
    else
      cout << "NO";
  } else
    cout << "NO";
  cout << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int64_t t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
