#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int T;
  cin >> T;
  for (long long int j = 0; j < T; j++) {
    long long int n;
    cin >> n;
    long long int a[n];
    long long int b[n];
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (long long int i = 0; i < n; i++) {
      cin >> b[i];
    }
    long long int l = -1;
    long long int r = -1;
    long long int flag = 0;
    for (long long int i = 0; i < n; i++) {
      if (b[i] > a[i] && l == -1) {
        flag = 1;
        break;
      } else if (b[i] < a[i] && r == -1) {
        flag = 1;
        break;
      }
      if (a[i] == 1) {
        l = 1;
      } else if (a[i] == -1) {
        r = 1;
      }
    }
    if (flag == 1) {
      cout << "NO" << endl;
    } else {
      cout << "YES" << endl;
    }
  }
  return 0;
}
