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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

h.z = m
h.v = m
h.x = k
c.y = k
k.q = m
m.z = h
m.v = h
m.x = k
assert m.x.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: C = None
        self.v: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

h.z = m
h.v = m
h.x = k
c.y = k
k.q = m
m.z = h
m.v = h
m.x = k
assert m.x.q.x.txt == "k"