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

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

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

e = A("e")
l = B("l")
g = C("g")
i = A("i")
d = A("d")
m = A("m")
h = C("h")
j = A("j")
c = A("c")
k = A("k")

e.v = d
l.o = h
l.s = c
g.o = h
i.v = k
d.v = k
m.v = j
h.o = g
j.v = k
c.v = i
k.v = i
assert d.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.txt = txt

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

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

e = A("e")
l = B("l")
g = C("g")
i = A("i")
d = A("d")
m = A("m")
h = C("h")
j = A("j")
c = A("c")
k = A("k")

e.v = d
l.o = h
l.s = c
g.o = h
i.v = k
d.v = k
m.v = j
h.o = g
j.v = k
c.v = i
k.v = i
assert d.v.v.v.v.v.v.txt == "i"