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

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

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

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

c.y = f
n.p = f
f.v = n
f.u = n
f.q = c
assert c.y.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

c.y = f
n.p = f
f.v = n
f.u = n
f.q = c
assert c.y.v.p.txt == "f"