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

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

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

g = A("g")
e = B("e")
h = C("h")
c = A("c")
l = A("l")
a = C("a")
f = B("f")
i = B("i")

g.w = h
e.p = g
e.x = g
h.u = a
h.o = a
h.w = e
c.w = a
l.w = a
a.u = h
a.o = h
a.w = i
f.p = c
f.x = g
i.p = g
i.x = l
assert a.o.w.x.w.w.txt == "
class A:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
h = C("h")
c = A("c")
l = A("l")
a = C("a")
f = B("f")
i = B("i")

g.w = h
e.p = g
e.x = g
h.u = a
h.o = a
h.w = e
c.w = a
l.w = a
a.u = h
a.o = h
a.w = i
f.p = c
f.x = g
i.p = g
i.x = l
assert a.o.w.x.w.w.txt == "e"