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

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

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

e = A("e")
c = B("c")
f = C("f")

e.z = f
c.z = e
f.y = c
assert f.y.z.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: A = None
        self.txt = txt

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

e = A("e")
c = B("c")
f = C("f")

e.z = f
c.z = e
f.y = c
assert f.y.z.z.txt == "f"