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

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

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

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

k.p = m
k.z = h
m.s = h
m.x = h
m.u = k
h.v = m
assert k.p.x.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: C = None
        self.txt = txt

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

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

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

k.p = m
k.z = h
m.s = h
m.x = h
m.u = k
h.v = m
assert k.p.x.v.txt == "m"