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

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

l = A("l")
m = B("m")
k = A("k")
a = B("a")
d = B("d")
j = B("j")

l.p = j
l.u = a
m.o = d
m.y = j
k.p = d
k.u = j
a.o = m
a.y = m
d.o = m
d.y = j
j.o = m
j.y = d
assert a.o.y.o.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: B = None
        self.txt = txt

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

l = A("l")
m = B("m")
k = A("k")
a = B("a")
d = B("d")
j = B("j")

l.p = j
l.u = a
m.o = d
m.y = j
k.p = d
k.u = j
a.o = m
a.y = m
d.o = m
d.y = j
j.o = m
j.y = d
assert a.o.y.o.y.txt == "j"