#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[100010], b[100010];
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    int f1 = n, f2 = n;
    for (int i = n + 1 - 1; i >= 0; i--) {
      if (a[i] == 1)
        f1 = i;
      else if (a[i] == -1)
        f2 = i;
    }
    int deu = 1;
    for (int i = 1; i <= f1; i++) {
      if (a[i] < b[i]) deu = 0;
    }
    for (int i = 1; i <= f2; i++) {
      if (a[i] > b[i]) {
        deu = 0;
      }
    }
    if (deu)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
