#include <bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n], b[n];
    bool pos[n], neg[n];
    memset(pos, 0, sizeof(pos));
    memset(neg, 0, sizeof(neg));
    for (long long int i = 0; i < n; i++) {
      cin >> a[i];
    }
    if (a[0] == 0) {
      pos[0] = false;
      neg[0] = false;
    }
    if (a[0] == 1) {
      pos[0] = true;
      neg[0] = false;
    }
    if (a[0] == -1) {
      pos[0] = false;
      neg[0] = true;
    }
    for (long long int i = 1; i <= n - 1; i++) {
      if (pos[i - 1] == true || a[i] == 1) pos[i] = true;
      if (neg[i - 1] == true || a[i] == -1) neg[i] = true;
    }
    for (long long int i = 0; i < n; i++) cin >> b[i];
    if (a[0] != b[0]) {
      cout << "NO" << endl;
      continue;
    }
    long long int c = 0;
    long long int u = 0;
    for (long long int i = n - 1; i > 0; i--) {
      c = 0;
      if (b[i] - a[i] > 0) {
        if (pos[i - 1] == true) {
          c++;
        }
        if (c == 0) {
          u++;
          cout << "NO" << endl;
          break;
        }
      }
      if (b[i] - a[i] < 0) {
        if (neg[i - 1] == true) {
          c++;
        }
        if (c == 0) {
          u++;
          cout << "NO" << endl;
          break;
        }
      }
    }
    if (u == 0) cout << "YES" << endl;
  }
  return 0;
}
