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

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

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

e = A("e")
m = B("m")
g = C("g")
c = A("c")
h = C("h")
f = B("f")
n = C("n")

e.x = g
e.v = c
m.u = g
m.o = c
g.y = e
c.x = n
c.v = e
h.y = c
f.u = g
f.o = c
n.y = c
assert h.y.v.x.y.x.y.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.v: A = None
        self.txt = txt

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

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

e = A("e")
m = B("m")
g = C("g")
c = A("c")
h = C("h")
f = B("f")
n = C("n")

e.x = g
e.v = c
m.u = g
m.o = c
g.y = e
c.x = n
c.v = e
h.y = c
f.u = g
f.o = c
n.y = c
assert h.y.v.x.y.x.y.x.txt == "g"