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

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

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

a = A("a")
f = B("f")
d = C("d")
g = B("g")
k = A("k")
i = B("i")
m = B("m")
e = C("e")

a.o = e
a.x = e
a.w = f
f.o = m
d.u = k
g.o = i
k.o = e
k.x = e
k.w = m
i.o = f
m.o = i
e.u = k
assert e.u.w.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.x: C = None
        self.w: B = None
        self.txt = txt

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

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

a = A("a")
f = B("f")
d = C("d")
g = B("g")
k = A("k")
i = B("i")
m = B("m")
e = C("e")

a.o = e
a.x = e
a.w = f
f.o = m
d.u = k
g.o = i
k.o = e
k.x = e
k.w = m
i.o = f
m.o = i
e.u = k
assert e.u.w.o.txt == "i"