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

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

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

j = A("j")
d = B("d")
h = C("h")
g = A("g")
a = C("a")
m = B("m")
i = C("i")

j.o = d
d.p = m
d.s = g
d.z = a
h.z = g
h.w = m
h.v = a
g.o = d
a.z = j
a.w = m
a.v = i
m.p = d
m.s = j
m.z = a
i.z = j
i.w = m
i.v = a
assert i.w.z.w.p.z.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

j = A("j")
d = B("d")
h = C("h")
g = A("g")
a = C("a")
m = B("m")
i = C("i")

j.o = d
d.p = m
d.s = g
d.z = a
h.z = g
h.w = m
h.v = a
g.o = d
a.z = j
a.w = m
a.v = i
m.p = d
m.s = j
m.z = a
i.z = j
i.w = m
i.v = a
assert i.w.z.w.p.z.w.txt == "m"