class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: 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.r: B = None
        self.txt = txt

j = A("j")
f = B("f")
a = C("a")

j.y = f
j.t = a
f.z = j
a.r = f
assert a.r.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.t: 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.r: B = None
        self.txt = txt

j = A("j")
f = B("f")
a = C("a")

j.y = f
j.t = a
f.z = j
a.r = f
assert a.r.z.y.txt == "f"