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

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

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

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

m.z = k
m.o = k
m.u = g
h.y = m
j.r = g
j.w = g
j.z = g
k.r = h
k.w = h
k.z = g
g.y = m
assert j.z.y.u.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.u: B = None
        self.o: C = None
        self.txt = txt

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

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

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

m.z = k
m.o = k
m.u = g
h.y = m
j.r = g
j.w = g
j.z = g
k.r = h
k.w = h
k.z = g
g.y = m
assert j.z.y.u.y.o.txt == "k"