#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  int k;
  bool be = true;
  for (int i = n - 1; i > 0; i--) {
    if (b[i] == a[i])
      continue;
    else if (b[i] > a[i]) {
      if (find(a, a + i, 1) != (a + i))
        continue;
      else {
        be = false;
        break;
      }
    } else {
      if (find(a, a + i, -1) != (a + i)) {
        continue;
      } else {
        be = false;
        break;
      }
    }
  }
  if (a[0] != b[0]) be = false;
  if (be)
    cout << "YES\n";
  else {
    cout << "NO\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) solve();
}
