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

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

l = A("l")
i = B("i")
m = B("m")
n = B("n")
h = A("h")
j = A("j")
k = A("k")
e = A("e")
d = A("d")
b = A("b")

l.x = d
i.w = l
m.w = b
n.w = k
h.x = l
j.x = e
k.x = l
e.x = k
d.x = e
b.x = l
assert j.x.x.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.txt = txt

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

l = A("l")
i = B("i")
m = B("m")
n = B("n")
h = A("h")
j = A("j")
k = A("k")
e = A("e")
d = A("d")
b = A("b")

l.x = d
i.w = l
m.w = b
n.w = k
h.x = l
j.x = e
k.x = l
e.x = k
d.x = e
b.x = l
assert j.x.x.x.x.x.txt == "e"