#include <bits/stdc++.h>
using namespace std;
const int MX = 1000000;
const long long inf = 1e9;
const long long mod = 998244353;
int a[MX], b[MX], mx[MX], mn[MX];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tc, n, m;
  cin >> tc;
  while (tc--) {
    cin >> n;
    for (int i = 1; i <= n; mx[i] = mn[i] = 0, i++) cin >> a[i];
    for (int i = 1; i <= n; i++) cin >> b[i];
    for (int i = 1; i <= n; i++)
      mx[i] = max(mx[i - 1], a[i - 1]), mn[i] = min(mn[i - 1], a[i - 1]);
    bool flg = true;
    for (int i = 1; i <= n; i++) {
      if (a[i] == b[i]) continue;
      if (b[i] > a[i]) {
        if (mx[i] != 1) flg = false;
      } else if (b[i] < a[i]) {
        if (mn[i] != -1) flg = false;
      }
    }
    if (flg)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
