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

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

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

k = A("k")
j = B("j")
c = C("c")
n = A("n")

k.v = j
j.v = n
j.q = c
j.r = c
c.r = k
c.u = k
c.s = n
n.v = j
assert k.v.r.s.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

k = A("k")
j = B("j")
c = C("c")
n = A("n")

k.v = j
j.v = n
j.q = c
j.r = c
c.r = k
c.u = k
c.s = n
n.v = j
assert k.v.r.s.txt == "n"