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

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

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

i = A("i")
n = B("n")
g = C("g")
e = B("e")
k = A("k")
d = A("d")

i.o = n
n.u = e
g.p = n
g.u = n
g.w = i
e.u = n
k.o = n
d.o = e
assert d.o.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.txt = txt

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

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

i = A("i")
n = B("n")
g = C("g")
e = B("e")
k = A("k")
d = A("d")

i.o = n
n.u = e
g.p = n
g.u = n
g.w = i
e.u = n
k.o = n
d.o = e
assert d.o.u.u.txt == "e"