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

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

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

k = A("k")
b = B("b")
f = C("f")
i = C("i")
e = C("e")
l = C("l")
j = B("j")
m = B("m")
c = A("c")
g = B("g")

k.x = l
b.q = j
b.r = g
f.v = k
i.v = c
e.v = c
l.v = k
j.q = m
j.r = g
m.q = b
m.r = g
c.x = e
g.q = j
g.r = j
assert f.v.x.v.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
f = C("f")
i = C("i")
e = C("e")
l = C("l")
j = B("j")
m = B("m")
c = A("c")
g = B("g")

k.x = l
b.q = j
b.r = g
f.v = k
i.v = c
e.v = c
l.v = k
j.q = m
j.r = g
m.q = b
m.r = g
c.x = e
g.q = j
g.r = j
assert f.v.x.v.x.v.x.txt == "l"