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

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

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

m = A("m")
g = B("g")
c = C("c")
f = A("f")
i = B("i")
j = C("j")
h = B("h")
l = A("l")

m.y = j
m.p = h
m.t = f
g.z = h
g.w = j
c.x = m
c.t = m
c.p = f
f.y = c
f.p = g
f.t = m
i.z = h
i.w = c
j.x = m
j.p = m
j.t = l
h.z = i
h.w = c
l.y = c
l.p = h
l.t = m
assert j.t.p.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: B = None
        self.t: A = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
c = C("c")
f = A("f")
i = B("i")
j = C("j")
h = B("h")
l = A("l")

m.y = j
m.p = h
m.t = f
g.z = h
g.w = j
c.x = m
c.t = m
c.p = f
f.y = c
f.p = g
f.t = m
i.z = h
i.w = c
j.x = m
j.p = m
j.t = l
h.z = i
h.w = c
l.y = c
l.p = h
l.t = m
assert j.t.p.z.w.txt == "c"