f=[[0,0,0,0] for n in range(17)] f[1][0]=13 f[1][1]=2 for n in range(2,17): f[n][0]=13*f[n-1][0] f[n][1]=3*f[n-1][0]+14*f[n-1][1] f[n][2]=2*f[n-1][1]+15*f[n-1][2] f[n][3]=f[n-1][2]+16*f[n-1][3] s=sum(f[n][3] for n in range(17)) print s,format(s,"X")