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

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

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

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

e.z = h
e.u = k
k.p = j
k.x = h
j.u = e
j.o = e
i.u = e
i.o = e
h.z = e
h.u = k
m.p = j
m.x = h
assert k.x.u.p.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.u: B = None
        self.txt = txt

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

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

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

e.z = h
e.u = k
k.p = j
k.x = h
j.u = e
j.o = e
i.u = e
i.o = e
h.z = e
h.u = k
m.p = j
m.x = h
assert k.x.u.p.o.txt == "e"