def f( d) :
print ( 'For d =' , d)
# ar is the current tree, 0 is the root
# ar[i] is the bitset of values xor-ed together
ar = [ ( 1 << i) for i in range ( d) ]
a0 = ar[ :]
p = 0
while 1 :
p += 1
for i in range ( d) :
for j in range ( i+1 , d) :
ar[ i] ^= ar[ j]
for i in range ( d) :
print ( ( ar[ 0 ] >> i) & 1 , end= '' )
print ( '' )
if ar== a0:
break
print ( 'Period is' , p)
f( 4 )
f( 6 )
f( 8 )
CmRlZiBmKGQpOgoJcHJpbnQoJ0ZvciBkID0nLCBkKQoJIyBhciBpcyB0aGUgY3VycmVudCB0cmVlLCAwIGlzIHRoZSByb290CgkjIGFyW2ldIGlzIHRoZSBiaXRzZXQgb2YgdmFsdWVzIHhvci1lZCB0b2dldGhlcgoJYXIgPSBbKDEgPDwgaSkgZm9yIGkgaW4gcmFuZ2UoZCldCglhMCA9IGFyWzpdCglwID0gMAoJd2hpbGUgMToKCQlwICs9IDEKCQlmb3IgaSBpbiByYW5nZShkKToKCQkJZm9yIGogaW4gcmFuZ2UoaSsxLCBkKToKCQkJCWFyW2ldIF49IGFyW2pdCgkJZm9yIGkgaW4gcmFuZ2UoZCk6CgkJCXByaW50KChhclswXT4+aSkgJiAxLCBlbmQ9JycpCgkJcHJpbnQoJycpCgkJaWYgYXI9PWEwOgoJCQlicmVhawoJcHJpbnQoJ1BlcmlvZCBpcycsIHApCgpmKDQpCgpmKDYpCgpmKDgp