6. #include<iostream>#include<cstdio>#include<cstring>#include<cmath>#include<algorithm>#include<set>usingnamespacestd;#definemem(x,y)memset(x,y,sizeof(x))constintMOD=5000010;constintMAXN=5000010;inttop;inthash[MAXN],next[MAXN],head[MAXN];voidadd(intx){inti=x%MOD;hash[top]=x;next...