#include <iostream>
#include <string.h>
using namespace std;
int main()
{
int t;
int a[100005],b[100005];
cin>>t;
while(t--)
{
bool start=false,end=false;
int n,d=0,t=0,ans=1;
cin>>n;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
for(int i=1; i<=n;i++)
{
cin>>a[i];
}
for(int i=1; i<=n;i++)
{
cin>>b[i];
d=b[i]-a[i];
if(d>0&&end) ans=0;
if((d>0)||start)
{
if(d==0) end=true;
else
{
if(!t) t=d;
else if(t!=d) ans=0;
start=true;
}
}
if(d<0) ans=0;
}
if(ans==1) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
d=0,t=0;
start=false,end=false,ans=1;
}
return 0;
}