#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, a[100001], b[100001], flag = 1;
    cin >> n;
    vector<int> v(2, 0);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int j = 0; j < n; j++) cin >> b[j];
    for (int i = 0; i < n; i++) {
      if (a[i] < b[i] && v[1] != 1) {
        flag = 0;
        break;
      } else if (a[i] > b[i] && v[0] != -1) {
        flag = 0;
        break;
      }
      if (a[i] == 1) v[1] = 1;
      if (a[i] == -1) v[0] = -1;
    }
    if (flag == 0)
      cout << "NO\n";
    else
      cout << "YES\n";
  }
}
