#include <bits/stdc++.h>
using namespace std;
int const nmax = 100000;
int v[1 + nmax], sol[1 + nmax];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> v[i];
    for (int i = 1; i <= n; i++) cin >> sol[i];
    int y1 = 0, n1 = 0;
    for (int i = 1; i <= n; i++) {
      if (v[i] < sol[i] && y1 == 0) {
        cout << "NO\n";
        goto label;
      }
      if (sol[i] < v[i] && n1 == 0) {
        cout << "NO\n";
        goto label;
      }
      if (v[i] == 1)
        y1 = 1;
      else if (v[i] == -1)
        n1 = 1;
    }
    cout << "YES\n";
  label:
    continue;
  }
  return 0;
}
