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

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

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

j = A("j")
m = B("m")
a = C("a")

j.u = m
m.z = a
m.w = a
a.s = j
a.r = m
assert j.u.w.r.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

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

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

j = A("j")
m = B("m")
a = C("a")

j.u = m
m.z = a
m.w = a
a.s = j
a.r = m
assert j.u.w.r.txt == "m"