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

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

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

d = A("d")
h = B("h")
m = C("m")
e = A("e")

d.u = e
d.q = m
d.v = h
h.x = m
h.v = m
m.x = h
m.w = h
m.z = e
e.u = d
e.q = m
e.v = h
assert d.u.q.x.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.q: C = None
        self.v: B = None
        self.txt = txt

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

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

d = A("d")
h = B("h")
m = C("m")
e = A("e")

d.u = e
d.q = m
d.v = h
h.x = m
h.v = m
m.x = h
m.w = h
m.z = e
e.u = d
e.q = m
e.v = h
assert d.u.q.x.txt == "h"