#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n], b[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    vector<int> good(2, 0);
    int d = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] > b[i] && !good[0]) {
        cout << "NO\n";
        d = 1;
        break;
      } else if (a[i] < b[i] && !good[1]) {
        cout << "NO\n";
        d = 1;
        break;
      }
      if (a[i] == -1) good[0] = 1;
      if (a[i] == 1) good[1] = 1;
    }
    if (d == 0) cout << "YES\n";
  }
  return 0;
}
