#include <bits/stdc++.h>
using namespace std;
int const maxn = 100 * 1000 + 5;
int a[maxn];
int b[maxn];
int main() {
  int t;
  cin >> t;
  int n, f1, fm1;
  for (int i = 0; i < t; i++) {
    f1 = maxn;
    fm1 = maxn;
    cin >> n;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
      if (a[j] == 1 && f1 == maxn) f1 = j;
      if (a[j] == -1 && fm1 == maxn) fm1 = j;
    }
    bool check = true;
    for (int j = 0; j < n; j++) {
      cin >> b[j];
    }
    for (int j = n - 1; j >= 0; j--) {
      if (j > 0) {
        if (a[j] < b[j] && f1 >= j) check = false;
        if (a[j] > b[j] && fm1 >= j) check = false;
      } else {
        if (a[j] != b[j]) check = false;
      }
      if (!check) break;
    }
    if (check)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
