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

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

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

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

m.o = k
m.p = k
k.u = n
k.z = m
k.p = m
n.x = k
assert k.u.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: B = None
        self.txt = txt

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

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

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

m.o = k
m.p = k
k.u = n
k.z = m
k.p = m
n.x = k
assert k.u.x.z.txt == "m"