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

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

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

j = A("j")
a = B("a")
k = C("k")
c = A("c")
n = A("n")
d = A("d")
m = B("m")

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

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

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

j = A("j")
a = B("a")
k = C("k")
c = A("c")
n = A("n")
d = A("d")
m = B("m")

j.v = k
j.r = k
a.u = k
k.q = c
k.v = a
c.v = k
c.r = k
n.v = k
n.r = k
d.v = k
d.r = k
m.u = k
assert c.r.q.v.q.r.txt == "k"