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

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

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

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

e.p = h
e.z = j
c.t = j
c.s = g
c.x = g
g.x = e
h.t = j
h.s = g
h.x = g
m.p = h
m.z = h
j.t = c
j.s = g
j.x = g
assert h.x.x.z.s.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.z: B = None
        self.txt = txt

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

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

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

e.p = h
e.z = j
c.t = j
c.s = g
c.x = g
g.x = e
h.t = j
h.s = g
h.x = g
m.p = h
m.z = h
j.t = c
j.s = g
j.x = g
assert h.x.x.z.s.txt == "g"