#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int m = 0, p = 0, x, v, k = 1;
    vector<int> a, b;
    cin >> x;
    for (int t = 0; t < x; t++) {
      cin >> v;
      a.push_back(v);
      if (v == 1) {
        p += 1;
      } else if (v == -1) {
        m += 1;
      }
    }
    for (int t = 0; t < x; t++) {
      cin >> v;
      b.push_back(v);
    }
    for (int t = x - 1; t >= 0; t--) {
      if (a[t] > b[t]) {
        if (a[t] == 1) {
          p--;
        }
        if (a[t] == -1) {
          m--;
        }
        if (m < 1) {
          cout << "NO"
               << "\n";
          k = 0;
          break;
        }
      }
      if (a[t] < b[t]) {
        if (a[t] == 1) {
          p--;
        }
        if (a[t] == -1) {
          m--;
        }
        if (p < 1) {
          cout << "NO"
               << "\n";
          k = 0;
          break;
        }
      }
      if (a[t] == b[t]) {
        if (a[t] == 1) {
          p--;
        }
        if (a[t] == -1) {
          m--;
        }
      }
    }
    if (k) {
      cout << "YES"
           << "\n";
    }
  }
}
