#include <bits/stdc++.h>
using namespace std;
int arr[100005], brr[100005], poss[100005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    for (int i = 0, colchin = n; i < colchin; ++i) cin >> arr[i];
    for (int i = 0, colchin = n; i < colchin; ++i) cin >> brr[i];
    bool ones = false;
    bool minusOne = false;
    for (int i = 0, colchin = n; i < colchin; ++i) {
      if (ones && minusOne) {
        poss[i] = 3;
      } else if (ones) {
        poss[i] = 1;
      } else if (minusOne) {
        poss[i] = 2;
      } else {
        poss[i] = 0;
      }
      if (arr[i] == 1) {
        ones = true;
      } else if (arr[i] == -1) {
        minusOne = true;
      }
    }
    bool possible = true;
    for (int i = 0, colchin = n; i < colchin; ++i) {
      if (brr[i] < arr[i]) {
        possible &= (poss[i] == 3 || poss[i] == 2);
      } else if (brr[i] > arr[i]) {
        possible &= (poss[i] == 3 || poss[i] == 1);
      }
    }
    if (possible) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
