#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, i, f1 = 0;
    cin >> n;
    long long int a[n], b[n], cnt1 = 0, cnt0 = 0, cnt2 = 0;
    map<long long int, long long int> m, m1, m2;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) cin >> b[i];
    if (a[0] != b[0]) {
      cout << "NO\n";
      continue;
    }
    m[a[0]]++;
    for (i = 1; i < n; i++) {
      if (b[i] > a[i] && m[1] > 0) {
        m[a[i]]++;
      } else if (b[i] < a[i] && m[-1] > 0) {
        m[a[i]]++;
      } else if (b[i] == a[i]) {
        m[a[i]]++;
        continue;
      } else {
        f1 = 1;
        break;
      }
    }
    if (f1)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
}
