#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    bool same = true;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      if (a[i] != b[i]) {
        same = false;
      }
    }
    bool possible = true;
    bool hasn = false;
    bool hasone = false;
    for (int i = 0; i < n; i++) {
      if (a[i] < b[i] && !hasone) {
        possible = false;
      }
      if (a[i] > b[i] && !hasn) {
        possible = false;
      }
      if (a[i] == 1) {
        hasone = true;
      }
      if (a[i] == -1) {
        hasn = true;
      }
    }
    if (same) {
      possible = true;
    }
    if (possible) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}
