#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int h = 0; h < t; h++) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    bool f1 = false, f0 = false, fmin1 = false, flag = true;
    if (a[0] != b[0]) {
      cout << "NO" << endl;
      continue;
    }
    if (a[0] > 0)
      f1 = true;
    else if (a[0] == 0)
      f0 = true;
    else
      fmin1 = true;
    for (int i = 1; i < n; i++) {
      if (a[i] == b[i]) {
        if (a[i] > 0)
          f1 = true;
        else if (a[i] == 0)
          f0 = true;
        else
          fmin1 = true;
        continue;
      }
      if (b[i] < 0 && fmin1 == false) {
        flag = false;
        break;
      }
      if (b[i] > 0 && f1 == false) {
        flag = false;
        break;
      }
      if (b[i] == 0 && (f0 == false || !(f1 && fmin1)) && !(f1 && a[i] == -1) &&
          !(fmin1 && a[i] == 1)) {
        flag = false;
        break;
      }
      if (a[i] > 0)
        f1 = true;
      else if (a[i] == 0)
        f0 = true;
      else
        fmin1 = true;
    }
    flag ? cout << "YES" : cout << "NO";
    cout << endl;
  }
  return 0;
}
