#include <bits/stdc++.h>
using namespace std;
int read() {
  int res = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') f = -1, c = getchar();
  while (isdigit(c)) res = (res << 3) + (res << 1) + (c ^ 48), c = getchar();
  return res * f;
}
const int maxn = 1e5 + 10;
int a[maxn], b[maxn], c[10];
int main() {
  int T = read();
  while (T--) {
    int n = read();
    c[0] = c[1] = c[2] = 0;
    for (int i = 1; i <= n; i++) a[i] = read(), c[a[i] + 1]++;
    for (int i = 1; i <= n; i++) b[i] = read();
    int flag = 1;
    for (int i = n; i && flag; i--) {
      c[a[i] + 1]--;
      if (b[i] > a[i] && !c[2]) flag = 0;
      if (b[i] < a[i] && !c[0]) flag = 0;
    }
    printf("%s\n", flag ? "YES" : "NO");
  }
  return 0;
}
