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

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

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

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

e.o = k
e.t = m
k.o = e
k.u = c
k.w = a
f.y = e
c.y = m
d.y = m
m.o = k
m.t = e
a.y = m
assert c.y.o.w.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: A = None
        self.txt = txt

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

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

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

e.o = k
e.t = m
k.o = e
k.u = c
k.w = a
f.y = e
c.y = m
d.y = m
m.o = k
m.t = e
a.y = m
assert c.y.o.w.y.o.txt == "k"