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

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

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

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

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

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

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

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

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