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

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

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

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

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

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

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

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

j.y = m
j.p = m
j.w = a
l.u = a
l.z = m
m.z = a
a.u = l
a.z = m
assert l.u.u.u.txt == "a"