#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int indexp = INT_MAX, indexr = INT_MAX;
    int arr[n], brr[n];
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] == -1 and indexp == INT_MAX) indexp = i;
      if (arr[i] == 1 and indexr == INT_MAX) indexr = i;
    }
    for (int i = 0; i < n; i++) {
      cin >> brr[i];
    }
    int flag = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (brr[i] == arr[i])
        continue;
      else {
        if (brr[i] > arr[i]) {
          if (i > indexr)
            continue;
          else {
            flag = 1;
            break;
          }
        } else {
          if (i > indexp)
            continue;
          else {
            flag = 1;
            break;
          }
        }
      }
    }
    if (flag == 1)
      cout << "NO"
           << "\n";
    else
      cout << "YES"
           << "\n";
  }
  return (0);
}
