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

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

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

e = A("e")
j = B("j")
m = C("m")
c = A("c")
n = C("n")
h = C("h")
l = B("l")

e.o = l
e.y = h
e.p = c
j.s = c
j.w = l
m.w = n
m.z = e
c.o = j
c.y = m
c.p = e
n.w = m
n.z = c
h.w = n
h.z = e
l.s = e
l.w = j
assert m.z.o.w.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.y: C = None
        self.p: A = None
        self.txt = txt

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

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

e = A("e")
j = B("j")
m = C("m")
c = A("c")
n = C("n")
h = C("h")
l = B("l")

e.o = l
e.y = h
e.p = c
j.s = c
j.w = l
m.w = n
m.z = e
c.o = j
c.y = m
c.p = e
n.w = m
n.z = c
h.w = n
h.z = e
l.s = e
l.w = j
assert m.z.o.w.w.w.txt == "j"