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

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

i = A("i")
h = B("h")
m = A("m")
e = B("e")

i.y = e
h.r = i
h.o = i
m.y = e
e.r = m
e.o = i
assert e.o.y.r.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

i = A("i")
h = B("h")
m = A("m")
e = B("e")

i.y = e
h.r = i
h.o = i
m.y = e
e.r = m
e.o = i
assert e.o.y.r.txt == "m"