#include <bits/stdc++.h>
using namespace std;
int main() {
  int ch, t, n, ch1, ch2, i, j;
  cin >> t;
  while (t--) {
    cin >> n;
    int arr1[n];
    int arr2[n];
    for (i = 0; i < n; i++) {
      cin >> arr1[i];
    }
    for (i = 0; i < n; i++) {
      cin >> arr2[i];
    }
    if (arr1[0] != arr2[0]) {
      cout << "NO" << endl;
    } else {
      ch1 = 0;
      ch2 = 0;
      ch = 0;
      if (arr1[0] == 1) {
        ch1 = 1;
      }
      if (arr1[0] == -1) {
        ch2 = 1;
      }
      for (i = 1; i < n; i++) {
        if (arr2[i] > arr1[i]) {
          if (ch1 == 0) {
            ch = 1;
            break;
          }
        }
        if (arr2[i] < arr1[i]) {
          if (ch2 == 0) {
            ch = 1;
            break;
          }
        }
        if (arr1[i] == 1) {
          ch1 = 1;
        }
        if (arr1[i] == -1) {
          ch2 = 1;
        }
      }
      if (ch == 1) {
        cout << "NO" << endl;
      } else {
        cout << "YES" << endl;
      }
    }
  }
}
