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

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

d = A("d")
k = B("k")
e = B("e")
h = B("h")

d.o = h
k.r = d
k.s = d
e.r = d
e.s = d
h.r = d
h.s = d
assert k.r.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

d = A("d")
k = B("k")
e = B("e")
h = B("h")

d.o = h
k.r = d
k.s = d
e.r = d
e.s = d
h.r = d
h.s = d
assert k.r.o.r.txt == "d"