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

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

l = A("l")
h = B("h")
i = B("i")
m = A("m")
f = B("f")
a = B("a")
d = A("d")

l.t = f
h.z = i
h.s = i
i.z = f
i.s = a
m.t = f
f.z = h
f.s = a
a.z = h
a.s = i
d.t = h
assert m.t.z.z.z.s.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

l = A("l")
h = B("h")
i = B("i")
m = A("m")
f = B("f")
a = B("a")
d = A("d")

l.t = f
h.z = i
h.s = i
i.z = f
i.s = a
m.t = f
f.z = h
f.s = a
a.z = h
a.s = i
d.t = h
assert m.t.z.z.z.s.z.z.txt == "i"