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.w: A = None
        self.txt = txt

k = A("k")
d = B("d")
l = A("l")
f = B("f")

k.o = l
k.u = f
d.w = k
l.o = k
l.u = d
f.w = k
assert d.w.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.w: A = None
        self.txt = txt

k = A("k")
d = B("d")
l = A("l")
f = B("f")

k.o = l
k.u = f
d.w = k
l.o = k
l.u = d
f.w = k
assert d.w.o.u.txt == "d"