#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void read(T &res) {
  char c;
  T flag = 1;
  while ((c = getchar()) < '0' || c > '9')
    if (c == '-') flag = -1;
  res = c - '0';
  while ((c = getchar()) >= '0' && c <= '9') res = res * 10 + c - '0';
  res *= flag;
}
int a[4];
int k[100005];
int b[100005];
int main() {
  int t;
  read(t);
  while (t--) {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      read(k[i]);
      if (k[i] == 1) a[1]++;
      if (k[i] == 0) a[2]++;
      if (k[i] == -1) a[3]++;
    }
    for (int i = 1; i <= n; i++) read(b[i]);
    int temp = 1;
    for (int i = n; i; i--) {
      if (k[i] == 1) a[1]--;
      if (k[i] == 0) a[2]--;
      if (k[i] == -1) a[3]--;
      if (b[i] > k[i]) {
        if (a[1] == 0) {
          temp = 0;
        }
      }
      if (b[i] < k[i]) {
        if (a[3] == 0) {
          temp = 0;
        }
      }
    }
    if (temp)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
