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

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

k = A("k")
c = B("c")
m = B("m")
e = A("e")

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

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

k = A("k")
c = B("c")
m = B("m")
e = A("e")

k.s = m
k.o = m
c.r = m
m.r = c
e.s = m
e.o = m
assert e.o.r.r.txt == "m"