#include <bits/stdc++.h>
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
using namespace std;
int t;
int n, a[N], b[N];
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    if (a[0] != b[0]) {
      printf("NO\n");
      continue;
    }
    if (n == 1 && a[0] == b[0]) {
      printf("YES\n");
      continue;
    }
    bool flag = 0;
    for (int i = n - 1; i >= 1; --i) {
      flag = 0;
      if (b[i] == a[i]) {
        flag = 1;
        continue;
      } else if (b[i] < a[i]) {
        for (int j = 0; j < i; ++j) {
          if (a[j] == -1) {
            flag = 1;
            break;
          }
        }
      } else if (b[i] > a[i]) {
        for (int j = 0; j < i; ++j) {
          if (a[j] == 1) {
            flag = 1;
            break;
          }
        }
      }
      if (flag == 0) break;
    }
    if (flag)
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
