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

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

l = A("l")
m = B("m")
n = B("n")
i = B("i")
d = A("d")
j = B("j")
a = B("a")

l.y = d
m.u = l
n.u = l
i.u = l
d.y = l
j.u = l
a.u = d
assert a.u.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

l = A("l")
m = B("m")
n = B("n")
i = B("i")
d = A("d")
j = B("j")
a = B("a")

l.y = d
m.u = l
n.u = l
i.u = l
d.y = l
j.u = l
a.u = d
assert a.u.y.y.y.txt == "l"