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

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

e = A("e")
b = B("b")
f = B("f")
k = A("k")
n = A("n")
h = B("h")

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

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

e = A("e")
b = B("b")
f = B("f")
k = A("k")
n = A("n")
h = B("h")

e.x = b
e.t = h
b.z = h
f.z = b
k.x = h
k.t = h
n.x = h
n.t = f
h.z = b
assert e.t.z.z.z.z.txt == "h"