#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int mod = 1e9 + 7;
const int N = 2e5 + 5;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test;
  cin >> test;
  while (test--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = (0); i < (int)(n); i++) cin >> a[i];
    for (int i = (0); i < (int)(n); i++) cin >> b[i];
    if (a[0] != b[0]) {
      cout << "NO\n";
      continue;
    }
    vector<bool> vv(10, false);
    vv[a[0] + 1] = true;
    bool dd = true;
    for (int i = (1); i < (int)(n); i++) {
      if (a[i] < b[i] && vv[2] == false) dd = false;
      if (a[i] > b[i] && vv[0] == false) dd = false;
      vv[a[i] + 1] = true;
    }
    if (dd == true)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
