#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n, tmp;
    cin >> n;
    vector<long long> a, b;
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      a.push_back(tmp);
    }
    for (int i = 0; i < n; i++) {
      cin >> tmp;
      b.push_back(tmp);
    }
    if (a[0] != b[0])
      cout << "NO" << endl;
    else {
      int rs = 0, gs = 0, flag = 0;
      for (int i = 0; i < n; i++) {
        if (b[i] > a[i] && rs < 1) {
          flag = 1;
          break;
        } else if (a[i] > b[i] && gs < 1) {
          flag = 1;
          break;
        }
        if (a[i] == 1) rs++;
        if (a[i] == -1) gs++;
      }
      if (flag == 1)
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
    }
  }
  return 0;
}
