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

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

g = A("g")
k = B("k")
e = B("e")

g.z = k
k.t = e
e.t = k
assert e.t.t.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: B = None
        self.txt = txt

g = A("g")
k = B("k")
e = B("e")

g.z = k
k.t = e
e.t = k
assert e.t.t.t.txt == "k"