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

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

k = A("k")
l = B("l")
d = B("d")
i = B("i")
c = A("c")
h = B("h")
f = B("f")
m = A("m")

k.q = f
k.v = d
l.x = d
d.x = i
i.x = h
c.q = f
c.v = l
h.x = l
f.x = i
m.q = f
m.v = f
assert m.q.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.v: B = None
        self.txt = txt

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

k = A("k")
l = B("l")
d = B("d")
i = B("i")
c = A("c")
h = B("h")
f = B("f")
m = A("m")

k.q = f
k.v = d
l.x = d
d.x = i
i.x = h
c.q = f
c.v = l
h.x = l
f.x = i
m.q = f
m.v = f
assert m.q.x.x.x.x.txt == "d"