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

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

c = A("c")
l = B("l")
h = B("h")
d = A("d")

c.u = l
c.w = h
l.x = h
h.x = l
d.u = l
d.w = h
assert d.w.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.w: B = None
        self.txt = txt

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

c = A("c")
l = B("l")
h = B("h")
d = A("d")

c.u = l
c.w = h
l.x = h
h.x = l
d.u = l
d.w = h
assert d.w.x.x.x.txt == "l"