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

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

l = A("l")
m = B("m")
d = B("d")
a = A("a")
e = A("e")
f = A("f")
i = A("i")
b = B("b")
j = B("j")

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

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

l = A("l")
m = B("m")
d = B("d")
a = A("a")
e = A("e")
f = A("f")
i = A("i")
b = B("b")
j = B("j")

l.y = d
m.u = d
m.y = b
d.u = m
d.y = j
a.y = m
e.y = b
f.y = b
i.y = b
b.u = m
b.y = j
j.u = m
j.y = d
assert f.y.u.y.y.txt == "j"