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

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

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

c = A("c")
a = B("a")
i = C("i")
m = C("m")
n = A("n")

c.y = a
c.r = a
c.q = n
a.u = c
a.t = m
i.t = n
i.w = a
i.v = c
m.t = n
m.w = a
m.v = c
n.y = a
n.r = a
n.q = c
assert c.q.q.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.q: A = None
        self.r: B = None
        self.txt = txt

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

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

c = A("c")
a = B("a")
i = C("i")
m = C("m")
n = A("n")

c.y = a
c.r = a
c.q = n
a.u = c
a.t = m
i.t = n
i.w = a
i.v = c
m.t = n
m.w = a
m.v = c
n.y = a
n.r = a
n.q = c
assert c.q.q.r.txt == "a"