#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    long long flag = 0, p = 0, ne = 0;
    if (a[0] != b[0]) {
      flag = 1;
      cout << "NO" << endl;
      continue;
    }
    if (a[0] == 1) p++;
    if (a[0] == -1) ne++;
    for (int i = 1; i < n; i++) {
      if ((a[i] > b[i] && ne == 0) || (a[i] < b[i] && p == 0)) {
        flag = 1;
        cout << "NO" << endl;
        break;
      }
      if (a[i] == 1) p++;
      if (a[i] == -1) ne++;
    }
    if (flag == 0) cout << "YES" << endl;
  }
  return 0;
}
