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

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

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

h = A("h")
b = B("b")
i = C("i")
n = A("n")
m = C("m")
c = B("c")
g = C("g")

h.w = m
b.x = g
b.o = h
i.t = c
i.z = g
n.w = i
m.t = c
m.z = i
c.x = m
c.o = n
g.t = c
g.z = i
assert h.w.z.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

h = A("h")
b = B("b")
i = C("i")
n = A("n")
m = C("m")
c = B("c")
g = C("g")

h.w = m
b.x = g
b.o = h
i.t = c
i.z = g
n.w = i
m.t = c
m.z = i
c.x = m
c.o = n
g.t = c
g.z = i
assert h.w.z.t.txt == "c"