def r gets.split.map &:to_i end s=->a{c=[1]+[x=0]*M=1024 a.each{c[x^=_1]+=1} t=[0]*M (0...M).each{|i|(0...i).each{t[i^_1]+=c[i]*c[_1]} t[0]+=c[i]*~-c[i]/2} t} *,k=r x=s[r] y=s[r] p (0...M).sum{x[_1]*y[_1^k]}.%10**9+7