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

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

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

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

i.z = a
a.w = h
a.x = h
a.s = i
h.x = i
e.w = h
e.x = h
e.s = i
m.w = h
m.x = h
m.s = i
j.w = h
j.x = h
j.s = i
assert h.x.z.w.x.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

i.z = a
a.w = h
a.x = h
a.s = i
h.x = i
e.w = h
e.x = h
e.s = i
m.w = h
m.x = h
m.s = i
j.w = h
j.x = h
j.s = i
assert h.x.z.w.x.z.s.txt == "i"