#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i <= n - 1; i++) cin >> a[i];
    for (int j = 0; j <= n - 1; j++) cin >> b[j];
    if (a[0] != b[0]) {
      cout << "NO\n";
      continue;
    }
    bool a_1 = false;
    bool a_m1 = false;
    int x = 0;
    while (a[x] == b[x]) {
      if (a[x] == 1)
        a_1 = true;
      else if (a[x] == -1)
        a_m1 = true;
      x++;
      if (x == n) break;
    }
    while (x < n) {
      if (a[x] == b[x]) {
        a_1 = (a_1 || (a[x] > 0));
        a_m1 = (a_m1 || (a[x] < 0));
        x++;
      } else if (a[x] < b[x] && a_1 == true) {
        a_1 = (a_1 || (a[x] > 0));
        a_m1 = (a_m1 || (a[x] < 0));
        x++;
      } else if (a[x] > b[x] && a_m1 == true) {
        a_1 = (a_1 || (a[x] > 0));
        a_m1 = (a_m1 || (a[x] < 0));
        x++;
      } else
        break;
    }
    if (x == n) {
      cout << "YES\n";
      continue;
    } else {
      cout << "NO\n";
      continue;
    }
  }
}
