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

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

c = A("c")
a = B("a")
k = A("k")
l = A("l")
j = B("j")
e = B("e")
b = B("b")
d = A("d")
h = B("h")
i = A("i")

c.x = k
a.x = k
k.x = d
l.x = k
j.x = d
e.x = l
b.x = d
d.x = k
h.x = k
i.x = k
assert e.x.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.x: A = None
        self.txt = txt

c = A("c")
a = B("a")
k = A("k")
l = A("l")
j = B("j")
e = B("e")
b = B("b")
d = A("d")
h = B("h")
i = A("i")

c.x = k
a.x = k
k.x = d
l.x = k
j.x = d
e.x = l
b.x = d
d.x = k
h.x = k
i.x = k
assert e.x.x.x.x.x.x.txt == "k"