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

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

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

a = A("a")
c = B("c")
e = C("e")
n = C("n")

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

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

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

a = A("a")
c = B("c")
e = C("e")
n = C("n")

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