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

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

k = A("k")
m = B("m")
d = B("d")
a = A("a")
e = B("e")
g = A("g")
n = B("n")
l = A("l")
i = B("i")

k.v = m
m.x = e
d.x = n
a.v = i
e.x = i
g.v = m
n.x = m
l.v = n
i.x = m
assert i.x.x.x.x.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

k = A("k")
m = B("m")
d = B("d")
a = A("a")
e = B("e")
g = A("g")
n = B("n")
l = A("l")
i = B("i")

k.v = m
m.x = e
d.x = n
a.v = i
e.x = i
g.v = m
n.x = m
l.v = n
i.x = m
assert i.x.x.x.x.x.x.x.x.x.txt == "i"