#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  scanf("%d", &(tc));
  while (tc--) {
    vector<int> v1, v2;
    int n;
    scanf("%d", &(n));
    v1.push_back(0);
    v2.push_back(0);
    int x;
    for (int i = 0; i < n; i++) {
      scanf("%d", &(x));
      v1.push_back(x);
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &(x));
      v2.push_back(x);
    }
    int zero = 0, pos = 0, neg = 0;
    int res = 0;
    for (int i = 1; i <= n; i++) {
      if (v1[i] != v2[i]) {
        if (v2[i] == 0) {
          if (v1[i] == -1 && pos != 1)
            res = -1;
          else if (v1[i] == 1 && neg != -1)
            res = -1;
        } else if (v2[i] > 0) {
          if (pos != 1) res = -1;
        } else {
          if (neg != -1) res = -1;
        }
      }
      if (v1[i] == 1)
        pos = 1;
      else if (v1[i] == -1)
        neg = -1;
    }
    if (res == 0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
