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

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

e = A("e")
k = B("k")
g = B("g")
n = B("n")
m = B("m")
h = B("h")

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

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

e = A("e")
k = B("k")
g = B("g")
n = B("n")
m = B("m")
h = B("h")

e.z = k
k.t = e
g.t = e
n.t = e
m.t = e
h.t = e
assert k.t.z.t.z.t.txt == "e"