import Data.Ratio
data Tree a = Node (Tree a) a (Tree a)
cf (Just r) [] = r
cf Nothing [] = 0
make b (x:xs) = Node (make True l) (cf Nothing $ x:xs) (make False r) where
(l,r) = if b
then (x+1 : xs, 2 : x-1 : xs)
else (2 : x-1 : xs, x+1 : xs)
t = make False [1]
bfs :: Tree a -> [Tree a]
bfs t = t : ext (bfs t) where
ext ((Node l _ r):qs) = l : r : ext qs
extract :: Tree a -> a
extract (Node _ x _) = x
aW1wb3J0IERhdGEuUmF0aW8KCmRhdGEgVHJlZSBhID0gTm9kZSAoVHJlZSBhKSBhIChUcmVlIGEpCgpjZiA6OiBNYXliZSBSYXRpb25hbCAtPiBbSW50ZWdlcl0gLT4gUmF0aW9uYWwKY2YgKEp1c3QgcikgW10gPSByCmNmIChKdXN0IHIpICh4OnhzKSA9IGNmIChKdXN0ICQgZnJvbUludGVncmFsIHggKyAxIC8gcikgeHMKY2YgTm90aGluZyAgW10gPSAwCmNmIE5vdGhpbmcgICh4OnhzKSA9IGNmIChKdXN0ICQgZnJvbUludGVncmFsIHgpIHhzCgptYWtlIDo6IEJvb2wgLT4gW0ludGVnZXJdIC0+IFRyZWUgUmF0aW9uYWwKbWFrZSBiICh4OnhzKSA9IE5vZGUgKG1ha2UgVHJ1ZSBsKSAoY2YgTm90aGluZyAkIHg6eHMpIChtYWtlIEZhbHNlIHIpIHdoZXJlCiAgKGwscikgPSBpZiBiCiAgICB0aGVuICh4KzEgOiB4cywgMiA6IHgtMSA6IHhzKQogICAgZWxzZSAoMiA6IHgtMSA6IHhzLCB4KzEgOiB4cykKCnQgOjogVHJlZSBSYXRpb25hbAp0ID0gbWFrZSBGYWxzZSBbMV0KCmJmcyA6OiBUcmVlIGEgLT4gW1RyZWUgYV0KYmZzIHQgPSB0IDogZXh0IChiZnMgdCkgd2hlcmUKICBleHQgKChOb2RlIGwgXyByKTpxcykgPSBsIDogciA6IGV4dCBxcwogIApleHRyYWN0IDo6IFRyZWUgYSAtPiBhCmV4dHJhY3QgKE5vZGUgXyB4IF8pID0geAoKbWFpbiA9IG1hcE1fIHByaW50ICQgdGFrZSAyMDAgJCBtYXAgZXh0cmFjdCAkIGJmcyB0