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

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

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

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

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

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

a.x = d
a.y = i
d.x = i
e.x = i
e.y = b
n.x = i
n.y = d
l.x = i
l.y = d
b.x = d
i.x = b
assert d.x.x.x.x.x.txt == "b"