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

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

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

e = A("e")
c = B("c")
i = C("i")
k = C("k")
h = A("h")
b = B("b")

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

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

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

e = A("e")
c = B("c")
i = C("i")
k = C("k")
h = A("h")
b = B("b")

e.w = b
e.o = h
c.z = h
c.p = k
i.p = b
i.x = c
k.p = b
k.x = b
h.w = c
h.o = e
b.z = e
b.p = i
assert e.w.p.x.z.o.txt == "e"