class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: B = None
        self.txt = txt

h = A("h")
b = B("b")
k = A("k")
m = A("m")
c = B("c")
f = A("f")
n = A("n")

h.o = c
b.t = c
b.u = c
k.o = b
m.o = b
c.t = b
c.u = b
f.o = b
n.o = c
assert c.t.u.u.u.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.t: B = None
        self.u: B = None
        self.txt = txt

h = A("h")
b = B("b")
k = A("k")
m = A("m")
c = B("c")
f = A("f")
n = A("n")

h.o = c
b.t = c
b.u = c
k.o = b
m.o = b
c.t = b
c.u = b
f.o = b
n.o = c
assert c.t.u.u.u.t.t.t.txt == "b"