#include using namespace std; void test_case(int tc){ int n; cin >> n; vector a(n); vector b(n); for (size_t i = 0; i < n; i++){ cin >> a[i]; } for (size_t i = 0; i < n; i++){ cin >> b[i]; } bool result = true; int exactdif = INT32_MAX; int hightestdif = 0; bool onlyzeroes = true; for(size_t i = 0; i < n; ++i){ auto ax = a[i], bx = b[i]; auto d = ax - bx; if(bx == 0){ hightestdif = max(hightestdif, d); } else { onlyzeroes = false; if(exactdif == INT32_MAX){ exactdif = d; } else if(exactdif != d){ result = false; break; } } } if(hightestdif > exactdif){ result = false; } cout << (result || onlyzeroes ? "YES" : "NO") << '\n'; } int main(){ ios::sync_with_stdio(0); cin.tie(0); int t; cin >> t; for(int tc = 1; tc <= t; ++tc){ test_case(tc); } cout << flush; return 0; }