#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<long long> b(n);
    bool e = true;
    map<int, bool> m;
    int i;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (i = 0; i < n; i++) {
      cin >> b[i];
    }
    m[0] = m[1] = m[-1] = false;
    for (i = 0; i < n; i++) {
      if (a[i] != b[i]) {
        if (a[i] > b[i] && !m[-1]) {
          e = false;
          break;
        }
        if (a[i] < b[i] && !m[1]) {
          e = false;
          break;
        }
      }
      m[a[i]] = true;
      if (m[1] && m[-1]) break;
    }
    if (e)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
}
