#include<bits/stdc++.h> using namespace std; #define module 1000000007 int main() { int t; cin>>t; while(t--) { int p,q,r,i,j,k; cin>>p>>q>>r; int a[p],b[q],c[r]; for(i=0;i<p;i++) { cin>>a[i]; } for(i=0;i<q;i++) { cin>>b[i]; } for(j=0;j<r;j++) { cin>>c[j]; } sort(a,a+p); sort(b,b+q); sort(b,b+r); int ans1[10000]={0}; int ans2[10000]={0}; j=0; int z1=0,z2=0; for(i=0;i<q;i++) { for(j=0;j<p;j++) { if(b[i]>=a[j]) { ans1[z1]=b[i]+a[j]; ans1[z1]=ans1[z1]%module; z1++; } else { ans1[z1]=0; break; } } for(k=0;k<r;k++) { if(b[i]>=c[k]) { ans2[z2]=b[i]+c[k]; ans2[z2]=ans2[z2]%module; z2++; } else { ans2[z2]=0; break; } } } int s=0; for(i=0;i<z1;i++) { if(ans1[i]!=0) { for(j=0;j<z2;j++) { if(ans2[j]!=0) { s=s+((ans1[i]*ans2[j])%module); } } } } s=s%module; cout<<s<<endl; } return 0; }
Asked by: Manish_Kumar_Savita on April 7, 2019, 6:34 p.m. Last updated on April 7, 2019, 6:34 p.m.