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

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

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

c = A("c")
j = B("j")
k = C("k")
e = B("e")
m = A("m")
i = C("i")

c.p = j
c.o = j
c.r = i
j.z = i
j.w = m
j.t = e
k.u = i
k.w = e
e.z = k
e.w = c
e.t = j
m.p = e
m.o = j
m.r = i
i.u = k
i.w = j
assert c.p.t.w.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.o: B = None
        self.r: C = None
        self.txt = txt

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

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

c = A("c")
j = B("j")
k = C("k")
e = B("e")
m = A("m")
i = C("i")

c.p = j
c.o = j
c.r = i
j.z = i
j.w = m
j.t = e
k.u = i
k.w = e
e.z = k
e.w = c
e.t = j
m.p = e
m.o = j
m.r = i
i.u = k
i.w = j
assert c.p.t.w.p.txt == "j"