#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int *arr = new int[n];
    long int *arr1 = new long int[n];
    pair<int, int> p;
    vector<pair<int, int> > v;
    for (int i = 0; i < n; i++) {
      cin >> arr[i];
    }
    for (int i = 0; i < n; i++) {
      cin >> arr1[i];
    }
    p = make_pair(0, 0);
    v.push_back(p);
    for (int i = 1; i < n; i++) {
      if (arr[i - 1] == 1) {
        int pos = p.first;
        int sec = p.second;
        p = make_pair(pos + 1, sec);
        v.push_back(p);
      } else if (arr[i - 1] == -1) {
        int pos = p.first;
        int sec = p.second;
        p = make_pair(pos, sec + 1);
        v.push_back(p);
      } else {
        int pos = p.first;
        int sec = p.second;
        p = make_pair(pos, sec);
        v.push_back(p);
      }
    }
    bool flag = true;
    for (int i = 0; i < n; i++) {
      if ((i == 0) && (arr[i] != arr1[i])) {
        flag = false;
        break;
      } else {
        if (i == 0) continue;
        int pos = v[i].first;
        int sec = v[i].second;
        if (arr1[i] == arr[i])
          continue;
        else if ((arr1[i] == 0 && arr[i] > 0 && sec == 0) ||
                 (arr1[i] == 0 && arr[i] < 0 && pos == 0)) {
          flag = false;
          break;
        } else if (arr1[i] > 0 && pos == 0) {
          flag = false;
          break;
        } else if (arr1[i] < 0 && sec == 0) {
          flag = false;
          break;
        }
      }
    }
    if (flag == true)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
