#include <bits/stdc++.h>
using namespace std;
long long sum(long long n) {
  if (n == 0) return 0;
  return (n * (n + 1)) / 2;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long ara[n];
    long long bara[n];
    for (int i = 0; i < n; i++) {
      cin >> ara[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> bara[i];
    }
    bool cara[2] = {0};
    bool f = 1;
    for (int i = 0; i < n; i++) {
      if (ara[i] > bara[i] && !cara[0]) {
        cout << "NO\n";
        f = 0;
        break;
      }
      if (ara[i] < bara[i] && !cara[1]) {
        cout << "NO\n";
        f = 0;
        break;
      }
      if (ara[i] == 1) cara[1] = 1;
      if (ara[i] == -1) cara[0] = 1;
    }
    if (f) cout << "YES\n";
  }
  return 0;
}
