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

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

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

k = A("k")
f = B("f")
g = C("g")
b = A("b")
n = C("n")
l = B("l")
m = B("m")
c = C("c")

k.v = n
f.v = n
f.t = g
g.q = m
b.v = c
n.q = l
l.v = c
l.t = n
m.v = c
m.t = g
c.q = l
assert b.v.q.v.q.t.txt == "
class A:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

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

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

k = A("k")
f = B("f")
g = C("g")
b = A("b")
n = C("n")
l = B("l")
m = B("m")
c = C("c")

k.v = n
f.v = n
f.t = g
g.q = m
b.v = c
n.q = l
l.v = c
l.t = n
m.v = c
m.t = g
c.q = l
assert b.v.q.v.q.t.txt == "n"