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

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

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

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

k.y = m
k.z = m
m.v = a
a.p = k
a.w = k
a.o = m
assert k.y.v.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.z: B = None
        self.txt = txt

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

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

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

k.y = m
k.z = m
m.v = a
a.p = k
a.w = k
a.o = m
assert k.y.v.o.txt == "m"