#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  int x, y, z;
  x = y = z = 0;
  int flag = 1;
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
    if (a[i - 1] == -1 and i > 0)
      x = 1;
    else if (a[i - 1] == 0 and i > 0)
      y = 1;
    else if (a[i - 1] == 1 and i > 0)
      z = 1;
    if ((a[i] > b[i]) and x == 0)
      flag = 0;
    else if ((a[i] < b[i]) and z == 0)
      flag = 0;
  }
  if (flag)
    cout << "YES"
         << "\n";
  else
    cout << "NO"
         << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test;
  test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
