#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
void print(T1 a[], T2 n) {
  for (T2 i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
template <class T1, class T2>
void print(vector<T1> a, T2 n) {
  for (T2 i = 0; i < n; i++) {
    cout << a[i] << " ";
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    int b[n];
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    int f1 = 0, f2 = 0, flag = 0;
    for (int i = 0; i < n; i++) {
      if (b[i] > a[i]) {
        if (f1 == 0) {
          flag = 1;
        }
      } else if (b[i] < a[i]) {
        if (f2 == 0) {
          flag = 1;
        }
      }
      if (a[i] == 1) {
        f1 = 1;
      } else if (a[i] == -1) {
        f2 = 1;
      }
    }
    if (flag == 1) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
}
