#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n;
int a[N], b[N];
unordered_map<int, int> cnt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int T;
  cin >> T;
  while (T--) {
    cnt.clear();
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      cnt[a[i]]++;
    }
    for (int i = 1; i <= n; i++) cin >> b[i];
    bool success = true;
    for (int i = n; i; i--) {
      cnt[a[i]]--;
      if (a[i] == b[i]) continue;
      if (a[i] > b[i])
        if (cnt[-1])
          continue;
        else {
          success = false;
          break;
        }
      if (cnt[1])
        continue;
      else {
        success = false;
        break;
      }
    }
    cout << (success ? "YES" : "NO") << endl;
  }
  return 0;
}
