class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: B = None
        self.q: B = None
        self.txt = txt

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

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

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

c.s = n
c.v = f
c.q = f
f.y = n
n.t = f
n.z = c
n.r = c
assert f.y.t.y.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.v: B = None
        self.q: B = None
        self.txt = txt

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

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

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

c.s = n
c.v = f
c.q = f
f.y = n
n.t = f
n.z = c
n.r = c
assert f.y.t.y.txt == "n"