#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
int las[100010], to[100010], nxt[100010], n, m, a[100010], b[100010],
    v[100010][2], shangda, shangxiao, zheng1, zheng2, fu1, fu2, ans, cnt;
int main() {
  int t;
  cin >> t;
  while (t--) {
    for (register int i = 1; i <= n; i++) v[i][0] = v[i][1] = 0;
    cin >> n;
    for (register int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (register int i = 1; i <= n; i++) scanf("%d", &b[i]);
    for (register int i = 1; i <= n; i++) {
      v[i + 1][0] = v[i][0], v[i + 1][1] = v[i][1];
      if (a[i] == 1) v[i + 1][0] = 1;
      if (a[i] == -1) v[i + 1][1] = 1;
    }
    int f = 0;
    for (int i = n; i; i--)
      if ((a[i] > b[i] && v[i][1] == 0) || (a[i] < b[i] && v[i][0] == 0)) {
        f = 1;
        break;
      }
    if (f == 1)
      cout << "NO";
    else
      cout << "YES";
    cout << '\n';
  }
}
