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

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

i = A("i")
j = B("j")
e = A("e")
d = B("d")
l = B("l")

i.o = e
i.u = l
j.v = l
j.p = i
e.o = i
e.u = l
d.v = l
d.p = e
l.v = d
l.p = i
assert j.p.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.u: B = None
        self.txt = txt

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

i = A("i")
j = B("j")
e = A("e")
d = B("d")
l = B("l")

i.o = e
i.u = l
j.v = l
j.p = i
e.o = i
e.u = l
d.v = l
d.p = e
l.v = d
l.p = i
assert j.p.o.u.txt == "l"