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

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

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

e = A("e")
k = B("k")
g = C("g")
j = C("j")
d = C("d")
a = A("a")

e.w = a
e.u = a
e.y = a
k.z = a
k.o = e
g.o = k
g.y = j
j.o = k
j.y = g
d.o = k
d.y = g
a.w = e
a.u = e
a.y = e
assert e.u.w.y.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.u: A = None
        self.y: A = None
        self.txt = txt

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

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

e = A("e")
k = B("k")
g = C("g")
j = C("j")
d = C("d")
a = A("a")

e.w = a
e.u = a
e.y = a
k.z = a
k.o = e
g.o = k
g.y = j
j.o = k
j.y = g
d.o = k
d.y = g
a.w = e
a.u = e
a.y = e
assert e.u.w.y.u.u.txt == "a"