def r(n,a):o=n*8;return map(int,(a[o+1],a[o+3],a[o+5],a[o+7])) def m(r,c):return map(max,c,(r[0]+r[2],r[1]+r[3])) def d(t):return [[""]*t[0]for _ in xrange(t[1])] def k(r,c,f): x=r[0] while x-r[0]<r[2]: y=r[1] while y-r[1]<r[3]:f[y][x]+=c;y+=1 x+=1 return f def n(f,s):return len(filter(lambda e:set(s).issubset(set(e)),f)) while 1:s=raw_input().split(' ');a=r(0,s);b=r(1,s);c=r(2,s);f=d(m(a,m(b,m(c,(0,0)))));f=sum(k(a,'a',k(b,'b',k(c,'c',f))),[]);print "ab {0} ac {1} bc {2} abc {3}".format(n(f,"ab"),n(f,"ac"),n(f,"bc"),n(f,"abc"))
Note that non-ascii characters in the above source code will be escaped (such as \x9f).