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

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

h = A("h")
a = B("a")
d = A("d")

h.y = a
h.u = d
a.o = h
d.y = a
d.u = h
assert d.u.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: A = None
        self.txt = txt

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

h = A("h")
a = B("a")
d = A("d")

h.y = a
h.u = d
a.o = h
d.y = a
d.u = h
assert d.u.y.o.txt == "h"