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

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

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

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

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

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

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

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

k.t = m
k.v = b
c.v = b
c.r = d
c.q = j
b.s = k
m.t = k
m.v = b
n.v = b
n.r = d
n.q = j
j.v = b
j.r = d
j.q = d
d.v = b
d.r = n
d.q = c
assert k.v.s.t.t.txt == "k"