#include <bits/stdc++.h>
using namespace std;
void init_code() {}
int main() {
  init_code();
  int t, n, a[100005], b[100005];
  map<int, int> m;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    int flag = 1;
    m[a[0]]++;
    if (a[0] != b[0])
      flag = 0;
    else {
      for (int i = 1; i < n; i++) {
        if (b[i] - a[i] > 0 && m[1] == 0) flag = 0;
        if (b[i] - a[i] < 0 && m[-1] == 0) flag = 0;
        m[a[i]]++;
      }
    }
    m.clear();
    if (flag)
      cout << "Yes"
           << "\n";
    else
      cout << "No"
           << "\n";
  }
}
