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

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

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

m.y = h
m.u = b
h.w = i
h.v = b
e.y = b
e.u = b
b.w = m
b.v = h
c.y = h
c.u = h
i.y = h
i.u = b
assert i.u.w.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.u: B = None
        self.txt = txt

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

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

m.y = h
m.u = b
h.w = i
h.v = b
e.y = b
e.u = b
b.w = m
b.v = h
c.y = h
c.u = h
i.y = h
i.u = b
assert i.u.w.u.txt == "b"