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

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

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

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

h.v = g
d.o = h
i.o = f
i.p = d
i.y = h
e.o = n
e.p = g
e.y = h
g.o = h
f.o = e
f.p = d
f.y = h
n.o = e
n.p = d
n.y = h
assert d.o.v.o.v.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.txt = txt

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

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

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

h.v = g
d.o = h
i.o = f
i.p = d
i.y = h
e.o = n
e.p = g
e.y = h
g.o = h
f.o = e
f.p = d
f.y = h
n.o = e
n.p = d
n.y = h
assert d.o.v.o.v.o.v.txt == "g"