#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 (long long i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (long long j = 0; j < n; j++) {
      cin >> b[j];
    }
    if (a[0] != b[0]) {
      cout << "NO" << endl;
      continue;
    }
    long long c[2] = {0};
    if (a[0] == 1) {
      c[0]++;
    } else if (a[0] == -1)
      c[1]++;
    long long flag = 0;
    for (long long i = 1; i < n; i++) {
      if (a[i] > b[i] && c[1] == 0) {
        flag = 1;
        break;
      } else if (a[i] < b[i] && c[0] == 0) {
        flag = 1;
        break;
      } else {
        if (a[i] == 1)
          c[0]++;
        else if (a[i] == -1)
          c[1]++;
      }
      if (c[0] != 0 && c[1] != 0) break;
    }
    if (flag == 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
}
