#include <bits/stdc++.h>
using namespace std;
long long int arr[100005], brr[100005];
int main() {
  long long int t, one, minusone, flag, n;
  cin >> t;
  while (t--) {
    one = -1, minusone = -1, flag = 1;
    cin >> n;
    for (long long int i = 0; i < n; i++) {
      cin >> arr[i];
      if (arr[i] == 1 && one == -1) one = i;
      if (arr[i] == -1 && minusone == -1) minusone = i;
    }
    for (long long int i = 0; i < n; i++) cin >> brr[i];
    if (arr[0] != brr[0]) {
      cout << "NO" << '\n';
    } else {
      for (long long int i = 1; i < n; i++) {
        if (arr[i] == brr[i])
          continue;
        else if (brr[i] > arr[i]) {
          if (one == -1) {
            flag = 0;
            break;
          }
          if (one >= i) {
            flag = 0;
            break;
          }
        } else {
          if (minusone == -1) {
            flag = 0;
            break;
          }
          if (minusone >= i) {
            flag = 0;
            break;
          }
        }
      }
      if (flag)
        cout << "YES" << '\n';
      else
        cout << "NO" << '\n';
    }
  }
}
