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.s: B = None
        self.txt = txt

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

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

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

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