#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    long long int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];
    set<int> s;
    int flag = 0;
    for (int i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        if (a[i] < b[i]) {
          if (s.find(1) == s.end()) {
            flag = 1;
            break;
          }
        } else {
          if (s.find(-1) == s.end()) {
            flag = 1;
            break;
          }
        }
      }
      s.insert(a[i]);
    }
    if (flag)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
