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

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

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

m = A("m")
l = B("l")
f = C("f")

m.u = l
m.x = f
m.y = f
l.u = m
l.y = f
f.w = m
f.z = l
assert l.u.x.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: C = None
        self.y: C = None
        self.txt = txt

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

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

m = A("m")
l = B("l")
f = C("f")

m.u = l
m.x = f
m.y = f
l.u = m
l.y = f
f.w = m
f.z = l
assert l.u.x.w.txt == "m"