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

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

l = A("l")
b = B("b")
e = B("e")
h = A("h")
c = B("c")
a = A("a")
m = A("m")
j = B("j")
f = B("f")
g = A("g")

l.s = c
b.t = j
b.z = j
e.t = j
e.z = f
h.s = b
c.t = b
c.z = e
a.s = b
m.s = b
j.t = e
j.z = e
f.t = b
f.z = j
g.s = b
assert b.t.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.s: B = None
        self.txt = txt

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

l = A("l")
b = B("b")
e = B("e")
h = A("h")
c = B("c")
a = A("a")
m = A("m")
j = B("j")
f = B("f")
g = A("g")

l.s = c
b.t = j
b.z = j
e.t = j
e.z = f
h.s = b
c.t = b
c.z = e
a.s = b
m.s = b
j.t = e
j.z = e
f.t = b
f.z = j
g.s = b
assert b.t.z.z.txt == "f"