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

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

k = A("k")
n = B("n")
f = B("f")
l = B("l")
d = B("d")
j = A("j")
m = A("m")

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

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

k = A("k")
n = B("n")
f = B("f")
l = B("l")
d = B("d")
j = A("j")
m = A("m")

k.v = f
n.q = f
f.q = l
l.q = d
d.q = l
j.v = n
m.v = n
assert f.q.q.q.q.txt == "d"