#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
const int INF = 0x3f3f3f3f;
int a[maxn], b[maxn], cnt[maxn][4];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i <= n; i++)
      for (int j = 0; j <= 3; j++) cnt[i][j] = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      int k = a[i];
      if (a[i] == -1) k = 1;
      if (a[i] == 1) k = 2;
      for (int j = 0; j <= 3; j++) cnt[i][j] = cnt[i - 1][j];
      cnt[i][k]++;
    }
    int flag = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &b[i]);
      if (b[i] > a[i] && cnt[i - 1][2] == 0) flag = 1;
      if (b[i] < a[i] && cnt[i - 1][1] == 0) flag = 1;
    }
    if (flag)
      printf("NO\n");
    else
      printf("YES\n");
  }
}
