#include <bits/stdc++.h>
double IP = 2 * acos(0.0);
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int e[n + 2], b[n + 2];
    int mn = n + 1, pl = n + 1;
    int i;
    for (i = 0; i < n; i++) {
      cin >> e[i];
      if (e[i] == 1 and pl == n + 1) pl = i;
      if (e[i] == -1 and mn == n + 1) mn = i;
    }
    int ok = 1;
    for (i = 0; i < n; i++) {
      cin >> b[i];
      if (e[i] != b[i]) {
        if (b[i] < e[i] and mn < i and ok == 1)
          ok = 1;
        else if (b[i] > e[i] and pl < i and ok == 1)
          ok = 1;
        else {
          ok = 0;
        }
      }
    }
    if (ok == 0)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
