#include <bits/stdc++.h>
using namespace std;
void GO() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
}
const int N = 1e5, OO = 0x3f3f3f3f;
int mn = OO, mx = -OO;
int a[N], b[N], oneIdx = -1, nOne = -1;
bool foundOne, foundN;
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    foundN = foundOne = 0;
    oneIdx = nOne = -1;
    bool done = 1;
    cin >> n;
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
      if (a[i] == 1 && !foundOne && oneIdx == -1) {
        foundOne = 1;
        oneIdx = i;
      } else if (a[i] == -1 && !foundN && nOne == -1) {
        foundN = 1;
        nOne = i;
      }
    }
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) {
      if (b[i] > a[i]) {
        if (oneIdx >= i || oneIdx == -1) {
          done = 0;
          break;
        }
      } else if (b[i] < a[i]) {
        if (nOne >= i || nOne == -1) {
          done = 0;
          break;
        }
      }
    }
    if (done)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
