#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[100002], b[100002];
    bool mp1[100002] = {}, mpp[100002] = {};
    mp1[0] = 0;
    mpp[0] = 0;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      mp1[i] = mp1[i - 1];
      if (a[i - 1] == 1) {
        mp1[i] = 1;
      }
      mpp[i] = mpp[i - 1];
      if (a[i - 1] == -1) {
        mpp[i] = 1;
      }
    }
    for (int i = 1; i <= n; i++) {
      cin >> b[i];
    }
    bool nai = 0;
    for (int i = 1; i <= n; i++) {
      if (a[i] < b[i]) {
        if (mp1[i] != 1) {
          nai = 1;
        }
      }
      if (a[i] > b[i]) {
        if (mpp[i] != 1) {
          nai = 1;
        }
      }
    }
    if (nai == 0) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
