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

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

l = A("l")
k = B("k")
b = B("b")
a = A("a")
f = A("f")
e = B("e")
h = B("h")
d = B("d")

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

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

l = A("l")
k = B("k")
b = B("b")
a = A("a")
f = A("f")
e = B("e")
h = B("h")
d = B("d")

l.z = a
l.t = e
k.z = a
b.z = a
a.z = l
a.t = d
f.z = l
f.t = h
e.z = f
h.z = f
d.z = l
assert h.z.z.t.z.z.t.txt == "e"