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