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

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

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

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

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

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

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

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

i.v = a
i.r = a
i.w = c
a.z = c
a.r = i
a.q = i
b.y = a
b.s = c
c.y = a
c.s = n
n.y = a
n.s = c
assert a.r.r.z.s.txt == "n"